Question

I have 2 separate maven projects.

The first builds a lot of artifacts, and packages them up into an EAR. This is the standard product.

The second project is bespoke for a customer, and builds some additional JAR files. I need a mechanism to insert these 2 JAR files into the lib directory of the EAR built by the first project.

Is there a nice simple way of doing this, whereby I list the artifact of the first project in the second, so that it does not need to know how it was put together, it simply inserts the additional JARS.

Was it helpful?

Solution

You can include the contents of another ear file in your second ear file by specifying the first ear file als dependency, but using <type>pom</type> instead of ear:

if you specify an ear dependency, transitive dependencies are not resolved (ear is defined as a container type). If you use pom instead, all dependencies of your first ear are (transitive) dependencies to the second ear, and thus included.

OTHER TIPS

You need to add those supplemental jar files as dependencies to your project pom and furthermore you need to add them to your maven-ear-plugin configuration:

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.9</version>
        <configuration>
           [...]
           <modules>
             <jarModule>
               <groupId>artifactGroupId</groupId>
               <artifactId>artifactId</artifactId>
               <bundleDir>lib</bundleDir>
             </jarModule>
          </modules>
        </configuration>
      </plugin>
    </plugins>
  </build>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top