title: Gradle removes directory defined as task output (stale directories)
body: <p>I have an <code>unzipData</code> gradle task defined as following:</p>
  
  <pre><code>task unzipFile(type: Copy) {
    dependsOn mkdirTrash
    dependsOn downloadFile
  
    from zipTree(file("$trashDir/file.zip"))
    into trashDir
  }
  </code></pre>
  
  <p>The task unzips archive content right into the directory with archive itself (at the <code>trash</code> directory, which is a root of all task's artifacts and which could be deleted only when all preparation tasks are finished).</p>
  
  <p>Things used to work until I updated gradle wrapper to version 4.2.1.</p>
  
  <p>Task execution started to produce the error:</p>
  
  <pre><code>FAILURE: Build failed with an exception.
  
  * What went wrong:
  Cannot expand ZIP 'trash/file.zip' as it does not exist.
  </code></pre>
  
  <p>In debug output I see that gradle deletes the whole <code>trash</code> directory</p>
  
  <pre><code>&gt; Task :unzipFile
  11:56:23.145 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Task :unzipFile' started
  11:56:23.145 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':unzipFile'
  11:56:23.145 [INFO] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Putting task artifact state for task ':unzipFile' into context took 0.0 secs.
  11:56:23.204 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Clean stale outputs' started
  11:56:23.204 [INFO] [org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter] Deleting stale output file: /.../trash
  </code></pre>
  
  <p>As far as I can see it's gradle's new feature 
  <a href="https://docs.gradle.org/4.2-rc-1/release-notes.html#safer-handling-of-stale-output-files" rel="nofollow noreferrer">https://docs.gradle.org/4.2-rc-1/release-notes.html#safer-handling-of-stale-output-files</a></p>
  
  <p>The docs says that only <strong>directories registered as targets for the clean task</strong> and <strong>source set outputs</strong> are stale. I suppose, the <code>Copy</code> task is one of <code>source set</code> and it's output is bound to be deleted.</p>
  
  <p>I wonder what are advantages of this feature?
  Is there any possibility to forbid cleanup of particular directories? 
  Any not dirty workarounds?</p>