Same dependency as ejb and jar - what happens?

Dependencies in Maven have a type element, which defaults to jar , but can be set to ejb , war , ear , etc. The ejb type is a special case because it does not lead to another file termination: ejb still has a final .jar .

I have an ear project where the same dependency is referenced once with the ejb type and once with the jar type (in the transitive dependency tree). Both records request the same file with different Maven "coordinates".

From the point of view of the forcecer plugin dependencyConvergence rule, both dependencies seem different - the dependency version of the <type>jar apparently not controlled by dependencyManagement. However, only one of the dependencies turns it into ear , namely in <type>ejb .

When Maven "lowers" the second addiction and what can I do to influence it?

Please note: I know that you should not have ejb as a jar in your dependency list, but if I kill responsible developers, I can go to jail.

+7
java maven dependency-management
source share
1 answer

I created two sample projects in Eclipse: one EAR, one EJB.

If the order in the EAR POM is:

 <dependency> ... <type>jar</type> <dependency> ... <type>ejb</type> 

ejb.jar only fits in .ear /lib .

If the order in the EAR POM is:

 <dependency> ... <type>ejb</type> <dependency> ... <type>jar</type> 

ejb.jar is placed in .ear root and /lib .

Apparently, one of the rare cases where the order of the announcement in the POM matters.

By the way, just to make it clear: your "the same dependency is referenced [...] with different Maven coordinates" contradicts. Maven coordinates : groupId , artifactId and version (GAV), not packaging and / or classifier , because the last two do not indicate "Where?" but what?". This is probably why you specified the "coordinates".

+1
source share

All Articles