Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jacocoMergedReport task fails on Gradle 8 when invoked after test task #384

Closed
yastanotheruser opened this issue Aug 9, 2023 · 1 comment
Labels

Comments

@yastanotheruser
Copy link

Description

The jacocoMergedReport task fails to run on Gradle 8 due to a deprecated behaviour that is considered an error in this version. On Gradle 7 the same sequence of tasks shows the deprecation warning:

$ ./gradlew --version

------------------------------------------------------------
Gradle 7.6.2
------------------------------------------------------------
...
$ ./gradlew --warn clean build jacocoMergedReport
...
Execution optimizations have been disabled for task ':jacocoMergedReport' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/home/xxx/ca-project'. Reason: Task ':jacocoMergedReport' uses this output of task ':test' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.6.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
...

Reproduce

$ mkdir ca-project
$ cd ca-project
$ gradle init --dsl groovy  --package com.example --type java-application --project-name ca-project  --test-framework junit-jupiter
$ ./gradlew wrapper --gradle-version 8.2.1
$ echo "plugins {
    id \"co.com.bancolombia.cleanArchitecture\" version \"3.6.0\"
}" > build.gradle
$ ./gradlew ca --coverage JACOCO --example TRUE --javaVersion VERSION_17 --lombok TRUE --metrics FALSE --name ca-project --package com.example --type IMPERATIVE
$ ./gradlew --warn clean build jacocoMergedReport
...
FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':jacocoMergedReport' (type 'JacocoReport').
  - Gradle detected a problem with the following location: '/home/xxx/ca-project'.
    
    Reason: Task ':jacocoMergedReport' uses this output of task ':test' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
    
    Possible solutions:
      1. Declare task ':test' as an input of ':jacocoMergedReport'.
      2. Declare an explicit dependency on ':test' from ':jacocoMergedReport' using Task#dependsOn.
      3. Declare an explicit dependency on ':test' from ':jacocoMergedReport' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.2.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
...

Additional info

It seems the merged report execution data creates a dependency on the file ca-project/build/jacoco/test.exec, which is an output of the test task but is never created. It's included because the wildcard ** matches the project root directory.

executionData.setFrom project.fileTree(dir: '.', include: '**/build/jacoco/test.exec')

@github-actions
Copy link

github-actions bot commented Oct 2, 2023

🎉 This issue has been resolved in version 3.6.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant