title: Gradle Tasks depends on a file which should not exist yet
body: <p>I want to have a Gradle Tasks that executes my freshly build Java application. Also it should output the log/sout to a file called <strong>servicedispatcher.out</strong>. The problem that occurs is that Gradle, even tho I let this task depend on <strong>copyDistributionsToDestination</strong> (which would've created the missing filepath the error complains about) it still evaluates the Tasks code before the task dependency. This way I have no chance to define this path as the log output path. What can I do to get around this?</p>
  
  <p><em>Given the following code:</em></p>
  
  <pre><code>task startDispatcher(type:Exec){
      workingDir = "servicedispatcher/bin/"
      commandLine "cmd", "/c", "servicedispatcher.bat"
      File logFile = file("${workingDir}/log/toolbox-components-servicedispatcher.out")
      if(logFile.exists() == false){
          logFile.createNewFile() // Line 75 of error message
      }
      standardOutput = new FileOutputStream("${workingDir}/log/servicedispatcher.out")
  }
  
  task startToolbox(){
      group "Toolbox"
      dependsOn copyDistributionsToDestination
      dependsOn startDispatcher
  }
  
  startDispatcher.mustRunAfter("copyDistributionsToDestination")
  </code></pre>
  
  <p>Error Message:</p>
  
  <pre><code>FAILURE: Build failed with an exception.
  
  * Where:
  Build file 'C:\Development\Testzone\toolbox-backend\build.gradle' line: 75
  
  * What went wrong:
  A problem occurred evaluating root project 'toolbox-backend'.
  &gt; Das System kann den angegebenen Pfad nicht finden
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  
  BUILD FAILED
  
  Total time: 3.32 secs
  Das System kann den angegebenen Pfad nicht finden
  19:19:48: External task execution finished ':startToolbox'.
  </code></pre>