Search code examples
javamaven-2jboss7.xmaven-ear-plugin

How to tell maven to copy a certain project jar to the EAR lib?


I have an application with many sub projects, currently I use maven2 to compile and package it to an EAR which is then deployed on JBOSS 4.2.3.

Up until now all the jars where just sitting in the EAR root but now we moved to JBOSS 7.1 and in order for one jar to be recognized by other jars (I need to Commons project to be available for all other projects) it must sit under EAR/lib (this is JBOSS 7.1 requirement).

My question is, how can I tell Maven to copy a specific jar to the EAR/lib?

/* UPDATE **/

here is what i use to build the EAR:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
                <outputDirectory>../../outputs/java</outputDirectory>
                <version>5</version>
                <modules>
                    <jarModule>
                        <groupId>com.example.common</groupId>
                        <artifactId>common</artifactId>
                        <includeInApplicationXml>
                            true
                        </includeInApplicationXml>
                    </jarModule>
                    .....
                </modules>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>ear</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <sourceDirectory>EarContent</sourceDirectory>
    <resources>
        <resource>
            <directory>EarContent\META-INF</directory>
            <targetPath>../Manager-1.0/META-INF</targetPath>
            <excludes>
                <exclude>application.xml</exclude>
            </excludes>
        </resource>
    </resources>
</build>

Solution

  • The bundleDir attribute of the EAR plugin looks like the solution for your issue: http://maven.apache.org/plugins/maven-ear-plugin/examples/customizing-module-location.html

    The examples in the Maven documentation allow you to define the location per module or as a default for all modules.