steveb
(x1000)
July 15, 2015, 8:16am
1
Continuing the discussion from Gradle still runs junit test when last test source file is removed :
Steps to reproduce 1. Create a failing junit test, in a project without any tests 2. run gradle test
remove the test (i.e. remove the java source file) 4. run gradle test
Since there are no java source files to compile, compileTestJava does nothing (although it really should remove the .class file) Since gradle will find the old .class file it will still run the test, even though the java source file is removed. It does not help if I add --rerun-tasks.
This leads to problems in continuous integration environments like Jenkins
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.