Upgrade gradle to v8.14.3 by sarahchen6 · Pull Request #8950 · DataDog/dd-trace-java · GitHub
Skip to content

Upgrade gradle to v8.14.3#8950

Merged
sarahchen6 merged 20 commits into
masterfrom
sarahchen6/upgrade-to-gradle-8.14
Jul 10, 2025
Merged

Upgrade gradle to v8.14.3#8950
sarahchen6 merged 20 commits into
masterfrom
sarahchen6/upgrade-to-gradle-8.14

Conversation

@sarahchen6

@sarahchen6 sarahchen6 commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

What Does This Do

Upgrade gradle to v8.14.3

Motivation

Upgrade to the latest version of gradle

Additional Notes

Contributor Checklist

Jira ticket: https://datadoghq.atlassian.net/browse/LANGPLAT-660

@sarahchen6 sarahchen6 added type: enhancement Enhancements and improvements comp: tooling Build & Tooling labels Jun 9, 2025
@pr-commenter

pr-commenter Bot commented Jun 9, 2025

Copy link
Copy Markdown

Comment thread .gitlab-ci.yml Outdated
@sarahchen6 sarahchen6 changed the title Upgrade gradle to v8.14 Upgrade gradle to v8.14.2 Jun 10, 2025
@bric3

bric3 commented Jun 10, 2025

Copy link
Copy Markdown
Contributor

I believe the failure in gradle/java_no_deps.gradle can be fixed via

      if (currentJavaHomePath != testJvmHomePath) {
-       def jvmSpec = new SpecificInstallationToolchainSpec(project.getObjects(), file(testJvmHomePath))
+       def jvmSpec = new SpecificInstallationToolchainSpec(project.services.get(org.gradle.api.internal.provider.PropertyFactory), file(testJvmHomePath))
        // The provider always says that a value is present so we need to wrap it for proper error messages
        Provider<JavaLauncher> launcher = providers.provider {

This object is internal and has to use this internal API, there's no other options at this time I think.

Comment thread gradle/libs.versions.toml Outdated

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.

When upgrading from Gradle <= 8.13, Groovy needs to be upgraded to 3.0.24: https://docs.gradle.org/current/userguide/upgrading_version_8.html#upgrade_to_groovy_3_0_24

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.

Changes in this file address aesthetic comments in the previous Gradle upgrade #8886

@sarahchen6 sarahchen6 Jun 10, 2025

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.

Received the error The type Metric is not a valid substitute for the bounded parameter <M extends datadog.trace.api.telemetry.MetricCollector$Metric>. To resolve this, we needed strict type resolution to distinguish MetricCollector.Metric and the imported datadog.telemetry.api.Metric class. This type strictness follows patterns to explicitly use MetricCollector.Metric throughout the file.

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.

Much better without ambiguity ! TY

Comment thread gradle/test-suites.gradle Outdated

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.

Project dependencies was separated out due to the error The value for property 'dependencies.implementation' property 'dependencies' is final and cannot be changed any further. that prevented Gradle compilation. I think this is due to the deprecation of mutating configurations after observation that was introduced after 8.7: https://docs.gradle.org/current/userguide/upgrading_version_8.html#mutate_configuration_after_locking

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.

Indeed this looks like it : gradle/gradle#28867

Maybe drop a comment there, to explain why the documented method did not work. I wasn't able to reliably reproduce this issue. So there might be something odd happending.

Comment thread gradle/java_no_deps.gradle Outdated

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.

This change is needed due to the introduced error groovy.lang.GroovyRuntimeException: Could not find matching constructor for: org.gradle.jvm.toolchain.internal.SpecificInstallationToolchainSpec(org.gradle.api.internal.model.DefaultObjectFactory, File). I'm not sure exactly where this comes from, but since this is part of Gradle's internal implementation, breaking changes can be made unannounced.

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.

This internal Gradle type has changed twice its constructor signature since 8.5

Comment thread gradle/java_no_deps.gradle Outdated

@sarahchen6 sarahchen6 Jun 10, 2025

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.

GenericProgressiveFutureListener argument extends ProgressiveFuture (ref), and with the Gradle upgrade, I get the error: The type Future is not a valid substitute for the bounded parameter <F extends io.netty.util.concurrent.ProgressiveFuture<?>>. Explicitly setting the type to ProgressiveFuture instead of Future resolved this.

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.

For reference, there is a warning on master on this, suggesting to use ProgressiveFuture instead:
Image

@sarahchen6 sarahchen6 Jun 10, 2025

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.

When trying to ./gradlew clean assemble, I ran across the error incompatible types: org.gradle.internal.service.scopes.BuildScopeServices cannot be converted to org.gradle.internal.service.DefaultServiceRegistry. Explicitly setting the buildScopeServices type to DefaultServiceRegistry (which is what injectCiVisibilityGradleListener takes) resolves this.

I'm thinking that the Gradle upgrade has led to stricter type resolution as seen from other changes needed in this PR 🤔

@sarahchen6 sarahchen6 Jun 10, 2025

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.

The updates to the latest version of JUnit Jupiter and Platform address the error:

org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests...
Caused by: org.junit.platform.commons.JUnitException: OutputDirectoryProvider not available; probably due to unaligned versions of the junit-platform-engine and junit-platform-launcher jars on the classpath/module path.

Not quite sure why the gradle upgrade initiated this, but others have faced the same problem (unplanned junit issue) and resolved it by updating versions.

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.

I'd like to use the oldest possible version here, as we want to ensure JUnit 5 instrumentation is working for older releases. Could you please double-check which artifacts' version changes when Gradle version is bumped?
You can use commands like the one below:

./gradlew :dd-java-agent:instrumentation:junit-5.3:dependencyInsight --configuration testRuntimeClasspath --dependency org.junit

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.

@nikita-tkachenko-datadog Maybe something you can do is to declare them as constraints in this case ?

https://docs.gradle.org/current/userguide/dependency_constraints.html

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.

Good to know. From the command you shared, it looks like 1.12.0 and 5.12.0 are the oldest versions we can pull in (e.g. org.junit.platform:junit-platform-suite-api:1.12.0 and org.junit.jupiter:junit-jupiter-api:5.12.0 get pulled in). I can change that now!

@bric3

bric3 commented Jun 11, 2025

Copy link
Copy Markdown
Contributor

You may want to merge latest master, there were fixes on the gradle daemon smoke tests, see #8955

Unsure about the muzzle ones.

@sarahchen6 sarahchen6 force-pushed the sarahchen6/upgrade-to-gradle-8.14 branch from d8450d8 to 0bb8eab Compare June 11, 2025 13:27
if (gradleDaemonCmdLineParams) {
command += "-Dorg.gradle.jvmargs=$gradleDaemonCmdLineParams"
command += "-Dorg.gradle.jvmargs=$gradleDaemonCmdLineParams".toString()
}

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.

This resolves errors I was getting with assigning GStringImpl to String[] (others' experiences: apache issue, stackoverflow issue). Seems like this should be resolved with groovy 3.0.7+, but I guess not…

@sarahchen6 sarahchen6 Jul 2, 2025

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.

The muzzle check for this instrumentation fails on a classloader mismatch when running on Gradle 8.14.3, but since this instrumentation targets Gradle 8.3, skip muzzle like what is done for 8_10_Instrumentation.

@bric3

bric3 commented Jul 4, 2025

Copy link
Copy Markdown
Contributor

FYI 8.14.3 was just released

@sarahchen6 sarahchen6 requested review from a team as code owners July 7, 2025 18:22
@sarahchen6 sarahchen6 requested review from AlexeyKuznetsov-DD, bric3, nikita-tkachenko-datadog, pawelchcki and ygree and removed request for a team July 7, 2025 18:22
Comment thread gradle/wrapper/gradle-wrapper.properties Outdated
Comment on lines 35 to 37

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.

Shall we also update grdale.lock for this and similar places?

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 will leave this to the github bot 😬

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.

Today I learned where it came from

@sarahchen6 sarahchen6 force-pushed the sarahchen6/upgrade-to-gradle-8.14 branch from dc12875 to 2f16060 Compare July 7, 2025 19:53
@sarahchen6 sarahchen6 force-pushed the sarahchen6/upgrade-to-gradle-8.14 branch from 2f16060 to 7e140f4 Compare July 7, 2025 20:45

@PerfectSlayer PerfectSlayer left a comment

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.

Not much feedback to give on this part 😓 I feel @bric3 to be way more knowledgeable on that part than me.

But mainly, I would make sure to get approval from CI Visibility before merging as changing their instrumentations.

@bric3 bric3 left a comment

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.

Overall it looks good ! Thank you for the upgrade !

Comment on lines 35 to 37

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.

Today I learned where it came from

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.

@nikita-tkachenko-datadog Maybe something you can do is to declare them as constraints in this case ?

https://docs.gradle.org/current/userguide/dependency_constraints.html

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.

For reference, there is a warning on master on this, suggesting to use ProgressiveFuture instead:
Image

Comment on lines -10 to -17
// 3.0.24 added support for JDK 24 via ASM 9.7.1
// https://groovy-lang.org/changelogs/changelog-3.0.24.html
// https://asm.ow2.io/versions.html#9.7.1
configurations.all {
resolutionStrategy {
force 'org.codehaus.groovy:groovy-all:3.0.24'
}
}

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.

note: We may have to resurrect this code for JDK 25.

Comment thread gradle/java_no_deps.gradle Outdated

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.

This internal Gradle type has changed twice its constructor signature since 8.5

Comment thread gradle/wrapper/gradle-wrapper.properties Outdated

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.

Much better without ambiguity ! TY

Comment thread gradle/test-suites.gradle Outdated

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.

Indeed this looks like it : gradle/gradle#28867

Maybe drop a comment there, to explain why the documented method did not work. I wasn't able to reliably reproduce this issue. So there might be something odd happending.

sarahchen6 and others added 3 commits July 9, 2025 10:15
Co-authored-by: Brice Dutheil <brice.dutheil@gmail.com>
@sarahchen6 sarahchen6 merged commit 9519752 into master Jul 10, 2025
507 checks passed
@sarahchen6 sarahchen6 deleted the sarahchen6/upgrade-to-gradle-8.14 branch July 10, 2025 12:55
@github-actions github-actions Bot added this to the 1.52.0 milestone Jul 10, 2025
@mcculls mcculls added the tag: no release notes Changes to exclude from release notes label Aug 4, 2025
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 type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants