title: Gradle dependencies: how to remove java classes from jar in repository?
body: <p>Grade: how to exclude some java classes from a jar in public repository?</p>
  
  <p>For example, a foo.jar in repository depends on bar1.jar, bar2.jar</p>
  
  <pre><code>foo.jar
       bar1.jar
       bar2.jar
  </code></pre>
  
  <p>remove "javax/**" from foo.jar, add it into runtimeOnly configuration</p>
  
  <pre><code>dependencies {
      runtimeOnly foo-changed.jar, bar1.jar, bar2.jar
  }
  </code></pre>
  
  <p>Tried</p>
  
  <pre><code>configurations {
       changeFoo
  }
  
  dependencies {
       changeFoo "group:foo:1.0"  // contains foo.jar, bar1.jar, bar2.jar
  }
  
  task changeFoo(type: Jar) {
      def jarFile = configurations.changeFoo.singleFile   // error: more than one file
  
      from zipTree(jarFile) {
          exclude 'javax/**'
      }
  
      destinationDir project.libsDir
      archiveName "foo-changed.jar"
  }
  </code></pre>
  
  <p>How to get the single file (foo.jar)?
  How to replace the foo.jar in the configurations.changeFoo with foo-changed.jar?</p>
  
  <pre><code>dependencies {
      runtimeOnly.extendsFrom changeFoo
  }
  </code></pre>