aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.21k stars 854 forks source link

Namespace collision during maven shading between aws-core and sdk-core #2676

Closed mamtananavati closed 3 years ago

mamtananavati commented 3 years ago

Describe the issue

There is a duplicate class on classpath exception for software/amazon/awssdk/global/handlers/execution.interceptors between software.amazon.awssdk.aws-core and software.amazon.awssdk.sdk-core

It looks like this was added 10 days ago https://github.com/aws/aws-sdk-java-v2/blob/master/core/aws-core/src/main/resources/software/amazon/awssdk/global/handlers/execution.interceptors

Steps to Reproduce

Running org.basepom.maven:duplicate-finder-maven-plugin which project which consumes the above dependencies transitively causes the build to fail. The issues goes away when i roll back the version to 2.17.14

This collision shows up during maven shading.

Current Behavior

[WARNING] Found duplicate and different resources in [software.amazon.awssdk:aws-core:2.17.24, software.amazon.awssdk:sdk-core:2.17.24]: [WARNING] software/amazon/awssdk/global/handlers/execution.interceptors [WARNING] Found duplicate classes/resources in compile classpath. [WARNING] Found duplicate and different resources in [software.amazon.awssdk:aws-core:2.17.24, software.amazon.awssdk:sdk-core:2.17.24]: [WARNING] software/amazon/awssdk/global/handlers/execution.interceptors

Your Environment

debora-ito commented 3 years ago

Hi @mamtananavati thank you for reaching out.

Right now this is by design. We are careful in not creating execution.interceptors files within the same module, and in this case they are in two different modules aws-core and sdk-core, even though the files have the same namespace.

That said, we are aware of how this can lead to problems if you want to shade the SDK. Is this your case, are you shading the SDK? Or is this simply a report of the results of running the duplicate maven plugin?

Can you tell us more about your use case?

mamtananavati commented 3 years ago

The report above is from duplicate maven plugin but we are shading the jars as well and unfortunately, a class from one is referencing the other module , so there is no way for me to exclude one or the other dependency.

debora-ito commented 3 years ago

Thank you for following up, we've added this to our backlog.

If anyone else is affected by this, please upvote the original description.

fsvehla commented 3 years ago

This also affects building an Uberjar.

debora-ito commented 3 years ago

@mamtananavati @fsvehla

A fix was released via #2734, available in SDK version 2.17.46.

Please try it out and let us know if you still see the issue.

fsvehla commented 3 years ago

@debora-ito Überjar building (with sbt-assembly) is now fixed.