Migrate cross-project test source sharing to java-test-fixtures for Gradle 9.5 compatibility#11367
Open
bric3 wants to merge 3 commits into
Open
Migrate cross-project test source sharing to java-test-fixtures for Gradle 9.5 compatibility#11367bric3 wants to merge 3 commits into
bric3 wants to merge 3 commits into
Conversation
profiling-controller-openjdk used
files(project(':...:profiling-controller-jfr').sourceSets.test.output)
In Gradle 8 this worked: inside the `dependencies` closure,
`project(':foo')` resolved via `Project.project(String)` -- which is a
Groovy DSL lookup fallback, since `DependencyHandler` had no
`project(String)` method -- returning the real `Project` -- which has
the `sourceSets` property.
Gradle 9.5 added `DependencyHandler.project(String)` that returns a
`ProjectDependency`, which Groovy now resolves first. The instance is a
`DefaultProjectDependency`, which has no `sourceSets` property, and
as such fails with:
```
> Could not get unknown property 'sourceSets' for project ':dd-java-agent:agent-profiling:profiling-controller-jfr' of type org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency.
```
This commit instead rely on the java-test-fixtures plugin applied
to profiling-controller-jfr to share test resources, consumer projects
now declare : testFixtures(project(':...:profiling-controller-jfr')).
Gradle 9.5 added `DependencyHandler.project(String)` returning a
`ProjectDependency`, shadowing `Project.project(String)` in
`dependencies` closures. Since `ProjectDependency` implementation do
not has a `sourceSets` property it fails the build.
The goal of using `files(project(':foo').sourceSets.test.output)` is to
share test code in other projects which is supported by the test
java-test-fixtures plugin that is already applied to the `:mongo-common`
project. Also the nine mongo driver/test consumers already declared the
correct `testFixtures(project(':...:mongo-common'))` so this commit
drops the now-broken duplicate `sourceSets.test.output` dependency
declarations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Does This Do
Replaces two patterns of cross-project test source access that break
under Gradle 9.5:
profiling-controller-openjdkused:Since the goal was to share test resources to other projects, this fits the
java-test-fixturesplugin, this PR has a commit that migrates theprofiling-controller-jfrto this plugin, as well as its consumer projects.Note : JFP resource paths are now provided by
JfpTestResources, which extracts classpath resources to temp files as (test-fixture JARs are not accessible viaFiledirectly).Nine mongo driver/test consumers had a redundant:
testImplementation project(':...:mongo-common').sourceSets.test.outputalongside an already-correcttestFixtures(project(':...:mongo-common')). Sinceproject(':foo').sourceSetsis broken in Gradle 9.5, a commit in this PR removes the duplicate dependency declarations.Motivation
Prior Gradle 9.5,
project(':foo')in adependencies {}block resolved to the realProjectobject, which gave access to thesourceSetsproperty via Groovy magic.However, Gradle 9.5 added a
DependencyHandler.project(String)returning aProjectDependency. In Groovy DSL closures this shadowsProject.project(String), which was previously resolved as a "fallback" (sinceDependencyHandlerhad noproject(String)overload before 9.5).The actual instance returned is now a
DefaultProjectDependencyinstead, which has nosourceSetsproperties, making the build fails with:Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels the queue request./merge -f --reason "reason"skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.