Home

Awesome

ci.maven Maven Central Latest Build Status

The Liberty Maven plugin supports install and operational control of Liberty runtime and servers. Use it to manage your application on Liberty for integration test and to create Liberty server packages.

Usage - TLDR

Build

As of version 3.9 of the plugin, you must use Maven 3.8.6 or later to build the Liberty Maven plugin. We conveniently provide the maven-wrapper script, so you do not need to download maven yourself if you are not using it yet.

Plugins

Liberty Maven Plugin

The Liberty Maven Plugin provides a number of goals for managing a Liberty server and applications. As of version 3.9 of the plugin, Maven 3.8.6 or later is required to use the Liberty Maven Plugin.

Java Support

The Liberty Maven Plugin is tested with Long-Term-Support (LTS) releases of Java. The plugin, as of release 3.10, supports Java 8, 11, 17 and 21. Versions 3.7 to 3.9.x support Java 8, 11 and 17. Prior to version 3.7, the plugin is supported on Java 8 and 11.

Release 3.0 differences

The new capabilities and behavior differences are summarized in the Liberty Maven Plug-in 3.0 release notes.

Configuration

To enable Liberty Maven Plugin in your project add the following to your pom.xml:

<project>
    ...
    <build>
        <plugins>
            <!-- Enable liberty-maven-plugin -->
            <plugin>
                <groupId>io.openliberty.tools</groupId>
                <artifactId>liberty-maven-plugin</artifactId>
                <version>3.9</version>
                <!-- Specify configuration, executions for liberty-maven-plugin -->
                ...
            </plugin>
        </plugins>
    </build>
    ...
</project>

If you are using a snapshot version of Liberty Maven Plugin then you will also need to add the following plugin repository to your pom.xml:

<project>
    ...
    <pluginRepositories>
        <!-- Configure Sonatype OSS Maven snapshots repository -->
        <pluginRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    ...
</project>
Liberty installation configuration

The Liberty Maven Plugin must first be configured with the Liberty server installation information. The installation information can be specified as:

Installing from a Maven artifact is the default installation method. The default runtime artifact is the latest version of io.openliberty:openliberty-kernel. In order to configure WebSphere Liberty for installation, specify the runtimeArtifact with the com.ibm.websphere.appserver.runtime groupId and the specific artifactId and version that is needed. For a full list of artifacts available, see the Liberty installation configuration documentation.

Example using the runtimeArtifact parameter to install a WebSphere Liberty runtime from a Maven artifact:

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

To install an Open Liberty beta runtime, specify the runtimeArtifact with the io.openliberty.beta groupId, open liberty-runtime artifactId and the version that is needed.

Example using the runtimeArtifact parameter to install an Open Liberty beta runtime from a Maven artifact:

<plugin>
    <groupId>io.openliberty.tools</groupId>
    <artifactId>liberty-maven-plugin</artifactId>
    <version>3.9</version>
    <configuration>
        <runtimeArtifact>
            <groupId>io.openliberty.beta</groupId>
            <artifactId>openliberty-runtime</artifactId>
            <version>23.0.0.10-beta</version>
            <type>zip</type>
        </runtimeArtifact>
    </configuration>
</plugin>

The Liberty Maven Plugin can also download and install a Liberty server from the Liberty repository or other location using the install parameter.

Goals

The Liberty Maven Plugin provides the following goals.

GoalDescription
cleanDeletes every file in the ${outputDirectory}/logs, ${outputDirectory}/workarea, ${userDirectory}/dropins or ${userDirectory}/apps.
compile-jspCompile JSPs in the src/main/webapp into the target/classes directory
createCreate a Liberty server.
debugStart a Liberty server in debug mode.
deployCopy applications to the Liberty server's dropins or apps directory. If the server instance is running, it will also verify the applications started successfully.
devStart a Liberty server in dev mode.*
devcStart a Liberty server in dev mode in a container.*
display-urlDisplay the application URL in the default browser.
dumpDump diagnostic information from the server into an archive.
generate-featuresScan the class files of an application and create a Liberty configuration file in the source configuration directory that contains the Liberty features the application requires.*
install-featureInstall a feature packaged as a Subsystem Archive (esa) to the Liberty runtime.
install-serverInstalls the Liberty runtime. This goal is implicitly invoked by all the other plugin goals and usually does not need to be executed explicitly.
java-dumpDump diagnostic information from the server JVM.
packagePackage a Liberty server.
prepare-featurePrepare a user feature for installation to the Liberty runtime.
runStart a Liberty server in the foreground. The run goal implicitly creates the server, installs features referenced by the server.xml file, and deploys the application before starting the Liberty server.
startStart a Liberty server in the background. The server instance will be automatically created if it does not exist.
statusCheck a Liberty server status.
stopStop a Liberty server. The server instance must exist and must be running.
test-startAllows you to bypass automatically starting the server during the pre-integration-test phase with pom configuration or a Liberty-specific command line argument.
test-stopAllows you to bypass automatically stopping the server during the post-integration-test phase with pom configuration or a Liberty-specific command line argument.
undeployUndeploy an application to a Liberty server. The server instance must exist and must be running.
uninstall-featureUninstall a feature from the Liberty runtime.

*The dev, devc, and generate-features goals have a runtime dependency on IBM WebSphere Application Server Migration Toolkit for Application Binaries, which is separately licensed under IBM License Agreement for Non-Warranted Programs. For more information, see the license. Note: The dev and devc goals have this dependency only when auto-generation of features is turned on. By default, auto-generation of features is turned off.

Common Parameters

Parameters shared by all goals. See common parameters.

Common Server Parameters

Additional parameters shared by all server-based goals. See common server parameters.

Extensions

Extensions improve the compatibility or user experience of third party libraries used with Liberty. The Liberty Maven Plugin provides the following extensions.

ExtensionDescription
configure-arquillian goalIntegrates arquillian.xml configuration for the Liberty Managed and Remote Arquillian containers in the Liberty Maven Plugin. Automatically configures required arquillian.xml parameters for the Liberty Managed container.
Spring Boot SupportThe Liberty Maven Plugin provides support for Spring Boot applications, allowing you to install Spring Boot executable JARs directly to the Liberty runtime.

Packaging types

liberty-assembly

The liberty-assembly Maven packaging type is used to create a packaged Liberty server Maven artifact out of existing server installation, compressed archive, or another server Maven artifact. Any applications specified as Maven compile dependencies will be automatically packaged with the assembled server. Liberty features can also be installed and packaged with the assembled server. Any application or test code included in the project is automatically compiled and tests run at appropriate unit or integration test phase. Application code is installed as a loose application WAR file if deployPackages is set to all or project and looseApplication is set to true.

The liberty-assembly default lifecycle includes:

PhaseGoal
pre-cleanliberty:stop
process-resourcesmaven-resources-plugin:resources
compilemaven-compiler-plugin:compile
process-test-resourcesmaven-resources-plugin:testResources
test-compilemaven-compiler-plugin:testCompile
testmaven-surefire-plugin:test
prepare-packageliberty:create, liberty:prepare-feature, liberty:install-feature
packageliberty:deploy, liberty:package
pre-integration-testliberty:test-start
integration-testmaven-failsafe-plugin:integration-test
post-integration-testliberty:test-stop
verifymaven-failsafe-plugin:verify
installmaven-install-plugin:install
deploymaven-deploy-plugin:deploy

Example:

<project>
    ...
    <groupId>myGroup</groupId>
    <artifactId>myServer</artifactId>
    <!-- Create Liberty server assembly -->
    <packaging>liberty-assembly</packaging>
    ...
    <dependencies>
        <!-- Package SimpleServlet.war with server assembly -->
        <dependency>
            <groupId>wasdev</groupId>
            <artifactId>SimpleServlet</artifactId>
            <version>1.0</version>
            <type>war</type>
        </dependency>
    </dependencies>
    ...
    <build>
        <plugins>
            <!-- Enable liberty-maven-plugin -->
            <plugin>
                <groupId>io.openliberty.tools</groupId>
                <artifactId>liberty-maven-plugin</artifactId>
                <version>3.9</version>
                <extensions>true</extensions>
                <configuration>
                    <installDirectory>/opt/ibm/wlp</installDirectory>
                    <serverName>test</serverName>
                    <features>
                        <acceptLicense>true</acceptLicense>
                        <feature>mongodb-2.0</feature>
                    </features>
                    <looseApplication>true</looseApplication>
                    <deployPackages>all</deployPackages>
                </configuration>
            </plugin>
        </plugins>
    </build>
    ...
</project>

Getting started

There are multiple starters available to generate a package to start developing your first application on Open Liberty.

If you want to use one of the previously published archetypes that we are no longer enhancing, refer to this documentation.