title: Use multiple Guava versions in same maven project
body: <p>I have the following two dependencies in my project:</p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;com.google.javascript&lt;/groupId&gt;
    &lt;artifactId&gt;closure-compiler&lt;/artifactId&gt;
    &lt;version&gt;v20141215&lt;/version&gt;
    &lt;exclusions&gt;
        &lt;exclusion&gt;
            &lt;groupId&gt;com.google.protobuf&lt;/groupId&gt;
            &lt;artifactId&gt;protobuf-java&lt;/artifactId&gt;
        &lt;/exclusion&gt;
    &lt;/exclusions&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
    &lt;groupId&gt;org.apache.hadoop&lt;/groupId&gt;
    &lt;artifactId&gt;hadoop-common&lt;/artifactId&gt;
    &lt;version&gt;2.4.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>As you can see in the dependency tree, they both contain a different version of Guava:</p>
  
  <pre><code>[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ extraction ---
  
  [INFO] +- com.google.javascript:closure-compiler:jar:v20141215:compile
  [INFO] |  +- com.google.javascript:closure-compiler-externs:jar:v20141215:compile
  [INFO] |  +- args4j:args4j:jar:2.0.26:compile
  [INFO] |  +- com.google.guava:guava:jar:18.0:compile
  [INFO] |  +- com.google.code.gson:gson:jar:2.2.4:compile
  [INFO] |  \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
  [INFO] +- org.apache.hadoop:hadoop-common:jar:2.4.0:compile
  [INFO] |  +- org.apache.hadoop:hadoop-annotations:jar:2.4.0:compile
  [INFO] |  |  \- jdk.tools:jdk.tools:jar:1.7:system
  [INFO] |  +- (com.google.guava:guava:jar:11.0.2:compile - omitted for conflict with 18.0)
  [INFO] |  +- ...
  </code></pre>
  
  <p>The well known problem is that Guava is not backward compatible. Therefore I kind of need both jars.</p>
  
  <p>The error - I get - is the following:</p>
  
  <pre><code>Error:  tried to access method com.google.common.base.Stopwatch.&lt;init&gt;()V from class org.apache.hadoop.mapreduce.lib.input.FileInputFormat
  </code></pre>
  
  <p>This has already reported here: <a href="https://issues.apache.org/jira/browse/HADOOP-10961">https://issues.apache.org/jira/browse/HADOOP-10961</a></p>
  
  <p>Moreover they suggest to handle it by using the shading Maven plugin:
  <a href="https://groups.google.com/a/cloudera.org/forum/#!topic/cdh-user/d5_HqUSvVl4">https://groups.google.com/a/cloudera.org/forum/#!topic/cdh-user/d5_HqUSvVl4</a></p>
  
  <p>Which I tried here:</p>
  
  <pre><code>&lt;build&gt;
  &lt;plugins&gt;
     &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;version&gt;3.1&lt;/version&gt;
          &lt;configuration&gt;
              &lt;source&gt;1.6&lt;/source&gt; &lt;!-- If you want to use Java 8, change this to "1.8" --&gt;
              &lt;target&gt;1.6&lt;/target&gt; &lt;!-- If you want to use Java 8, change this to "1.8" --&gt;
          &lt;/configuration&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-shade-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.3&lt;/version&gt;
          &lt;executions&gt;
              &lt;execution&gt;
                  &lt;phase&gt;package&lt;/phase&gt;
                  &lt;goals&gt;
                      &lt;goal&gt;shade&lt;/goal&gt;
                  &lt;/goals&gt;
                  &lt;configuration&gt;
                      &lt;relocations&gt;
                          &lt;relocation&gt;
                              &lt;pattern&gt;com.google&lt;/pattern&gt;
                              &lt;shadedPattern&gt;project.shaded.com.google&lt;/shadedPattern&gt;
                          &lt;/relocation&gt;
                      &lt;/relocations&gt;
                  &lt;/configuration&gt;
              &lt;/execution&gt;
          &lt;/executions&gt;
      &lt;/plugin&gt;
  &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>But I still get the same error.</p>
  
  <p>Can anyone help me with this Maven issue?</p>
  
  <p>Thank you,
  Felix</p>