packagingExcludes不在maven war插件中工作

时间:2016-04-15 10:12:34

标签: maven jar war maven-war-plugin

我在我的pom.xml中关注

...
   <groupId>my.org.name</groupId>
    <artifactId>webservices-webapp</artifactId>
    <packaging>war</packaging>
    <name>Webapp</name>
<dependencies>
...
</dependecies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <attachClasses>true</attachClasses>
                    <packagingExcludes>
                        WEB-INF/lib/avalon-*.jar,
                        WEB-INF/lib/geronimo-*.jar,
                        WEB-INF/lib/aopalliance-*.jar,
                        WEB-INF/lib/common-*.jar,
                        WEB-INF/lib/core-cryptor-*.jar,
                        WEB-INF/lib/logging-*.jar,
                        WEB-INF/lib/rm-security-*.jar,
                        WEB-INF/lib/security-context-shared-*.jar,
                        WEB-INF/lib/session-management-*.jar,
                        WEB-INF/lib/jax*.jar,
                        WEB-INF/lib/joda-time-*.jar,
                        WEB-INF/lib/opensaml-*.jar,WEB-INF/lib/spring-security-core-*.jar,
                        WEB-INF/lib/xmlsec-*.jar,WEB-INF/lib/xmltooling-*.jar,
                        WEB-INF/lib/stax-api-*.jar,
                        WEB-INF/lib/servlet-api-*.jar,WEB-INF/lib/axis-saaj-*.jar,WEB-INF/lib/axis-jaxrpc-*.jar,
                        %regex[WEB-INF/lib/spring-(?!web).*.jar]
                    </packagingExcludes>
                    <archive>
                        <manifestEntries>
                            <DisableIBMJAXWSEngine>true</DisableIBMJAXWSEngine>
                        </manifestEntries>
                    </archive>
                    <webResources>
                        <resource>
                            <directory>src/main/java</directory>
                            <targetPath>WEB-INF/classes</targetPath>
                            <includes>
                                <include>**/*.xml</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
        <finalName>${project.artifactId}</finalName>
    </build>

现在当我做mvn clean install时。 我在target / webapp / WEB-INF / lib中获取所有jar 实际上我不应该让那些与被排除在外的模式相匹配的罐子 avalon- .jar,geronimo - .jar,aopalliance- .jar,common - .jar等..

为什么这些被排除的jar进入WEB_INF / lib ??

1 个答案:

答案 0 :(得分:5)

packagingExcludes适用于战争档案。它对“爆炸式”战争没有影响。

参考:https://github.com/apache/maven-plugins/blob/maven-war-plugin-2.6/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java#L109

(无论packagingExcludes

,都会调用handleArtifacts(context)