jakarta-eejakarta-mailmaven-enforcer-plugin

Duplicate class conflict when using jakarta.mail-api with angus implementation


My application uses the following dependencies:

<dependency>
    <groupId>jakarta.mail</groupId>
    <artifactId>jakarta.mail-api</artifactId>
    <version>2.1.2</version>
</dependency>
<dependency>
    <groupId>org.eclipse.angus</groupId>
    <artifactId>jakarta.mail</artifactId>
    <version>2.0.2</version>
</dependency>

and my build is configured to use the maven-enforcer-plugin to ban duplicate classes. Now, angus depends on jakarta.mail-api v2.1.2 so i would expect this to work. However when i try to compile the project i get a conflict in one class:

[ERROR] Rule 1: org.apache.maven.plugins.enforcer.BanDuplicateClasses failed with message:
Duplicate classes found:

  Found in:
    org.eclipse.angus:jakarta.mail:jar:2.0.2:compile
    jakarta.mail:jakarta.mail-api:jar:2.1.2:compile
  Duplicate classes:
    jakarta/mail/Session.class

The debug output shows me that all other class duplicates are ignored because the bytcodes are identical and there are also these:

[DEBUG] ignoring duplicates of class jakarta/mail/Session$1.class since the bytecode matches exactly 
[DEBUG] ignoring duplicates of class jakarta/mail/Session$2.class since the bytecode matches exactly 
[DEBUG] ignoring duplicates of class jakarta/mail/Session$3.class since the bytecode matches exactly 
[DEBUG] ignoring duplicates of class jakarta/mail/Session$4.class since the bytecode matches exactly 
[DEBUG] ignoring duplicates of class jakarta/mail/Session$5.class since the bytecode matches exactly
[DEBUG] ignoring duplicates of class jakarta/mail/Session$6.class since the bytecode matches exactly 
[DEBUG] ignoring duplicates of class jakarta/mail/Session$7.class since the bytecode matches exactly 
[DEBUG] ignoring duplicates of class jakarta/mail/Session$8.class since the bytecode matches exactly

just Session.class itself causes problems.

Anybody have an idea what's happening here?


Solution

  • If you compare two artifact you can see that DEFAULT_PROVIDER is different:

    enter image description here

    It seems that they are making that change here: https://github.com/eclipse-ee4j/angus-mail/blob/master/providers/jakarta.mail/pom.xml#L155

    That should be the reason in difference in byte codes.