Maven依赖插件和Maven战争插件之间的资源提取冲突?

时间:2019-07-16 17:51:48

标签: maven dependencies war

我以前从依赖项中提取了一些资源,并将其提取到项目的结果WAR中(作为覆盖图)。但是,由于我添加了对依赖项插件的解压缩目标的调用,因此似乎只有ZIP存档中的资源才嵌入到该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>

我想要的是将ZIP资源添加到现有资源中。但我最终只获得ZIP资源,在这里。

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

有人知道某个问题或在这里看到我在做什么错吗? 非常感谢您的帮助或建议。

1 个答案:

答案 0 :(得分:0)

我终于发现叠加层可以处理不同的类型,所以答案是这样的:

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

不需要maven-dependency-plugin。