views:

30

answers:

1

Hi,

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>
+2  A: 

(...) 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.

Pascal Thivent
Thanks for your response! We want to create skinny wars only. Actually we have multiple wars(6 of them). They are packaged in an ear file. Size of war files is increased because of core libs and other dependent libs. I tried provided scope also. It is working fine but i need to add libs with dependenc scope as provided in the class path (META-INF of each war). What can be done to add them in classpath?