Skip to content

Migrate cross-project test source sharing to java-test-fixtures for Gradle 9.5 compatibility#11367

Open
bric3 wants to merge 3 commits into
masterfrom
bdu/removes-sourceset-output-cross-project-sharing
Open

Migrate cross-project test source sharing to java-test-fixtures for Gradle 9.5 compatibility#11367
bric3 wants to merge 3 commits into
masterfrom
bdu/removes-sourceset-output-cross-project-sharing

Conversation

@bric3
Copy link
Copy Markdown
Contributor

@bric3 bric3 commented May 13, 2026

What Does This Do

Replaces two patterns of cross-project test source access that break
under Gradle 9.5:

  1. profiling-controller-openjdk used:

    files(project(':...:profiling-controller-jfr').sourceSets.test.output)

    Since the goal was to share test resources to other projects, this fits the java-test-fixtures plugin, this PR has a commit that migrates the profiling-controller-jfr to 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 via File directly).

  2. Nine mongo driver/test consumers had a redundant: testImplementation project(':...:mongo-common').sourceSets.test.output alongside an already-correct testFixtures(project(':...:mongo-common')). Since project(':foo').sourceSets is broken in Gradle 9.5, a commit in this PR removes the duplicate dependency declarations.

Motivation

Prior Gradle 9.5, project(':foo') in a dependencies {} block resolved to the real Project object, which gave access to the sourceSets property via Groovy magic.

However, Gradle 9.5 added a DependencyHandler.project(String) returning a ProjectDependency. In Groovy DSL closures this shadows Project.project(String), which was previously resolved as a "fallback" (since DependencyHandler had no project(String) overload before 9.5).

The actual instance returned is now a DefaultProjectDependency instead, which has no sourceSets properties, making the build fails with:

> Could not get unknown property 'sourceSets' for project '...' of type DefaultProjectDependency

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels 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.

bric3 added 2 commits May 13, 2026 17:37
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.
@bric3 bric3 requested review from a team as code owners May 13, 2026 15:51
@bric3 bric3 added tag: no release notes Changes to exclude from release notes comp: tooling Build & Tooling labels May 13, 2026
@bric3 bric3 requested a review from sarahchen6 May 13, 2026 16:14
Copy link
Copy Markdown
Contributor

@sarahchen6 sarahchen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: tooling Build & Tooling tag: no release notes Changes to exclude from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants