title: Gradle: assembling multiple source-sets into one jar
body: <p>I've asked a related question here <a href="https://stackoverflow.com/questions/27244262/jooq-class-generation-and-gradle">JOOQ class generation and gradle</a> </p>
  
  <p>In that question I'm trying to find the best way to do a multi-stage build including generating classes in a middle step. I've gone down the Option Two approach, and now find myself an impasse. </p>
  
  <p>I have the following build.gradle file</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'eclipse'
  
  sourceSets
  {
      bootstrap 
  
      generated {
          compileClasspath += bootstrap.output
      }
  
      main {
          compileClasspath += bootstrap.output
          compileClasspath += generated.output
      }
  }
  
  buildscript {
      repositories {
          mavenCentral()
      }
  
      dependencies {
          classpath 'org.jooq:jooq-codegen:3.5.0'
          classpath 'postgresql:postgresql:9.1-901.jdbc4'
          classpath project(":")
      }
  }
  
  dependencies
  {
      compile 'org.jooq:jooq:3.5.0'
      compile 'org.jooq:jooq-codegen:3.5.0'
      compile 'org.apache.poi:poi:3.10.1'
      compile 'com.google.guava:guava:18.0'
  
      generatedCompile 'org.jooq:jooq:3.5.0'
      generatedCompile 'org.jooq:jooq-codegen:3.5.0'
      generatedCompile 'org.apache.poi:poi:3.10.1'
      generatedCompile 'com.google.guava:guava:18.0'
  
      bootstrapCompile 'org.jooq:jooq:3.5.0'
      bootstrapCompile 'org.jooq:jooq-codegen:3.5.0'
      bootstrapCompile 'org.apache.poi:poi:3.10.1'
      bootstrapCompile 'com.google.guava:guava:18.0'
  }
  
  task generate &lt;&lt; {
      //Use JOOQ to generate classes, with the output going into the generated sourceSet
            .withDirectory(file("src/generated/java").getAbsolutePath())
  }
  
  generatedClasses
  {
      dependsOn bootstrapClasses
      dependsOn generate
  }
  
  jar
  {
      dependsOn generatedClasses
      dependsOn bootstrapClasses
  }
  </code></pre>
  
  <p>The structure is that </p>
  
  <ul>
  <li>the <strong>bootstrap</strong> source set holds some core java classes that are required for the code generation, plus an sql file that will be used to pouplate a database</li>
  <li>The <strong>generate</strong> task uses the classes and sql file in <strong>boostrap</strong> to generate classes</li>
  <li>The <strong>generated</strong> source set holds the outputs of the generation task, and </li>
  <li>The <strong>main</strong> source set holds what might be called the "normal" classes (i.e. the ones that make use of the database being described by the bootstrap and generated classes)</li>
  </ul>
  
  <p>I have a couple of problems, which I can't untangle:</p>
  
  <ol>
  <li>I seem to have to duplicate the dependencies for each source-set</li>
  <li>When the jar file gets built, it only contains the classes generated from the <strong>main</strong> source set</li>
  </ol>
  
  <p>I should note that the build as it stands above will successfully generate each of the source-sets. </p>
  
  <p>Any help would be greatly appreciated.</p>