consul-client icon indicating copy to clipboard operation
consul-client copied to clipboard

shaded consul-client shouldn't include Guava transitive dependencies

Open pkwarren opened this issue 7 years ago • 3 comments

Since updating to a newer version of Guava, the shaded client has started shipping Guava transitive dependencies (without relocating them):

 +- com.google.guava:guava:jar:22.0:compile
 |  +- com.google.errorprone:error_prone_annotations:jar:2.0.18:compile
 |  +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
 |  \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile

Since guava is excluded from shading (https://github.com/OrbitzWorldwide/consul-client/blob/aa41cbd47d1653c2d6a2533cf93c58c89ba80375/pom.xml#L258), it would be helpful if these weren't shaded either to avoid class conflicts at runtime.

As part of analyzing this, I also found the jsr305 artifact is shaded (and not relocated). In order to resolve these, I propose the following fix:

diff --git a/pom.xml b/pom.xml
index 339b1ae..cc3d426 100644
--- a/pom.xml
+++ b/pom.xml
@@ -256,6 +256,11 @@
                                     <exclude>org.slf4j:slf4j-api</exclude>
                                     <exclude>org.immutables:values</exclude>
                                     <exclude>com.google.guava:guava</exclude>
+                                    <exclude>com.google.code.findbugs:jsr305</exclude>
+                                    <!-- Pulled in as transitive dependencies from Guava -->
+                                    <exclude>com.google.errorprone:error_prone_annotations</exclude>
+                                    <exclude>com.google.j2objc:j2objc-annotations</exclude>
+                                    <exclude>org.codehaus.mojo:animal-sniffer-annotations</exclude>
                                 </excludes>
                             </artifactSet>
                             <relocations>

pkwarren avatar Oct 26 '17 16:10 pkwarren

Guava is back in the shaded Jar (see 2995997b638aee9354537014941cfd5b704f0940), so I guess this issue is obsolete?

Do you agree @pkwarren?

adericbourg avatar Dec 04 '17 13:12 adericbourg

This is fixed, however I noticed that both jsr305 and animal-sniffer-annotations are both packaged in the shaded jar now (without relocation).

Screenshot

pkwarren avatar Dec 06 '17 14:12 pkwarren

Indeed. I tried to relocate javax.annotation from jsr305 only but I cannot find a way to do that with the Maven Shade plugin.

adericbourg avatar Dec 18 '17 17:12 adericbourg