views:

33

answers:

2

I would like copy just "file.xml" without folder structure using overlays like this:

    <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>

In other words: copy file.xml from WEB-INF/folder1/folder2/ and place to the WEB-INF/otherFolder

Any ideas?

A: 

To my knowledge, this is not possible with overlays, the content of the overlay is added "as is" to the targetPath (that defaults to the root structure of the webapp).

If you want to make file.xml available at another location, you'll have to tweak its location in my_comp WAR before the overlay.

Pascal Thivent
A: 

I didn't find how to resolve the issue via overlays. So I had to use two plugins maven-dependency-plugin and maven-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>

The first plugin attached to the process-resources phase. The second invoked on phase package when all overlays combined. Overlays are applied with a first-win strategy (hence if a file has been copied by an overlay, it won't be copied anymore) If I've copy my file.xml (via plugin) then it not be overwritten by any overlay.

It's so complicated!

eugenn