Compiled files should be removed when source set gets empty (up-to-date status is wrong)

Continuing the discussion from Gradle still runs junit test when last test source file is removed:

Problem is still present with gradle 2.4: This bug also affects the main sources: If the last source file in src/main gets deleted the compileJava task is up-to-date. But inside the generated jar the deleted class file is still present, so the artifacts are completely out of sync.

This means we still have to use our workaround

[compileJava,compileTestJava].each { task ->
  task.doFirst {
     delete task.destinationDir

if I get the documentation right, the doFirst/doLast will switch off parallel execution for this task…

This is GRADLE-2579. We’ve added this to the list of open issues to be assigned to an upcoming release.