Dependencies in Maven have a type
element which defaults to jar
, but can be set to ejb
, war
, ear
, etc. The type ejb
is a special case because it does not lead to a different file ending: The ejb
has still the ending .jar
.
I have an ear project where the same dependency is referenced once with type ejb
and once with type jar
(in the transitive dependency tree). Both entries ask for the very same file, with different Maven "coordinates".
From the perspective of the dependencyConvergence
rule of the enforcer plugin, both dependencies seem to be different - the version of the <type>jar
dependency is seemingly not managed by dependencyManagement. Nevertheless, only one of the dependencies makes it into the ear
- namely the <type>ejb
one.
When does Maven "drop" the second dependency and what can I do to influence this?
Please note: I know that you shouldn't have ejb
s as jar
s on your dependency list, but if I kill the responsible developers, I might go to prison.
I created two sample projects in Eclipse: one EAR, one EJB.
If the order in the EAR's POM is:
<dependency>
...
<type>jar</type>
<dependency>
...
<type>ejb</type>
the ejb.jar
is put to .ear
's /lib
only.
If the order in the EAR's POM is:
<dependency>
...
<type>ejb</type>
<dependency>
...
<type>jar</type>
the ejb.jar
is put to .ear
's root and /lib
.
Apparently one of the rare cases where order of declaration in the POM matters.
BTW, just to make it clear: Your "the same dependency is referenced [...] with different Maven 'coordinates'" is contradicting. Maven coordinates are groupId
, artifactId
and version
(GAV), not packaging
and/or classifier
, because the latter two don't specify the "Where?" but the "What?". It's probably that why you quoted "coordinates".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With