Installation as a Maven artifact

A Liberty server can be installed as a Maven artifact. You have two options for installing as a Maven artifact: using the Maven install plug-in and using the Liberty assembly packaging method.

Using Maven install plug-in

Usage:

You can use maven-install-plugin to install a compressed archive that contains Liberty server files as a Maven artifact. The compressed archive can be generated, for example, by the liberty:package-server goal.

Example: Using command line
mvn install:install-file
    -Dfile=/opt/ibm/wlp.zip \
    -DgroupId=myGroup \
    -DartifactId=myServer \
    -Dversion=1.0 \
    -Dpackaging=zip \
Example: Using pom.xml
This is the code snippet that you can use in the pom.xml file of your project.
...
<plugin>
    <!-- Install the Liberty server zip into the local Maven repository -->
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.2</version>
    <executions>
        <execution>
            <id>install-liberty-to-repo</id>
            <phase>process-resources</phase>
            <goals>
                <goal>install-file</goal>
            </goals>
            <configuration>
                <file>/opt/ibm/wlp.zip</file>
                <groupId>myGroup</groupId>
                <artifactId>myServer</artifactId>
                <version>1.0</version>
                <packaging>zip</packaging>
           </configuration>
       </execution>
</plugin>
...

Using Liberty assembly

Usage:

You can use the liberty-assembly packaging type to create a Liberty server Maven artifact from an existing server installation, a compressed archive, or another server Maven artifact. Any applications that are specified as Maven compile dependencies are automatically packaged with the assembled server in the dropins/ directory by default.

Example: Using liberty-assembly packaging type
This is the code snippet that you can use in the pom.xml file of your project.
<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>net.wasdev.wlp.maven.plugins</groupId>
                <artifactId>liberty-maven-plugin</artifactId> 
                <version>1.2.1</version>
                <extensions>true</extensions>
                <configuration>
                    <installDirectory>/opt/ibm/wlp</installDirectory>
                    <serverName>test</serverName>
                </configuration>         
            </plugin>
        </plugins>
    </build>        
    ...        
</project>

Icon that indicates the type of topic Reference topic

File name: rwlp_maven_artifact.html