Question

This is happening while packaging the EAR

My pom.xml is packaging the ear file where it should include projectA.jar file and projectB.war outside the /lib folder. Apparently, projectA.jar file is going inside the /lib folder which is not supposed to be. I have my application.xml which tells that these two projects should be outside the lib.

Question : how do i instruct maven not to bundle projectA.jar inside the /lib folder but to bundle it outside the /lib folder?.

My EAR structure should be:

MyWebEAR

\lib
\META-INF
projectA.jar
ProjectB.war

Below is my pom.

<dependencies>
    <dependency>
        <groupId>com.xxx.sms</groupId> 
        <artifactId>projectA</artifactId> 
        <version>1.0-SNAPSHOT</version>             
    </dependency>
    <dependency>
        <groupId>com.xxx</groupId>
        <artifactId>projectB</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>war</type>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <earSourceDirectory>${basedir}</earSourceDirectory>
                <earSourceIncludes>META-INF/*</earSourceIncludes>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
                <generateApplicationXml>false</generateApplicationXml>
                <applicationXML>${basedir}/META-INF/application.xml</applicationXML>
            </configuration>
        </plugin>
    </plugins>
    <finalName>MyWebEAR</finalName>
</build>

Thanks for your time.

Was it helpful?

Solution

You need to specifically define a jarModule configuration in the modules section of your maven-ear-plugin configuration for the projectA dependency and explicitly set where you want the jar placed.

So your POM would be:

<plugin>
    <artifactId>maven-ear-plugin</artifactId>
    <configuration>
        <defaultLibBundleDir>lib</defaultLibBundleDir>
        <earSourceDirectory>${basedir}</earSourceDirectory>
        <earSourceIncludes>META-INF/*</earSourceIncludes>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
            </manifest>
        </archive>
        <generateApplicationXml>false</generateApplicationXml>
        <applicationXML>${basedir}/META-INF/application.xml</applicationXML>
        <modules>
            <jarModule>
                <groupId>com.xxx.sms</groupId>
                <artifactId>projectA</artifactId>
                <bundleDir>/</bundleDir>
            </jarModule>
        </modules>
    </configuration>
</plugin>

The value (/) in the bundleDir tells the maven-ear-plugin to place projectA's jar in the root folder of the ear instead of the default location of lib.

You can see details on this in the plugins documentation here: http://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-module-location.html

OTHER TIPS

I had the same problem in my project.

In my case, I was using an MDB so it was needed to be declared as  <**ejbModule**> instead of jarModule. I also had to declare my dependency as of type ejb to be picked up Jboss (6.4):

<dependency>
    <groupId>ab.cd</groupId>
    <artifactId>mdb-publisher</artifactId>
    <version>xxx-SNAPSHOT</version>
   <type>**ejb**</type>
</dependency>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top