title: Exclude Package From Gradle Dependency
body: <p>I'm experiencing an issue where multiple versions of the same class are showing up in my classpath.  The class in question is <code>javax.ws.rs.core.UriBuilder</code>.  The version I want to use is brought in by <code>javax.ws.rs:javax.ws.rs-api:2.0.1</code>. However, we also use the Jira rest client library which has a dependency on the older version of jersey (<code>com.sun.jersey:jersey-core</code>) which has included the java.ws packages bundled in it's jar.</p>
  
  <p>Here is an example snippet from the build file:</p>
  
  <pre><code>dependencies {
    compile 'com.atlassian.jira:jira-rest-java-client-core:2.0.0-m31'
    compile 'javax.ws.rs:javax.ws.rs-api:2.0.1'
    compile 'org.glassfish.jersey.core:jersey-client:2.17'
  }
  </code></pre>
  
  <p>I can't remove <code>com.sun.jersey:jersey-core</code> as it uses different package name from the new version and would cause class def not found exceptions in the Jira client.</p>
  
  <p>As far as I can tell, my options at this point are:</p>
  
  <ol>
  <li>Revert to using Jersey 1.x and it's implementation of jsr311</li>
  <li>Somehow have gradle exclude the <code>javax.ws</code> package from the old jersey client.</li>
  </ol>
  
  <p>I'd like to keep using the newer version of jersey so #2 would be my ideal solution but I'm not sure if it's even possible.  Does anyone know how to go about this?  If that's not possible, I'm open to other suggestions.</p>