-
Notifications
You must be signed in to change notification settings - Fork 40
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
Scoverage plugin is not usable in multi-project parallel builds with Gradle 6.7+ #150
Comments
We also encountered this issue in our project. When the scoverage plugin is disabled, everything works file. |
I'm running into the same issue. This keeps me from upgrading gradle to 6.7. Parallel and Scoverage don't play nice anymore :( |
Any thoughts @eyalroth ? I wonder if this means we just have to instrument the main source set, rather than creating a separate configuration. |
…README gradle/gradle#15730 and scoverage/gradle-scoverage#150 have details on why `-Dorg.gradle.parallel=false` is required.
Details: * https://github.com/jacoco/jacoco/releases/tag/v0.8.6 * https://github.com/jacoco/jacoco/releases/tag/v0.8.7 Ran `./gradlew clients:reportCoverage -PenableTestCoverage=true -Dorg.gradle.parallel=false` successfully with Java 15 (see gradle/gradle#15730 and scoverage/gradle-scoverage#150 for the reason why `-Dorg.gradle.parallel=false` is required). Also updated `README.md` to include `-Dorg.gradle.parallel=false` alongside `reportCoverage`. Reviewers: Chia-Ping Tsai <[email protected]>
Details: * https://github.com/jacoco/jacoco/releases/tag/v0.8.6 * https://github.com/jacoco/jacoco/releases/tag/v0.8.7 Ran `./gradlew clients:reportCoverage -PenableTestCoverage=true -Dorg.gradle.parallel=false` successfully with Java 15 (see gradle/gradle#15730 and scoverage/gradle-scoverage#150 for the reason why `-Dorg.gradle.parallel=false` is required). Also updated `README.md` to include `-Dorg.gradle.parallel=false` alongside `reportCoverage`. Reviewers: Chia-Ping Tsai <[email protected]>
Sorry for taking so long to reply. There are two reasons we discover task dependencies recursively (which causes this error in conjunction with
Trying to make them depend only on directly dependent projects instead of looking for 2+ depth dependencies will fail when in-between projects have no scoverage. We could make it so that this lookup will happen only if running without normal compilation is selected, and then only that mode will be incompatible with parallel execution, which is fine given that both have the same purpose of improving build times. However, this may require a change to how this feature is enabled, as I faintly remember that accessing the CLI arguments in the configuration stage is not so easy or perhaps discouraged.
This is something that I'm guessing would be hard to give up, unlike the option for running without normal compilation. I wonder whether there is a way to run the configuration in a single thread even in the parallel mode. Edit: A bit of a correction regarding 2) -- it seems that this is only relevant to running without normal compilation as well (it's been awhile since I worked with this code). In the default mode, the classpath of tests consists of the jars of their dependent projects, and these jars contain the output of the normal compilation, and so running the tests will not affect the coverage of their dependent projects. However, without normal compilation, the jars contain the scoverage instrumented classes (since the "normal" classes were never compiled), and so the tests do affect the coverage of their dependent projects. |
I wonder if it is possible to follow the suggestion in the Gradle repo ticket (gradle/gradle#15730) and use configurations to share instrumented code. Basically, as far as I understand it, the idea is to rely on variant-aware dependency selection, which looks like this (in pseudocode):
In this setup, resolving the Then, if the scoverage plugin sets up the test tasks to use this configuration as their classpath instead of the "default" one, I believe that it will kind of automatically result in compilation of only instrumented classes if the user only wants to run tests and compute coverage. If the user wants to publish their code, then because all of the publishing mechanism depends on the "regular" variants (specifically those provided by the |
@netvl The question is whether this will solve the problem of needing to discover tasks that are 2+ levels into the chain list, which is the only reason the plugin (in no-normal-compile mode) is incompatible with parallel builds. The reason this is important is so support cases where projects in the middle of the chain do not have the scoverage plugin applied to them:
If the plugin doesn't apply on the project in the middle, then Perhaps there is a way to make For instance, in the example above, |
I ran into this same issue. I am curious if anyone has found a workaround for the current implementation? |
Please check this Gradle issue: gradle/gradle#15730
In short, if
org.gradle.parallel=true
project property is set, using the Scoverage plugin in a multi-project build with compilation dependencies between projects will result in an exception:This project reproduces the error.
The cause of the error is apparently this portion of the plugin's logic:
gradle-scoverage/src/main/groovy/org/scoverage/ScoveragePlugin.groovy
Lines 159 to 161 in f92c942
which causes some internal invariants in Gradle to fail due to cross-project access.
The text was updated successfully, but these errors were encountered: