title: Only run task if another isn't UP-TO-DATE in gradle
body: <p>I want to automatically add a serverRun task when doing functional tests in Gradle, so I add a dependency :</p>
  
  <pre><code>funcTestTask.dependsOn(serverRun)
  </code></pre>
  
  <p>Which results in the task running whether or not the funcTestTask even runs</p>
  
  <pre><code>:compile
  :serverRun
  :funcTestTask (and associate compile tasks... etc)
  :serverStop
  
  OR
  
  :compile UP-TO-DATE
  :serverRun &lt;-- unnecessary 
  :funcTestTask UP-TO-DATE
  :serverStop
  </code></pre>
  
  <p>The cost of starting the server is pretty high and I only want it to start if the functionalTest <strong>isn't</strong> UP-TO-DATE, I'd like to do or something :</p>
  
  <pre><code>if(!funcTestTask.isUpToDate) {
      funcTestTask.dependsOn(serverRun)
  }
  </code></pre>
  
  <p>So I know I can't know the up-to-date status of funcTestTask until all it's inputs/outputs are decided BUT can I inherit it's uptoDate checker?</p>
  
  <pre><code>serverRun.outputs.upToDateWhen(funcTestTask.upToDate)
  </code></pre>
  
  <p>The alternative is to "doFirst" the ServerRun in the FuncTest, which I believe is generally frowned upon?</p>
  
  <pre><code>funcTestTask.doFirst { serverRun.execute() }
  </code></pre>
  
  <p>Is there a way to conditionally run a task before another?</p>
  
  <p><strong>UPDATE 1</strong><br/>
  Tried settings inputs/outputs the same</p>
  
  <pre><code>serverRun.inputs.files(funcTestTask.inputs.files)
  serverRun.outputs.files(funcTestTask.outputs.files)
  </code></pre>
  
  <p>and this seems to rerun the server on recompiles (good), skips reruns after successful unchanged functional tests (also good), but wont rerun tests after a failed test like the following</p>
  
  <pre><code>:compile
  :serverRun
  :funcTestTask FAILED
  
  then
  
  :compile UP-TO-DATE
  :serverRun UP-TO-DATE &lt;-- wrong!
  :funcTestTask FAILED
  </code></pre>