Maven War插件无法排除爆炸War格式的库 [英] Maven war plugin not able to exclude libs in exploded war format

查看:126
本文介绍了Maven War插件无法排除爆炸War格式的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Maven War插件排除一些常见的jar,并将它们放在类路径中.我能够正确生成war文件,该文件排除指定的库并将其添加到类路径中,但展开的war目录仍然包含排除的库.如何生成使用Maven War插件配置的爆炸War文件.

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>

推荐答案

(...)如何生成使用Maven War插件配置的爆炸War文件.

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

war:exploded 目标确实使用了(全球)配置的Maven War插件,但它不允许

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.

但是为什么要使用 packagingExcludes 反正?应该使用该参数来实现非常特殊的瘦身战争用例,但我不确定这是您的情况.你为什么需要它?

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?

根据您的确切需求,我的建议是使用依赖范围(在您的情况下为provided?)或配置文件(添加依赖项)或两者结合使用.

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.

这篇关于Maven War插件无法排除爆炸War格式的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆