title: Gradle Include Source Files
body: <p>I have a project in which I have two different 'sub-projects', the main library and a compiler for a programming language in a directory structure like this:</p>
  
  <pre><code>- build.gradle
  - src
    - library
    - compiler
    - ...
  </code></pre>
  
  <p>My build.gradle looks like this:</p>
  
  <pre><code>sourceSets
  {
      library
      {
          java
          {
              srcDir 'src/library'
              srcDir 'src/asm'
          }
      }
      compiler
      {
          java
          {
              srcDir 'src/compiler'
          }
      }
      //...
  }
  
  // ...
  
  task buildLib(type: Jar, dependsOn: 'classes') {
      from sourceSets.library.output
      classifier = 'dyvil-library'
  }
  
  task buildCompiler(type: Jar, dependsOn: 'classes') {
      from sourceSets.compiler.output
      classifier = 'dyvil-compiler'
  }
  </code></pre>
  
  <p>My problem is that whenever I try to run the <code>buildCompiler</code> task, the build fails and the Java Compiler gives me hundreds of errors in places where the compiler source code references classes in the library. I already tried to make the compiler dependant on the library classes like this:</p>
  
  <pre><code>task buildCompiler(type: Jar, dependsOn: [ 'classes', 'libraryClasses' ]) {
      from sourceSets.compiler.output
      classifier = 'dyvil-compiler'
  }
  </code></pre>
  
  <p>But that did not help. I know that I could theoretically copy the <code>srcDirs</code> from <code>sourceSets.library</code> into <code>sourceSets.compiler</code> like this:</p>
  
  <pre><code>compiler
  {
      java
      {
          srcDir 'src/library'
          srcDir 'src/asm'
          srcDir 'src/compiler'
      }
  }
  </code></pre>
  
  <p>But that seems like a bad idea for obvious reasons.</p>
  
  <p>Is there another way to include the source files from the library when compiling the compiler (<em>duh</em>)?</p>