Cannot clean related project because of Gradle daemon and JUnit Include/Exclude Categories

issue-acknowledged
gradle-3315

(rc) #1

When using the Gradle daemon and the excludeCategories or includeCategories JUnitOptions, dependent jars are locked by the daemon process and you cannot delete them.

I have provided an example project at https://github.com/redcape/gradle-example/tree/junit-error
Please make sure you’re looking at the junit-error branch if you download this project. Note that there is no code in the ‘projectdep’ dependency project, yet its jar still gets locked. Additionally, tests are not even running. It is important that Gradle tries to run a test though meaning that there is source code in the directory or else the condition will not occur.

Run: ./gradlew.bat --daemon clean build
The project will successfully clean and build.
Run it again and it will fail with:

$ ./gradlew.bat --daemon clean check
:projecta:clean
:projectdep:clean FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':projectdep:clean'.
> Unable to delete file: T:\code\show-errors\gradle-example\projectdep\build\libs\projectdep.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Running ./gradlew.bat --stop followed by ./gradlew.bat clean build or ./gradlew.bat --daemon clean build will run fine.

If the daemon is not running, no clean errors will occur.

Commenting out either the project dependency line or the JUnit excludeCategories line and restarting the daemon(if it’s already holding a reference) will make the problem go away.

I tested this against Gradle 2.4 on IBM Java 6 (32-bit) and Oracle Java 8(64-bit) on Windows 7 32-bit and 64-bit respectively. They both have the same result.

I also tested this on the gradle master branch built from source on Oracle Java 8 and had the same issue.


(Mark Vieira) #2

Thanks for the report. I’ve raised this as GRADLE-3315.


(Nagasathi Babu Sathireddi) #3

Hello Mark,

I am running into the same issue with Gradle (2.12). Please find below my environment details.
Operating System: Windows 8.1 Enterprise.
Java: 1.7.0_79

I see that ‘https://issues.gradle.org/browse/GRADLE-3315’ is not resolved yet.
Could you let us know, which version of Gradle, this issue will be addressed?

I tried clearing off JUnit Options’ include categories and setting it to null after my test run. It did not work.
Please let us also know, if there is an workaround for this issue.

Thank you.


(Eric Wendelin) #4

We are planning to address GRADLE-3315 2 releases from now. Not 2.14, but the next one after that.

May we let you know directly once a fix is available so that you can help us verify it?


(Nagasathi Babu Sathireddi) #5

Eric,

Thank you for replying and making a fix to GRADLE-3315.
Sure, Please let me know directly, I will be glade to verify it.

Regards,
Babu