title: Force JavaExec task up to date
body: <p>I have a custom Gradle task (extending <code>JavaExec</code>) that should use an incremental building to not be executed most of the time:</p>
  
  <pre><code>task printFoo(type: JavaExec) {
      inputs.dir ...
      outputs.upToDateWhen( { return true } );
  
      classpath = sourceSets.main.runtimeClasspath
      main = "mypackage.MyMain"
  }
  </code></pre>
  
  <p>At first glance, this works fine: When I run the task twice, it runs only once. If I edit some of the input files, it will re-run.</p>
  
  <p>The problem is: it will re-run every time I change <em>anything</em> in my source code. This makes sense because <code>JavaExec</code> has all my source files as input since a different program might do different things. But since it is a very large project most of the changes in the source code won't change anything in the outcome of this task. I thus do not want to re-run it if something changes in my code (maybe except for the main class, but it won't change anytime soon so this is optional).</p>
  
  <p>Is there a way to achieve this behavior? I tried removing files from <code>inputs</code>, but apparently they are initialized after my code. I also thought about putting this task into <code>buildSrc</code>, but this has ugly implications on the dependencies of <code>MyMain</code> to the rest of the project.</p>