[ https://issues.apache.org/jira/browse/JCLOUDS-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15856941#comment-15856941 ]
Ignasi Barrera commented on JCLOUDS-1225: ----------------------------------------- Hi [~ian.springer]. I'm sorry you are having trouble with this. In fact it is really simple, and if you copied the example I provided from the Jenkins project, you should have it working. I'm going to paste it here, with minor amendments so you can easily directly copy and paste this without having to tweak it. This si a pretty common configuration of the maven shade plugin. *Pom to create the jclouds shaded jar* This shaded jar will contain: * The Guava version used by jclouds, with all its classes relocated to another package * All jclouds classes with all references to Guaca updated to use the relocated package. This will let jclouds use the version of Guava it needs, and you will be able to configure Guava 21 in your project without package collisions. *NOTE* That there is no need to relocate the jclouds classes; just Guava to avoid collisions between the version in your project and the version in the shaded jar. This why you can reference the jclouds classes as usual, using their standard package. {code:xml} <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.evergage.infrastructure</groupId> <artifactId>jclouds-shaded</artifactId> <version>2.0.0</version> <name>jclouds shaded dependencies</name> <dependencies> <!-- Replace these dependencies with the jclouds dependencies used in your project --> <dependency> <groupId>org.apache.jclouds</groupId> <artifactId>jclouds-all</artifactId> <version>2.0.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-shade-plugin</artifactId> <version>2.2</version> <executions> <execution> <id>shade</id> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> <configuration> <artifactSet> <!-- The shaded jar will have all jclouds dependencies and Guava --> <includes> <include>org.apache.jclouds*:*</include> <include>com.google.guava:*</include> </includes> </artifactSet> <relocations> <!-- Rename the Guava packages. This will rename the packages and update all references to Guava in the jclouds classes in the shaded jar, so the shaded jclouds will only use the relocated package, leaving the standard package free to be used normally in the app. You can use Guava 21 in your app then. --> <relocation> <pattern>com.google.common</pattern> <shadedPattern>shaded.com.google.common</shadedPattern> </relocation> </relocations> <transformers> <!-- Make sure all ServiceLoader defined services in each jclouds jar are joined in a single file in the shaded jar --> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> </transformers> <promoteTransitiveDependencies>true</promoteTransitiveDependencies> </configuration> </plugin> </plugins> </build> </project> {code} *Pom file to use in your project to include jclouds* Instead of including each jclouds dependency (all them should be now configured in the pom.xml above), just depend on the jclouds shaded jar. {code:xml} <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.evergage.infrastructure</groupId> <artifactId>project</artifactId> <version>2.0.0</version> <name>Infra Project</name> <dependencies> <dependency> <groupId>com.evergage.infrastructure</groupId> <artifactId>jclouds-shaded</artifactId> <version>2.0.0</version> </dependency> </dependencies> </project> {code} With this setup, you can have a look at the dependency tree for your just created project: {code} nacx@maqui:/tmp/foo $ mvn dependency:tree [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Infra Project 2.0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ project --- [INFO] com.evergage.infrastructure:project:jar:2.0.0 [INFO] \- com.evergage.infrastructure:jclouds-shaded:jar:2.0.0:compile [INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:compile [INFO] +- com.google.inject.extensions:guice-assistedinject:jar:3.0:compile [INFO] +- com.google.inject:guice:jar:3.0:compile [INFO] +- aopalliance:aopalliance:jar:1.0:compile [INFO] +- javax.inject:javax.inject:jar:1:compile [INFO] +- javax.annotation:jsr250-api:jar:1.0:compile [INFO] +- com.google.code.gson:gson:jar:2.5:compile [INFO] +- com.google.inject.extensions:guice-multibindings:jar:3.0:compile [INFO] +- org.yaml:snakeyaml:jar:1.17:compile [INFO] +- org.bouncycastle:bcprov-ext-jdk15on:jar:1.51:compile [INFO] +- org.slf4j:slf4j-api:jar:1.7.2:compile [INFO] +- com.hierynomus:sshj:jar:0.12.0:compile [INFO] +- org.bouncycastle:bcpkix-jdk15on:jar:1.51:compile [INFO] +- com.jcraft:jzlib:jar:1.1.3:compile [INFO] +- com.jcraft:jsch.agentproxy.sshj:jar:0.0.9:compile [INFO] +- com.jcraft:jsch.agentproxy.core:jar:0.0.9:compile [INFO] +- com.jcraft:jsch.agentproxy.connector-factory:jar:0.0.9:compile [INFO] +- com.jcraft:jsch.agentproxy.usocket-jna:jar:0.0.9:compile [INFO] +- net.java.dev.jna:jna:jar:4.1.0:compile [INFO] +- net.java.dev.jna:jna-platform:jar:4.1.0:compile [INFO] +- com.jcraft:jsch.agentproxy.usocket-nc:jar:0.0.9:compile [INFO] +- com.jcraft:jsch.agentproxy.sshagent:jar:0.0.9:compile [INFO] +- com.jcraft:jsch.agentproxy.pageant:jar:0.0.9:compile [INFO] +- com.squareup.okhttp:okhttp:jar:2.2.0:compile [INFO] +- com.squareup.okio:okio:jar:1.2.0:compile [INFO] +- com.jamesmurty.utils:java-xmlbuilder:jar:1.1:compile [INFO] \- net.iharder:base64:jar:2.3.8:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.837 s [INFO] Finished at: 2017-02-07T23:35:04+01:00 [INFO] Final Memory: 13M/491M [INFO] ------------------------------------------------------------------------ {code} As you can see, it depends just on the jclouds shaded, and it has all the jclouds transitive dependencies *except Guava*, which is the dependency that conflicted with your project, so you're free to add the Guava version of your choice now. Could you try this configuration? > Guava 21 compatibility > ---------------------- > > Key: JCLOUDS-1225 > URL: https://issues.apache.org/jira/browse/JCLOUDS-1225 > Project: jclouds > Issue Type: Improvement > Components: jclouds-core > Affects Versions: 2.0.0 > Reporter: Ian Springer > Labels: guava > > The below classes use com.google.common.base.Objects.ToStringHelper, which > has been deprecated since Guava 18, and has been removed in Guava 21. This > makes it impossible to use jclouds in a project using Guava 21. Please either > upgrade to Guava 18+ and switch to using > com.google.common.base.MoreObjects.ToStringHelper, or drop the usage of > ToStringHelper altogether. This will allow my project to upgrade to Guava 21 > without having to use a fork of jclouds. > * org/jclouds/apis/internal/BaseApiMetadata.java > * org/jclouds/domain/internal/LocationImpl.java > * org/jclouds/domain/internal/MutableResourceMetadataImpl.java > * org/jclouds/domain/internal/ResourceMetadataImpl.java > * org/jclouds/http/HttpMessage.java > * org/jclouds/http/HttpRequest.java > * org/jclouds/http/HttpResponse.java > * org/jclouds/internal/BaseView.java > * org/jclouds/providers/internal/BaseProviderMetadata.java > * org/jclouds/reflect/InvocationSuccess.java > * org/jclouds/rest/internal/BaseHttpApiMetadata.java > * org/jclouds/rest/suppliers/URIFromStringSupplier.java -- This message was sent by Atlassian JIRA (v6.3.15#6346)