Search code examples
mavendependencieswar

Resources extraction conflict between maven-dependency-plugin and maven-war-plugin?


I used to have some resources from dependencies extracted into the resulting WAR of my project (as an overlay). But since I added a call to the unpack goal of the dependencies plugin, it appears that only the resources from the ZIP archive are embedded into that WAR.

<groupId>com.xxx.custom.www.yyy</groupId>
<artifactId>www-yyy-war</artifactId>
<packaging>war</packaging>

<dependencies>
    <dependency>
        <groupId>com.xxx.custom.www.yyy</groupId>
        <artifactId>www-yyy-import</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.xxx.custom.www.yyy</groupId>
        <artifactId>www-yyy-export</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>com.xxx.www</groupId>
        <artifactId>www-server</artifactId>
        <version>${www.version}</version>
        <type>war</type>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <overlays>
                    <overlay />
                    <overlay>
                        <groupId>com.xxx.www</groupId>
                        <artifactId>www-server</artifactId>
                        <type>war</type>
                    </overlay>
                </overlays>
            </configuration>
        </plugin>
    </plugins>
</build>

What I want is to add the ZIP resources to the already existing resources. But I end up with only the ZIP resources, here.

<dependencies>
    <dependency>
        <groupId>com.xxx.custom.www.yyy</groupId>
        <artifactId>www-yyy-etat</artifactId>
        <version>${project.version}</version>
        <type>zip</type>
    </dependency>
    ...
</dependencies>
...
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.1.1</version>
    <executions>
        <execution>
            <id>unpack-dependencies</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>com.xxx.custom.www.yyy</groupId>
                        <artifactId>www-xxx-etat</artifactId>
                        <version>${project.version}</version>
                        <type>zip</type>
                        <outputDirectory>${project.build.directory}/war/work/com.xxx.www/www-server/WEB-INF/classes</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

Does anybody knows about an issue or sees what I'm doing wrong here? Thanks very much for any help or suggestion.


Solution

  • I finally found out that overlays can handle different types, so here is the answer:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <overlays>
                        <overlay />
                        <overlay>
                            <groupId>com.xxx.www</groupId>
                            <artifactId>www-server</artifactId>
                            <type>war</type>
                        </overlay>
                        <overlay>
                            <groupId>com.xxx.custom.www.yyy</groupId>
                            <artifactId>www-yyy-etat</artifactId>
                            <type>zip</type>
                            <outputDirectory>WEB-INF/classes</outputDirectory>
                        </overlay>
                    </overlays>
                </configuration>
            </plugin>
    

    There is no need for maven-dependency-plugin.