1

我想使用这样的叠加层仅复制“file.xml”而没有文件夹结构:

    <overlays>
     <overlay>
      <groupId>com.mygroup</groupId>
      <artifactId>my_comp</artifactId>
      <includes>
        <include>WEB-INF/folder1/folder2/file.xml</include>
      </includes>
      <targetPath>WEB-INF/otherFolder</targetPath>
      <type>war</type>
    </overlay>
   </overlays>

换句话说:从WEB-INF/folder1/folder2/复制file.xml并放置到WEB-INF/otherFolder

有任何想法吗?

4

2 回答 2

2

我没有找到如何通过覆盖解决问题。所以我不得不使用两个插件maven-dependency-pluginmaven-war-plugin

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                <id>copy</id>
                <phase>process-resources</phase>
                <goals>
                    <goal>unpack</goal>
                </goals>
                <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>com.mygroup</groupId>
                        <artifactId>my_comp</artifactId>
                        <type>war</type>
                        <overWrite>true</overWrite>
                        <outputDirectory>${project.build.directory}/tmp</outputDirectory>
                        <includes>WEB-INF/folder1/folder2/file.xml</includes>
                </artifactItem>
            </artifactItems>
            </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1-beta-1</version>
        <configuration>
        <webResources>
            <resource>
                  <directory>${project.build.directory}/tmp/WEB-INF/folder1/folder2</directory>
                  <targetPath>WEB-INF/otherFolder</targetPath>
            </resource>
        </webResources>
        </configuration>
    </plugin>

附加到流程资源阶段的第一个插件。当所有叠加层组合时,第二个在阶段包上调用。覆盖以先赢策略应用(因此,如果文件已被覆盖复制,它将不再被复制)如果我复制了我的 file.xml(通过插件),那么它不会被任何覆盖覆盖.

太复杂了!

于 2010-03-11T13:22:53.340 回答
0

据我所知,覆盖是不可能的,覆盖的内容“按原样”添加到 targetPath(默认为 webapp 的根结构)。

如果您想让file.xml在其他位置可用,则必须在覆盖之前my_comp调整其在WAR中的位置。

于 2010-03-10T18:49:04.713 回答