Configure Maven to automate tasks for Liberty

Apache Maven is a software project management tool based on the concept of a project object model (POM). We can use the Liberty Maven plug-in to manage the runtime and applications.

We can use the open source Liberty Maven plug-in to create, start, stop, and package the Liberty runtime, and to test the applications on Liberty. Each task is represented by a specific goal in Maven. This plug-in, which is available under the io.openliberty.tools group ID, supports both WebSphere Liberty and Open Liberty.

GitHub has documentation on using Maven and on Maven goals for automating Liberty tasks.

We can configure the Liberty Maven plug-in with Liberty runtime installation information specified as either:

  • Maven coordinates
  • An existing installation directory
  • A compressed archive

If no runtime installation is configured, the default artifact is used, which includes the latest version of the full Open Liberty runtime kernel.

For the latest available version see the Liberty Maven Plug-in documentation in GitHub.


Configure a Liberty installation using Maven coordinates

Use the runtimeArtifact parameter to specify the coordinates (group name, artifact ID, and version) of the Maven artifact containing Liberty runtime files, as shown in the following example. This example specifies the coordinates for the WebSphere Liberty runtime with all Jakarta EE 9 features.

    ...
    <plugin>
        <groupId>io.openliberty.tools</groupId>
        <artifactId>liberty-maven-plugin</artifactId> 
        <version>3.7.1</version>
        <configuration>
            <runtimeArtifact> 
                <groupId>com.ibm.websphere.appserver.runtime</groupId> 
                <artifactId>wlp-jakartaee9</artifactId>
                <version>22.0.0.10</version>
                <type>zip</type>
            </runtimeArtifact> 
        </configuration>
    </plugin>
    ...
    

For a list of the available coordinates for WebSphere Liberty and Open Liberty, see Use a Maven artifact.


Configure an installation using an existing Liberty installation directory

Use the installDirectory parameter to specify the directory of an existing Liberty runtime installation, as shown in the following example.

    ...
    <plugin>
        <groupId>io.openliberty.tools</groupId>
        <artifactId>liberty-maven-plugin</artifactId> 
        <version>3.7.1</version>
        <configuration>
            <installDirectory>/opt/ibm/wlp</installDirectory>
        </configuration>
    </plugin>
    ...
    


Configure an installation using a compressed Liberty archive

Use the runtimeArchive parameter to specify a compressed archive containing Libertyruntime files, as shown in the following example.

    ...
    <plugin>
        <groupId>io.openliberty.tools</groupId>
        <artifactId>liberty-maven-plugin</artifactId> 
        <version>3.7.1</version>
        <configuration>
            <runtimeArchive>/opt/ibm/wlp.zip</runtimeArchive>
        </configuration>
    </plugin>
    ...