title: How can Java build tools stop rebuilding everything?
body: <ul>
  <li><p><strong>tl;dr Version:</strong> Is there a way I can tell ant/maven/gradle to track file dependencies and only rebuild files which are outdated, i.e., older than their dependencies?</p></li>
  <li><p><strong>long version below:</strong></p></li>
  </ul>
  
  <h2>How I did it in C/C++</h2>
  
  <p>I used <code>make</code> for many years for C/C++. And while it might be cumbersome sometimes, it at least does one of the most important things for me: It tracks file dependencies and only rebuilds a file if any of its dependencies is newer than the file itself. This is great, it reduces build times considerably especially when a lot of code generation tools are executed.</p>
  
  <p>I use a lot of code generation in my projects. However, code generation takes some time and the generated code has to be compiled afterwards, so even more time wasted. Most of the generated code depends only on a small number of files, e.g., a grammar specification when generating a parser. With <code>make</code>, I simply set dependencies to the specification file and the parser is only rebuilt when the spec changes. In some of my projects generating the code takes 80-90% of the time a complete rebuild requires. Thus, not having to rebuild generated code speeds up my build process by almost a factor of 10.</p>
  
  <h2>Now to java</h2>
  
  <p>People don't use <code>make</code> for java, so even if I like make, I also the usual java build tools for my java projects. It seems that the build tools I tried (ant,gradle,maven) do not offer such dependency tracking. Instead, they rely on the called applications or tasks to do this (e.g., the <code>ant copy</code> task copies only files which are outdated). However, the code generation programs I use simply do not offer such checks. They always execute the full code generation no matter whether the input specifications are outdated or not.</p>
  
  <p>Consequently, my build times in java got longer and longer. They got so long that I took the code generation out of the usual build cycle into a separate target and only executed this target manually after changing any spec file. But of course, this is error prone since I sometimes forget it. My build process now feels totally flawed.</p>
  
  <h2>Finally, my questions</h2>
  
  <ol>
  <li><p>Is there a way to perform dependency tracking and rebuilding only outdated files in any of the build tools I mentioned (ant,gradle,maven) that I am not aware of?</p></li>
  <li><p>If not, then why? Why does the java community not seem to care about this feature? Especially when a lot of code generation is involved, such a feature is extremely important, especially if the code generation tools used do not offer that feature themselves.</p></li>
  <li><p>If not, then are there any other java build tools which do have such tracking?</p></li>
  </ol>