【问题标题】:maven overlay of exploded war: excluding items from exploded war爆炸战争的maven覆盖:不包括爆炸战争中的物品
【发布时间】:2014-02-04 02:31:15
【问题描述】:

我一直在努力研究如何使用 maven 覆盖插件从爆炸战争中排除项目。

我有以下几点:

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

无论我尝试什么,尽管排除了这些文件,这些文件仍然被覆盖。

【问题讨论】:

    标签: maven war


    【解决方案1】:

    在挖掘了很长时间并尝试了不同的配置后,我终于找到了可行的方法。

    在覆盖父级的子级上使用 mvn clean install -X 我确认文件正在被复制,因为有一个“+”符号而不是“-”。事实上,我虽然被排除的文件是因为实际排除的 exclude 块,因为孩子在同一位置有一个同名的文件。

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

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

    从我上面的问题中可以看出,我尝试按照建议在&lt;overlay&gt; 中使用&lt;exclude&gt;,但这实际上对任何事情都不起作用。最后 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>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多