title: Gradle multiple jars from single source folder
body: <p>As for now we have a project structure with single source folder named <code>src</code>, which contains  source code for three modules. What I want to do is:</p>
  
  <p>1) Compile source code. This is easily done with sourceSets definition:</p>
  
  <pre><code>sourceSets {
      main {
          java {
              srcDir 'src'
          }
      }
  }
  </code></pre>
  
  <p>2) Put compilation results into three jars. I am doing this via three 'jar' type tasks:</p>
  
  <p>I am doing this now via three separate tasks:</p>
  
  <ul>
  <li><p>util.jar</p>
  
  <pre><code>task utilJar(type: Jar) {
      from(sourceSets.main.output) {
          include "my/util/package/**"
      }
  }
  </code></pre></li>
  <li><p>client.jar</p>
  
  <pre><code>task clientJar(type: Jar) {
      from(sourceSets.main.output) {
          include "my/client/package/**"
      }
  }
  </code></pre></li>
  <li><p>server.jar</p>
  
  <pre><code>task serverJar(type: Jar) {
      from(sourceSets.main.output) {
          include "**"
      }
      excludes.addAll(utilJar.includes)
      excludes.addAll(clientJar.includes)
  }
  </code></pre></li>
  </ul>
  
  <p>The thing is that <code>server.jar</code> should contain all classes that are not contained within <code>client.jar</code> and <code>util.jar</code>. In ant build script we solve this problem by using <code>difference</code> ant task. How this can be done in gradle (my current approach doesn't work)?</p>
  
  <p>Maybe my approach is completely wrong. Please advice.</p>
  
  <p>P.S. as for now we CAN NOT change the project source code folder structure.</p>