我有一个Maven项目,其中包含一个war和几个ear项目。每个ear项目需要稍微不同的war/WEB-INF/web.xml。每个ear的pom.xml使用com.google.code.maven-replacer-plugin:replacer和org.codehaus.mojo:truezip-maven-plugin来替换web.xml中的标记,然后将新的web.xml放置在最终的-app.ear/web.war/WEB-INF中。这在构建和创建最终EAR工件时都很好用。
我遇到的问题是,当我运行(使用Netbeans,但这不应该有影响)时,用于部署的web.xml(/target/gfdeploy/first-app/web_war/WEB-INF/web.xml)是带有标记的版本。我尝试为部署添加执行阶段,但这并不起作用。
如何确保运行部署具有修改后的web.xml,以便我可以在开发期间测试我的应用程序?
以下是ear pom.xml的相关部分:
我遇到的问题是,当我运行(使用Netbeans,但这不应该有影响)时,用于部署的web.xml(/target/gfdeploy/first-app/web_war/WEB-INF/web.xml)是带有标记的版本。我尝试为部署添加执行阶段,但这并不起作用。
如何确保运行部署具有修改后的web.xml,以便我可以在开发期间测试我的应用程序?
以下是ear pom.xml的相关部分:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>package-replace</id>
<phase>package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
<execution>
<id>deploy-replace</id>
<phase>deploy</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${project.parent.basedir}/${web.xml}</file>
<outputFile>${project.build.directory}/${web.xml}</outputFile>
<replacements>
<replacement>
<token>@REALM_NAME@</token>
<value>${web.realm}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>package-replace-web-xml</id>
<goals>
<goal>copy</goal>
</goals>
<phase>package</phase>
<configuration>
<files>
<file>
<source>${project.build.directory}/${web.xml}</source>
<outputDirectory>${project.build.directory}/${project.build.finalName}/${web.zip}/WEB-INF</outputDirectory>
</file>
</files>
</configuration>
</execution>
<execution>
<id>package-replace-web</id>
<goals>
<goal>copy</goal>
</goals>
<phase>package</phase>
<configuration>
<files>
<file>
<source>${project.build.directory}/${project.build.finalName}/${web.zip}</source>
<outputDirectory>${project.build.directory}/${project.build.finalName}.ear</outputDirectory>
</file>
</files>
</configuration>
</execution>
<execution>
<id>deploy-replace-web-xml</id>
<goals>
<goal>copy</goal>
</goals>
<phase>deploy</phase>
<configuration>
<files>
<file>
<source>${project.build.directory}/${web.xml}</source>
<outputDirectory>${project.build.directory}/gfdeploy/${project.artifactId}/web-${project.version}_war/WEB-INF</outputDirectory>
</file>
</files>
</configuration>
</execution>
</executions>
</plugin>