Maven war plugin not able to exclude libs in exploded war format

a 夏天 提交于 2019-12-13 14:27:01

问题


I am using maven war plugin to exclude some common jar and put them in the classpath. I am able to generate war file properly which excludes specified libs and add them in the classpath but exploded war directory still contains excluded libararies. How can I generate exploded war file which use configuration of maven war plugin.

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ekaplus.ctrm.mdm</groupId>
    <artifactId>core-presentation</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <name>presentation layer core</name>

    <dependencies>
        <dependency>
            <groupId>com.ekaplus.ctrm.mdm</groupId>
            <artifactId>eka-core-mdm-presentation</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>exploded</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <defaultGoal>package</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.1</version>
                        <configuration>
                            <packagingExcludes>
                                WEB-INF/lib/dto-common-1.0.jar,
                                WEB-INF/lib/eka-action-1.0.jar
                            </packagingExcludes>
                            <archive>
                                <manifest>
                                    <addClasspath>true</addClasspath>
                                </manifest>
                            </archive>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

回答1:


(...) How can I generate exploded war file which use configuration of maven war plugin.

The war:exploded goal does use the (global) configuration of the maven war plugin but it doesn't admit the packagingExcludes parameter of war:war. This can't work.

But why you are using packagingExcludes anyway? This parameter should be used to implement the very special skinny war use case, and I'm not sure it's your case. Why do you need it?

Depending on your exact needs, my suggestion would be to play with dependency scopes (provided in your case?) or profiles (to add dependencies) or a combination of both.



来源:https://stackoverflow.com/questions/4061627/maven-war-plugin-not-able-to-exclude-libs-in-exploded-war-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!