title: Appending Dependencies from Another Configuration
body: <p>My project is a Java project following standard convention (src/main, src/test ..). I'm trying to write a simple Gradle task the will emit two jar files:</p>
  
  <ul>
  <li><p>The "default" jar emitted by Gradle containing my app code</p></li>
  <li><p>A jar containing just test classes and dependencies needed to run them (e.g. Junit). This jar should not contain dependencies that are only needed by the non-test code (e.g. Guava in example below).</p></li>
  </ul>
  
  <p>I tried to use "testCompile" in my testJar task below, but that also picks up non-test Jars. So I created a separate configuration listing just the test dependencies, but now as I would expect tests can't be compiled since the 'testCompile' configuration is not correctly populated.</p>
  
  <p>I haven't seen a way in the DependencyHandler API (which with my limited knowledge of Gradle is what defines the DSL in the dependencies block) to assign one configuration to another. <strong><em>How I can add testJars dependency set to testCompile set (not replace) so everything "works"?</em></strong> I've placed a comment in my code below where I assume the missing gap is but I might be wrong!</p>
  
  <pre><code>apply plugin: 'java'
  
  sourceCompatibility = 1.7
  targetCompatibility = 1.7
  
  repositories {
      mavenCentral()
  }
  
  configurations {
      testJars
  }
  
  dependencies {
      compile group: 'com.google.guava', name: 'guava', version: '14.0.1'
      testJars group: 'junit', name: 'junit', version: '4.+'
      //"testCompile append testJars"??
  }
  
  task testJar(type: Jar) {
      classifier = 'tests'
      from sourceSets.test.output
      from { configurations.testJars.collect { it.isDirectory() ? it : zipTree(it) } }
  }
  </code></pre>