The Liberty Maven plug-in provides a set of goals for managing and operating Liberty profile servers. It can also download and install the Liberty runtime from the Liberty repository or from another location. This makes it easy to use Liberty and Maven together in continuous integration or deployment scenarios.

In order to use the Liberty Maven plug-in, it needs to be configured with Liberty profile installation information. The plug-in can be configured with an installation directory of a Liberty profile instance, a packaged server archive (.zip file with Liberty binaries), or with a packaged server that has been published as a Maven artifact.

Installing the Liberty runtime from the Liberty Repository

To install Liberty from the Liberty repository you will need the version number and the associated Liberty license code. The license code can be found in the relevant license file on the line starting with D/N::

Next, configure the Liberty Maven plug-in in the following way:

      <licenseCode>license code</licenseCode>

Installing the Liberty runtime from a custom location

To install Liberty from some other location, for example, from a web server within your organization, you will need to configure the plug-in with a Liberty license code and the location of the Liberty runtime archive to download and install.

To find the Liberty license code, run the following command on the Liberty runtime archive:

java -jar wlp*runtime.jar –viewLicenseInfo

Look for the line starting with D/N: in the output.

Next, configure the Liberty Maven plug-in in the following way:

      <licenseCode>license code</licenseCode>
      <runtimeUrl>URL to Liberty runtime archive</runtimeUrl>

The Ferret sample application

The Ferret sample application is a simple web application that displays information about the HTTP requests, such as request parameters or HTTP headers sent. We extended the sample to use the Liberty Maven plug-in to download and install the Liberty runtime from the Liberty repository and to run the application.

Configuring the Liberty Maven plug-in

To set up the Liberty Maven plug-in for the Ferret sample we made the following changes:

  1. We created a server.xml configuration file for the application and placed it in the src/main/wlp directory. The server.xml enables the features required by the application and uses variables that can be used to pass environment-specific settings. Specifically, the server.xml uses the httpPort variable for specifying the port that the server listens to and the appLocation variable for specifying the location of the application to run.

    <server description="ferret server">
      <httpEndpoint id="defaultHttpEndpoint"
                    httpPort="${httpPort}" >
        <tcpOptions soReuseAddr="true"/>  
      <application name="ferret" context-root="/ferret"
                   location="${appLocation}" type="war" />
  2. We updated the pom.xml file to define the Liberty Maven plug-in the pluginManagement section.

  3. We added a pluginRepository entry to the pom.xml file. The repository contains the Liberty Maven plug-in.

      <name>Sonatype Nexus Snapshots</name>
  4. We added a wlp Maven profile to the pom.xml file. The profile only activates if the IBM_LIBERTY_LICENSE environment property is set. This provides an option to build the sample without downloading and setting up the Liberty profile server first. In the wlp profile, the Liberty Maven plug-in is configured to create a new Liberty server with the server.xml configuration file from the src/main/wlp directory. The plug-in is also configured to pass two bootstrap properties: httpPort and appLocation. The httpPort property is set to port 9080. The appLocation property is set to the target directory that Maven creates for the built application. That way we do not have to copy any files to the server directory in order to run the application.


Building and running the application

With the server.xml file created and the pom.xml file updated we can build the application and run it on Liberty profile:

  1. Set the IBM_LIBERTY_LICENSE environment variable with the correct license code to activate the wlp profile:

    $ export IBM_LIBERTY_LICENSE=license code
  2. Build the code as usual. With the IBM_LIBERTY_LICENSE environment variable set, the Liberty Maven plug-in will download and install the Liberty runtime and configure a server to run the application:

    $ mvn install
  3. Run the Liberty server with the application:

    $ mvn liberty:run-server

That’s it! Once the server is running, open http://localhost:9080/ferret in your web browser to see the application running.

Check out the Ferret sample repository on GitHub for the complete source code of this application. Also, see the Liberty Maven plug-in documentation for additional information about this feature. If you are using the Liberty Ant tasks, the wlp:install-liberty task provides equivalent functionality.

6 comments on"Installing Liberty with the Liberty Maven plug-in"

  1. Are there any plans to release 1.1? We’re not keen to use snapshots in our CI.

  2. XavierVerges May 14, 2015

    This does not work for plugin version 1.0, only for 1.1-SNAPSHOT, right? I am getting `CWWKM2103E: No server assembly specified: specify either Maven coordinates in assemblyArtifact or a file in assemblyArchive` when running `mvn liberty:create-server` using plugin 1.0

  3. Hi,

    thanks for the great work!

    Ist this plugin a fork of the “official” liberty-maven-plugin? (

    • We took the and open-sourced it on GitHub. So, the net.wasdev.wlp.maven.plugin:liberty-maven-plugin is now the official Maven plugin for Liberty. The is still available but it’s not being updated anymore. All the updates & enhancements are done in the open-sourced version.

Join The Discussion

Your email address will not be published. Required fields are marked *