首先定义如下参数:
<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>
打包结果根据参数不同,包名为me-pc.war或me-front.war