通過配置maven的pom文件來實現(xiàn)為一個項目同時生成多個jar/war包。
這里使用一下兩個配置插件:
maven-jar-plugin和maven-war-plugin,分別是用于打包jar文件和war文件。
現(xiàn)在以下圖中包名的工程為例(com以上的路徑未顯示),要打出主機程序jar文件和備機程序jar文件,主機程序jar文件包含除了backup目錄下的所有文件,備機程序jar文件包含所有文件:
pom中添加配置為(<build><plugins>節(jié)點下添加):
<pre>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>backup</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<classifier>backup</classifier>
<includes>
<include(此處有一個'>') /</include>
</includes>
</configuration>
</execution>
<execution>
<id>host</id>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
<configuration>
<classifier>host</classifier>
<excludes>
<exclude>com/wzl/demo/backup/</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</pre>