Search code examples
mavenmaven-3maven-ear-plugin

Add additional dependencies to an exisiting EAR


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.


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.