title: Generate CLASSPATH from all multiproject gradle build dependencies
body: <p>We're using an external testing tool (Squish) which runs after our main gradle build. This requires visibility of classes under test. Currently the CLASSPATH environment variable is built from various bash scripts and other string manipulation. I'm aiming to get gradle to do this automagically.</p>
  
  <p>Since the build is done on a very slow source control system (clearcase) it is preferable for the tests to be run against the class files/JARs as left by the build rather than extra copies / compression into a single JAR etc.</p>
  
  <p>The classpath needs to contain</p>
  
  <ul>
  <li>Generated JAR files, typically in build/libs/project-x.jar</li>
  <li>Test classes typically build/classes/test</li>
  <li>Test resources typically build/resources/test</li>
  <li>Any 3rd party jars any of the child projects depend upon, log4j, spring etc.</li>
  </ul>
  
  <p>It's a complex multiproject build, but I've simplified to following example with parent and two children.</p>
  
  <p>Parent settings.gradle</p>
  
  <pre><code>include ':child1'
  include ':child2'
  </code></pre>
  
  <p>Parent build.gradle</p>
  
  <pre><code>allprojects {
    apply plugin: 'java'
    repositories {
      mavenCentral()
    }
  }
  </code></pre>
  
  <p>Child 1 build.gradle</p>
  
  <pre><code>dependencies {
     compile 'org.springframework:spring-context:4.1.2.RELEASE'
     compile 'org.springframework:spring-beans:4.1.2.RELEASE'
  }
  </code></pre>
  
  <p>Child 2 build.gradle</p>
  
  <pre><code>dependencies {
     project (":child1")
  }
  </code></pre>
  
  <p>What I've got so far. Is this the right approach? Can it be simplified or completely rewritten in a better way?</p>
  
  <pre><code>task createSquishClasspath &lt;&lt; {
    def paths = new LinkedHashSet()
    paths.addAll(subprojects.configurations.compile.resolvedConfiguration.resolvedArtifacts.file.flatten())
    paths.addAll(subprojects.jar.outputs.files.asPath)
    paths.addAll(subprojects.sourceSets.test.output.resourcesDir)
    paths.addAll(subprojects.sourceSets.test.output.classesDir)
  
    paths.each {
      println "${it}"
    }
  
    println paths.join(File.pathSeparator)
  
  }
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>C:\so-question\Parent\local-repo\spring\spring-context-4.1.2.RELEASE.jar
  C:\so-question\Parent\local-repo\spring\spring-beans-4.1.2.RELEASE.jar
  C:\so-question\Parent\child1\build\libs\child1.jar
  C:\so-question\Parent\child2\build\libs\child2.jar
  C:\so-question\Parent\child1\build\resources\test
  C:\so-question\Parent\child2\build\resources\test
  C:\so-question\Parent\child1\build\classes\test
  C:\so-question\Parent\child2\build\classes\test
  </code></pre>