作为 Maven 工件进行安装

可以将 Liberty 服务器作为 Maven 工件进行安装。作为 Maven 工件进行安装时有两个选项可供选择:使用 Maven 安装插件和使用 Liberty 组合件打包方法。

使用 Maven 安装插件

用法:

可以使用 maven-install-plugin 将其中包含 Liberty 服务器文件的压缩归档作为 Maven 工件来安装。例如,可以通过 liberty:package-server 目标来生成压缩归档。

示例:使用命令行
mvn install:install-file
    -Dfile=/opt/ibm/wlp.zip \
    -DgroupId=myGroup \
    -DartifactId=myServer \
    -Dversion=1.0 \
    -Dpackaging=zip \
示例:使用 pom.xml
这是可以用在项目的 pom.xml 文件中的代码段。
...
<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>
...

使用 Liberty 组合件

用法:

可以使用 liberty-assembly 打包类型根据现有服务器安装、压缩归档或者另一个服务器 Maven 工件来创建 Liberty 服务器 Maven 工件。缺省情况下,指定为 Maven compile 依赖项的任何应用程序与已组装的服务器一起,自动打包在 dropins/ 目录中。

示例:使用 Liberty 组合件打包类型
这是可以用在项目的 pom.xml 文件中的代码段。
<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>

用于指示主题类型的图标 参考主题

文件名:rwlp_maven_artifact.html