title: Multiple source folders: Avoid implicit compilation with Ant
body: <p>Consider the following project layout (assuming A and B depend on each other):</p>
  
  <pre><code>.
  |-- bin1
  |-- bin2
  |-- src1
  |   `-- A.java
  `-- src2
      `-- B.java
  </code></pre>
  
  <p>After compilation, I want the classes to reside in their respective folders liike this:</p>
  
  <pre><code>.
  |-- bin1
  |   `-- A.class
  |-- bin2
  |   `-- B.class
  |-- src1
  |   `-- A.java
  `-- src2
      `-- B.java
  </code></pre>
  
  <p>This is quite simple from the command line:</p>
  
  <pre><code> $ javac -implicit:none -sourcepath src1:src2 -d bin1 src1/*
   $ javac -implicit:none -sourcepath src1:src2 -d bin2 src2/*
  </code></pre>
  
  <p>Eclipse also does it that way if so configured. But I cannot figure out how to do it with Ant.</p>
  
  <p><strong>Appendix:</strong> My current <code>javac</code> tasks:</p>
  
  <pre><code>    &lt;javac destdir="${classes.1.dir}"&gt;
          &lt;src path="${src.1.dir}" /&gt;
          &lt;src path="${src.2.dir}" /&gt;
      &lt;/javac&gt;
      &lt;javac destdir="${classes.2.dir}"&gt;
          &lt;classpath path="${classes.1.dir}" /&gt;
          &lt;src path="${src.2.dir}" /&gt;
      &lt;/javac&gt;
  </code></pre>
  
  <p>Note the circular dependency. The <em>second</em> task works well, it only compiles what’s in <code>src2</code> as it has a <code>classpath</code> dependency on the other build. The <em>first</em> task, however, cannot take a <code>classpath</code>, since nothing is yet compiled, and with <code>src</code> it of course compiles too much.</p>