首页 文章

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

提问于
浏览
3

我一直在努力训练如何使用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被排除在外,但它们位于: $/src/main/webapp/WEB-INF/

不排除该排除列表中的其余目录和文件 . 这些位于爆炸战争中: $/$/WEB-INF/wro/

我不确定我可以做些什么来排除 $/$/WEB-INF/wro/ 的内容

无论我尝试什么,尽管排除,这些文件仍然是静止覆盖的 .

1 回答

  • 4

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

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

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

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

    从我上面的问题可以看出,我试图在 <overlay> 中使用 <exclude> 作为推荐但实际上并没有用于任何事情 . 最后 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>
    

相关问题