Liberty: Installation as a Maven artifact

A Liberty server can be installed as a Maven artifact. There are 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 liberty-assembly packaging type to create 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 in the dropins/ directory.

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>com.ibm.websphere.wlp.maven.plugins</groupId>
                <artifactId>liberty-maven-plugin</artifactId> 
                <version>1.0</version>
                <extensions>true</extensions>
                <configuration>
                    <serverHome>/opt/ibm/wlp</serverHome>
                    <serverName>test</serverName>
                </configuration>         
            </plugin>
        </plugins>
    </build>        
    ...        
</project>

Icon that indicates the type of topic Reference topic



Timestamp icon Last updated: Monday, 5 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rwlp_maven_artifact
File name: rwlp_maven_artifact.html