正如我所收集的,maven-war-plugin
永远不要覆盖覆盖目标中已经存在的文件。例如,如果我有一个war
A依赖于war
B,两者都包含位于 的一些资源src/main/resources/some.xml
,则结果A.war
将包含some.xml
来自A项目的资源。
我如何指示maven-war-plugin
从依赖项(B)中获取资源而不是原始资源(A)?
正如我所收集的,maven-war-plugin
永远不要覆盖覆盖目标中已经存在的文件。例如,如果我有一个war
A依赖于war
B,两者都包含位于 的一些资源src/main/resources/some.xml
,则结果A.war
将包含some.xml
来自A项目的资源。
我如何指示maven-war-plugin
从依赖项(B)中获取资源而不是原始资源(A)?
请参阅http://maven.apache.org/plugins/maven-war-plugin/overlays.html:
“例如,如果必须在 webapp 中设置覆盖my-webapp 的 index.jsp 文件,但可以通过常规方式控制其他文件,则为my-webapp定义两个覆盖配置”
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<overlays>
<overlay>
<id>my-webapp-index.jsp</id>
<groupId>com.example.projects</groupId>
<artifactId>my-webapp</artifactId>
<includes>
<include>index.jsp</include>
</includes>
</overlay>
<overlay>
<!-- empty groupId/artifactId represents the current build -->
</overlay>
...
</overlays>
</configuration>
猜猜这不是最终的决定,而是一个起点。
您可以使用 maven-resources 插件将文件复制到所需位置。在战争建立之前或之后。