【发布时间】:2015-08-28 09:57:12
【问题描述】:
我的项目结构如下:
+Parent
|
+---dist
|
+---module1 (war)
|
+---module2 (jar)
我希望 dist 模块将来自 module1 的 war 与一个 Tomcat 实例打包并将其全部压缩,以便我可以通过在服务器上解压缩来部署它。
我知道创建可运行战争的插件和从 jar 开始的嵌入式 tomcat,但我希望整个 Tomcat 在一个 zip 中,我的战争在 webapps 目录中。
我可以使用程序集插件手动完成,但货物插件似乎应该做我想要的。
我的 dist pom 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>my-parent</artifactId>
<groupId>com.my.package</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>dist</artifactId>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>my-war</artifactId>
<version>${project.parent.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.15</version>
<configuration>
<container>
<!--containerId must be equal to one of the containers supported by Cargo -->
<!--https://codehaus-cargo.github.io/cargo/Container.html-->
<containerId>tomcat8x</containerId>
<artifactInstaller>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>8.0.24</version>
</artifactInstaller>
</container>
<configuration>
<type>standalone</type>
<home>${basedir}/target/cargo/installs/tomcat-8.0.24</home>
</configuration>
<deployables>
<deployable>
<groupId>${project.parent.groupId}</groupId>
<artifactId>my-war</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
<executions>
<execution>
<id>package</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
首先,当我使用工件安装程序时,我必须指定主目录,这似乎很奇怪。
二、输出结构如下:
+---dist
| \---target
| +---cargo
| | \---installs
| | \---tomcat-8.0.24
| | \---apache-tomcat-8.0.24
| | +---bin
| | +---conf
| | ..........
| | ..........
| |
| \---package
| +---apache-tomcat-8.0.24
| | +---bin
| | +---conf
| | ..........
| | ..........
| +---bin
| +---lib
| \---temp
注意 tomcat 目录是包的子目录,但是包目录中已经有 tomcat 目录的存根。
第三,也是最重要的一点,我的战争不在 dist/target 目录中的任何地方!
【问题讨论】:
标签: maven tomcat maven-cargo