首先定义如下参数:
<profile>
<id>front</id>
<properties>
<rp.build.warname>front</rp.build.warname>
</properties>
</profile>
<profile>
<id>pc</id>
<properties>
<rp.build.warname>pc</rp.build.warname>
</properties>
</profile>
其次配置打包插件
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<packagingExcludes>
WEB-INF/classes/dev/,
WEB-INF/classes/test/,
WEB-INF/classes/prd/,
WEB-INF/classes/uat/,
WEB-INF/classes/bak/
</packagingExcludes>
<failOnMissingWebXml>false</failOnMissingWebXml>
<overlays>
</overlays>
<warSourceExcludes>src/main/webapp/upload</warSourceExcludes>
<warName>me-${rp.build.warname}</warName>
<webResources>
<resource>
<directory>src/main/resources/${package.environment}</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
<resource>
<directory>src/main/java/groovy</directory>
<targetPath>WEB-INF/classes/groovy</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
附打包命令:mvn clean install -P test -Drp.build.warname=pc
打包结果根据参数不同,包名为me-pc.war或me-front.war
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)