读书人

用Maven profile兑现不同的打包策略

发布时间: 2012-08-11 20:50:31 作者: rapoo

用Maven profile实现不同的打包策略

需求是:

1.在本地开发的时候,war包部署在本地glassfish上的时候contextroot是dev-geoflow

2.在持续集成的时候,war包部署在服务器上的glassfish的时候,contextroot是geoflow

3.默认情况下,使用2


首先配置一个用于本地开发的profile

      <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>2.1.1</version><configuration>  <webResources>...    <resource>      <directory>${webXmlPath}</directory>      <targetPath>WEB-INF</targetPath>    </resource>  </webResources></configuration>      </plugin>

好了。当运行mvn package的时候,将webxml/release目录下的xml文件打包到WEB-INF内。这是默认情况。持续集成服务器使用。

当运行mvn package -P dev 的时候,将webxml/develop目录下的xml文件打包的WEB-INF内,这是本地开发使用。




读书人网 >软件开发

热点推荐