Open michaelhixson opened 1 year ago
Angus org.eclipse.angus:angus-mail:2.0.1 also depends on jakarta.mail:jakarta.mail-api .
Jakarta.Mail is the essential interface and should be what you program (compile) against, and Angus is one (of theoretically many) implementation(s) of jakarta.mail , and required at runtime.
So, transitively you always have the dependency on jakarta.mail ?
Angus org.eclipse.angus:angus-mail:2.0.1 also depends on jakarta.mail:jakarta.mail-api .
That's not a problem because it depends on jakarta.mail-api
. It doesn't bundle jakarta.mail-api
.
Meanwhile, jakarta.mail
bundles jakarta.mail-api
. By "bundle" I mean that its jar file contains copies of all the classes from jakarta.mail-api
.
Jakarta.Mail is the essential interface and should be what you program (compile) against, and Angus is one (of theoretically many) implementation(s) of jakarta.mail , and required at runtime.
jakarta.mail:jakarta.mail-api
is the interface. org.eclipse.angus:angus-mail
is the implementation. Those are what Greenmail should depend on, as the Angus release notes say. "Most people will only need the main Angus Mail implementation in the angus-mail.jar and jakarta.mail-api.jar files together with the Angus Activation on the module path or on the class path."
org.eclipse.angus:jakarta.mail
, which should not be used, is both of those jar files combined into a single jar file. Using it in combination with either of the others causes you to have multiple copies of those classes on your classpath.
I think GreenMail should add a dependency on
org.eclipse.angus:angus-mail
and remove its dependency onorg.eclipse.angus:jakarta.mail
.When I upgraded GreenMail from 2.0.0-alpha-3 to 2.0.1-alpha-1, I had to exclude the dependency on
org.eclipse.angus:jakarta.mail
in order to resolve duplicate class errors reported by the Maven Enforcer Plugin. Thatjakarta.mail
artifact bundles the classes from two other artifacts:org.eclipse.angus:angus-mail
andjakarta.mail:jakarta.mail-api
. If either of those other artifacts show up in your dependency tree, you'll have duplicate classes. In particular, GreenMail also depends onjakarta.mail-api
, so you will have duplicate classes if you depend on GreenMail 2.0.1-alpha-1.The release notes for Angus Mail confirm that my suggested approach is the "preferred" way:
whereas
jakarta.mail
can be used if you're trying to limit the number of dependencies for some reason. Personally, I feel like artifacts that bundle other artifacts don't play well with Maven-managed dependencies, and they're meant to be used on projects with more manual dependency management.