多模块项目中的 Maven War 插件执行和过滤
我正在使用 Maven 构建一个多模块项目。
在一个项目中,我执行 maven-war-plugin 四次,以便在每次执行中过滤一些属性。作为一个独立的项目,它运行良好。
但是当我构建多模块时,它从“父模块”执行四次,但它们都没有过滤属性。
谢谢大家!
这是我的 pom.xml 的片段:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>net.my</groupId>
<artifactId>my-project</artifactId>
<packaging>war</packaging>
<name>myProject</name>
<version>0.0.1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>list</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<warName>myProj-list.war</warName>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</webResources>
<filtering>true</filtering>
<filters>
<filter>src/main/filters/list.properties</filter>
</filters>
</configuration>
</execution>
...
<!-- more executions -->
</execution>
</executions>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</webResources>
<filters>
<filter>src/main/filters/locator.properties</filter>
</filters>
</configuration>
</plugin>
</plugins>
</build>
I'm using maven to build a multimodule project.
In one project I execute maven-war-plugin four times in order to filter some properties in every execution. As a stand alone project it works well.
But when I build the multimodule, from the "parent" it executes four times, but none of them filter the properties.
Thank you all!
Heres a fragment of my pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>net.my</groupId>
<artifactId>my-project</artifactId>
<packaging>war</packaging>
<name>myProject</name>
<version>0.0.1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>list</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
<warName>myProj-list.war</warName>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</webResources>
<filtering>true</filtering>
<filters>
<filter>src/main/filters/list.properties</filter>
</filters>
</configuration>
</execution>
...
<!-- more executions -->
</execution>
</executions>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</webResources>
<filters>
<filter>src/main/filters/locator.properties</filter>
</filters>
</configuration>
</plugin>
</plugins>
</build>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来像是一个复杂的设置...无论如何,您确定
src/main/webapp
的内容不会覆盖过滤的内容吗?使用-X
运行 Maven 可能有助于调试正在发生的情况。我的建议是停止滥用滥用
webResources
元素(应该用于外部Web资源)并移动需要的内容在src/main/webapp
之外进行过滤。Sounds like a complicated setup... Anyway, are you sure the content of
src/main/webapp
does not override the filtered content? Running maven with-X
might help to debug what is happening.My suggestion would be to stop abusing abusing the
webResources
element (that should be used for External Web Resources) and to move the content that needs to be filtered outsidesrc/main/webapp
.