爆炸战争的maven叠加:排除爆炸战争中的物品

时间:2014-01-15 14:48:19

标签: maven war

我一直在努力研究如何使用maven overlay插件从爆炸战争中排除物品。

我有以下内容:

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <executions>
        <execution>
            <id>build-directory-tree</id>
            <phase>process-resources</phase>
            <goals>
                <goal>exploded</goal>
            </goals>
            <configuration>
                <overlays>
                    <overlay>
                        <groupId>com.mycompany.Online</groupId>
                        <artifactId>MyCompanyOnline</artifactId>
                        <excludes>
                            <exclude>WEB-INF/web.xml,WEB-INF/applicationContext.xml,WEB-INF/wro/**,WEB-INF/wro/wro-mapping.properties</exclude>
                        </excludes>
                    </overlay>
                </overlays>
            </configuration>
        </execution>
    </executions>
</plugin>

web.xml和applicationContext.xml被排除在外,但它们位于: $ {basedir} / src / main / webapp / WEB-INF /

不排除该排除列表中的其余目录和文件。它们位于爆炸式战争中: $ {project.build.directory} / $ {project.build.finalName} / WEB-INF / wro /

我不确定我可以做些什么来排除 $ {project.build.directory} / $ {project.build.finalName} / WEB-INF / wro / <的内容/ p>

无论我尝试什么,尽管排除了这些文件,但这些文件仍然是悬浮的。

1 个答案:

答案 0 :(得分:4)

经过多年的挖掘并尝试不同的配置后,我终于找到了有效的方法。

在覆盖父项的子项上使用 mvn clean install -X 我确认正在复制文件,因为有一个&#34; +&#34;符号而不是&#34; - &#34;。实际上,由于排除块实际被排除在外,因此我排除了文件,因为子文件在同一位置具有相同名称的文件。

最后,我在 maven-war-plugin-2.2.jar 中查看 plugin.xml ,我找到了这个参数: dependentWarExcludes 根据xml是:

 <deprecated>Use <overlay><excludes>
 instead</deprecated>

从我上面的问题中可以看出,我尝试在<exclude>中使用<overlay>作为推荐,但实际上并不适用于任何事情。最后 dependentWarExcludes 在重构插件块后工作如下:

<plugin>
    <artifactId>maven-war-plugin</artifactId>

        <configuration>
            <overlays>
                <overlay>
                    <groupId>com.mycompany.Online</groupId>
                    <artifactId>MyCompanyOnline</artifactId>
                </overlay>
            </overlays>
            <dependentWarExcludes>WEB-INF/web.xml,WEB-INF/applicationContext.xml,WEB-INF/wro/</dependentWarExcludes>
        </configuration>

        <executions>
            <execution>
                <id>build-directory-tree</id>
                <phase>process-resources</phase>
                <goals>
                    <goal>exploded</goal>
                </goals>
            </execution>
        </executions>
</plugin>
相关问题