2

正如我所收集的,maven-war-plugin永远不要覆盖覆盖目标中已经存在的文件。例如,如果我有一个war A依赖于war B,两者都包含位于 的一些资源src/main/resources/some.xml,则结果A.war将包含some.xml来自A项目的资源。

我如何指示maven-war-plugin从依赖项(B)中获取资源而不是原始资源(A)?

4

2 回答 2

1

请参阅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>

猜猜这不是最终的决定,而是一个起点。

于 2013-01-19T09:13:40.043 回答
0

您可以使用 maven-resources 插件将文件复制到所需位置。在战争建立之前或之后。

于 2011-10-19T20:26:19.153 回答