Skip to content

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

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits into
masterfrom
bdu/removes-sourceset-output-cross-project-sharing
May 15, 2026
Merged

Migrate cross-project test source sharing to java-test-fixtures for Gradle 9.5 compatibility#11367
gh-worker-dd-mergequeue-cf854d[bot] merged 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

Follow-up to #10402, #11272

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!

import java.nio.file.StandardCopyOption;
import java.util.concurrent.atomic.AtomicReference;

public final class JfpTestResources {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Not sure if this a good name if this class is a bunch of static method...
Any reason code moved here, just curious.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure, what you mean. jfp are resources that are consumed by other tests that's also why it's in the testFixtures folder.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To me resources are some shared data usually.
But here I can see bunch of static methods, that usually means utils.
Does it make sense now?

Copy link
Copy Markdown
Contributor Author

@bric3 bric3 May 15, 2026

Choose a reason for hiding this comment

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

Ah I see what you meant, then no the methods are really giving access to the jfp files, nothing else. (The other method are private.)

Copy link
Copy Markdown
Contributor

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD left a comment

Choose a reason for hiding this comment

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

LGTM, left minor comment.

Copy link
Copy Markdown
Contributor

@jbachorik jbachorik left a comment

Choose a reason for hiding this comment

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

Looks good

@bric3 bric3 added this pull request to the merge queue May 15, 2026
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 15, 2026

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 15, 2026

View all feedbacks in Devflow UI.

2026-05-15 14:01:00 UTC ℹ️ Start processing command /merge


2026-05-15 14:01:05 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-05-15 15:58:18 UTC ⚠️ MergeQueue: This merge request build was cancelled

brice.dutheil@datadoghq.com cancelled this merge request build

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 15, 2026
@bric3 bric3 mentioned this pull request May 15, 2026
10 tasks
@bric3
Copy link
Copy Markdown
Contributor Author

bric3 commented May 15, 2026

/merge -c

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 15, 2026

View all feedbacks in Devflow UI.

2026-05-15 15:58:09 UTC ℹ️ Start processing command /merge -c

@bric3
Copy link
Copy Markdown
Contributor Author

bric3 commented May 15, 2026

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 15, 2026

View all feedbacks in Devflow UI.

2026-05-15 16:00:55 UTC ℹ️ Start processing command /merge


2026-05-15 16:01:00 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-05-15 17:09:36 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 66eda9a into master May 15, 2026
574 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the bdu/removes-sourceset-output-cross-project-sharing branch May 15, 2026 17:09
@github-actions github-actions Bot added this to the 1.63.0 milestone May 15, 2026
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.

4 participants