Use Maven to automate tasks for the Liberty profile
Apache Maven is a software project management tool based on the concept of a project object model (POM). We can use the Maven plug-in provided by the Liberty profile to manage the server and applications.
The Maven plug-in for the Liberty profile is located in the WebSphere Application Server Developer Community (WASdev) Maven repository. To use the Maven plug-in for Liberty, we must make sure the WASdev plug-in repository is specified in the pom.xml file of the project. The following example shows how to configure this repository and enable liberty-maven-plugin in your project.
<project> ... <pluginRepositories> <!-- Configure WASdev repository --> <pluginRepository> <id>WASdev</id> <name>WASdev Repository</name> <url>http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </pluginRepository> </pluginRepositories> ... <build> <plugins> <!-- Enable liberty-maven-plugin --> <plugin> <groupId>com.ibm.websphere.wlp.maven.plugins</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>1.0</version> <!-- Specify configuration, executions for liberty-maven-plugin --> ... </plugin> </plugins> </build> ... </project>The Liberty Maven plug-in must be configured with Liberty profile server installation information. The installation information can be specified as an existing installation directory, a compressed archive, or as a Maven artifact.
- Configure with existing installation directory.
Use the serverHome parameter to specify the directory of an existing Liberty profile server installation. For example:
... <plugin> <groupId>com.ibm.websphere.wlp.maven.plugins</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>1.0</version> <configuration> <serverHome>/opt/ibm/wlp</serverHome> </configuration> </plugin> ...
- Configure with compressed archive.
Use the assemblyArchive parameter to specify a compressed archive containing Liberty profile server files. For example:
... <plugin> <groupId>com.ibm.websphere.wlp.maven.plugins</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>1.0</version> <configuration> <assemblyArchive>/opt/ibm/wlp.zip</assemblyArchive> </configuration> </plugin> ...
- Configure with Maven artifact name.
Use the assemblyArtifact parameter to specify the name of the Maven artifact containing Liberty profile server files. For example:
... <plugin> <groupId>com.ibm.websphere.wlp.maven.plugins</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>1.0</version> <configuration> <assemblyArtifact> <groupId>com.ibm.ws.liberty.test</groupId> <artifactId>liberty-test-server</artifactId> <version>1.0</version> <type>zip</type> </assemblyArtifact> </configuration> </plugin> ...For more information on installing Liberty profile server as a Maven artifact, see Installation as a Maven artifact.
We can use the provided Maven plug-in to create, start, stop, and package a Liberty profile server, and test the application on the Liberty profile. Each task is represented by a specific goal in Maven.
Subtopics
- Maven goal - liberty:start-server
We can use the liberty:start-server goal to start a Liberty profile server in the file system.
- Maven goal - liberty:create-server
We can use the liberty:create-server goal to create a Liberty profile server.
- Maven goal - liberty:package-server
We can use the liberty:package-server goal to package a Liberty profile server.
- Maven goal - liberty:stop-server
We can use the liberty:stop-server goal to stop a Liberty profile server.
- Maven goal - liberty:deploy
We can use the liberty:deploy goal to deploy an application to a Liberty profile server.
- Maven goal - liberty:undeploy
We can use the liberty:undeploy goal to remove an application from a Liberty profile server.
- Maven goal - liberty:install-apps
We can use the liberty:install-apps goal to copy one or more applications to a Liberty profile server.
Parent topic: Administer the Liberty profile from the command promptReference:
The Apache Maven projectInstallation as a Maven artifact