Gradle clean failed in project with code coverage

We are using coberatura as code coverage tool.
The coverage ist measured in each module and then the coverage of all modules is merged in the root project.
One report is created for all modules and the build fails if the overall test coverage is too bad.

So we added the Gradle plugin ‘net.saliman.cobertura’ to all projects.

We now start the appliation and stop it. When execute “gradlew clean” then the build fails with this message:


:clean FAILED                                                                    

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':clean'.
> Unable to delete file: C:\dev\ipi\trunk\apps\coverage-test\build\hsqldb\coveragetest\coveragetest.lck

The error looks very similar to the one reported in https://www.cuba-platform.com/discuss/t/clean-task-fails .

Is it possible that the build tries to clean the main build directory after we installed the gradle plugin ‘net.saliman.cobertura’?

How can we fix this problem.

I have attached a demo project to this topic.

Thanks for your help.

Yours,
Joerg

coverage-test.zip (238.4K)

Hello, Joerg!

To fix the issue you need to customize clean task a little bit Put this code at the end of build.gradle:


clean {
    delete = ['build/libs', 'build/tmp']
}

It seems that the Gradle plugin that you’ve added adds “java” Gradle plugin to the root project and this affects the “build” folder which contains SQLDB and tomcat folders (“libs” and “tmp” folders are added each time “assemble” task is executed).

Regards,

Gleb.

Hello Gleb,

thanks for your support. Your solution sovles our problem. That’s great!

Yours,
Joerg