Skip to content

Upgrade gradle to v8.14.2 #8950

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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ variables:
BUILD_JOB_NAME: "build"
DEPENDENCY_CACHE_POLICY: pull
BUILD_CACHE_POLICY: pull
GRADLE_VERSION: "8.5" # must match gradle-wrapper.properties
GRADLE_VERSION: "8.14.2" # must match gradle-wrapper.properties
MAVEN_REPOSITORY_PROXY: "http://artifactual.artifactual.all-clusters.local-dc.fabric.dog:8081/repository/maven-central/"
GRADLE_PLUGIN_PROXY: "http://artifactual.artifactual.all-clusters.local-dc.fabric.dog:8081/repository/gradle-plugin-portal-proxy/"
BUILDER_IMAGE_VERSION_PREFIX: "" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "v25.05-")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import java.util.Set;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.matcher.ElementMatcher;
import org.gradle.internal.service.DefaultServiceRegistry;
import org.gradle.internal.service.ServiceRegistry;
import org.gradle.internal.service.scopes.BuildScopeServices;

@AutoService(InstrumenterModule.class)
public class GradleBuildScopeServices_8_3_Instrumentation extends InstrumenterModule.CiVisibility
Expand Down Expand Up @@ -55,7 +55,7 @@ public void methodAdvice(MethodTransformer transformer) {
public static class Construct {
@Advice.OnMethodExit(suppress = Throwable.class)
public static void afterConstructor(
@Advice.This final BuildScopeServices buildScopeServices,
@Advice.This final DefaultServiceRegistry buildScopeServices,
@Advice.Argument(0) final ServiceRegistry parentServices) {
CiVisibilityGradleListenerInjector_8_3.injectCiVisibilityGradleListener(
buildScopeServices, parentServices);
Copy link
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 errors->updates made below 🤔

Expand Down
13 changes: 6 additions & 7 deletions dd-java-agent/instrumentation/junit-5.3/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apply from: "$rootDir/gradle/java.gradle"

// JUnit5 5.3.0+ version is needed because of the fix in the TestInheritance test suite names.
Copy link
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.

I'm honestly not quite sure why the gradle upgrade initiated this. Others have faced the same problem (unplanned junit issue) and also resolved it by switching the versions.

Expand Down Expand Up @@ -33,9 +32,9 @@ dependencies {

// versions used below are not the minimum ones that we support,
// but the tests need to use them in order to be compliant with Spock 2.x
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.9.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.9.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.9.2'
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.13.1'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.13.1'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.13.1'

latestDepTestImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '+'
latestDepTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '+'
Expand All @@ -44,8 +43,8 @@ dependencies {

configurations.matching({ it.name.startsWith('test') }).each({
it.resolutionStrategy {
force group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.9.2'
force group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.9.2'
force group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.9.2'
force group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.13.1'
force group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.13.1'
force group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.13.1'
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ muzzle {
group = 'io.cucumber'
module = 'cucumber-junit-platform-engine'
versions = '[5.4.0,)'
extraDependency "org.junit.platform:junit-platform-launcher:1.9.2"
extraDependency "org.junit.platform:junit-platform-launcher:1.13.1"
}
}

Expand All @@ -19,9 +19,9 @@ dependencies {

testImplementation testFixtures(project(':dd-java-agent:agent-ci-visibility'))

testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.9.2'
testImplementation group: 'org.junit.platform', name: 'junit-platform-suite', version: '1.9.2'
testImplementation group: 'org.junit.platform', name: 'junit-platform-suite-engine', version: '1.9.2'
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.13.1'
testImplementation group: 'org.junit.platform', name: 'junit-platform-suite', version: '1.13.1'
testImplementation group: 'org.junit.platform', name: 'junit-platform-suite-engine', version: '1.13.1'

testImplementation group: 'io.cucumber', name: 'cucumber-junit-platform-engine', version: '5.4.0'
testImplementation group: 'io.cucumber', name: 'cucumber-java', version: '5.4.0'
Expand All @@ -33,8 +33,7 @@ dependencies {

configurations.matching({ it.name.startsWith('test') }).each({
it.resolutionStrategy {
force group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.9.2'
force group: 'org.junit.platform', name: 'junit-platform-suite', version: '1.9.2'
force group: 'org.junit.platform', name: 'junit-platform-suite', version: '1.9.2'
force group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.13.1'
force group: 'org.junit.platform', name: 'junit-platform-suite', version: '1.13.1'
}
})
12 changes: 6 additions & 6 deletions dd-java-agent/instrumentation/junit-5.3/junit-5.8/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ dependencies {

// versions used below are not the minimum ones that we support,
// but the tests need to use them in order to be compliant with Spock 2.x
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.9.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.9.2'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.9.2'
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.13.1'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.13.1'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.13.1'

latestDepTestImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '+'
latestDepTestImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '+'
Expand All @@ -47,8 +47,8 @@ dependencies {

configurations.matching({ it.name.startsWith('test') }).each({
it.resolutionStrategy {
force group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.9.2'
force group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.9.2'
force group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.9.2'
force group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.13.1'
force group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.13.1'
force group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.13.1'
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ muzzle {
group = 'org.spockframework'
module = 'spock-core'
versions = "[2.0-groovy-${spockGroovyVersion},)"
extraDependency "org.junit.platform:junit-platform-launcher:1.9.2"
extraDependency "org.junit.platform:junit-platform-launcher:1.13.1"
}
}

Expand All @@ -22,7 +22,7 @@ dependencies {

testImplementation testFixtures(project(':dd-java-agent:agent-ci-visibility'))

testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.9.2'
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.13.1'
testImplementation group: 'org.spockframework', name: 'spock-core', version: "2.2-groovy-${spockGroovyVersion}"

// Broken from 2.4: https://datadoghq.atlassian.net/browse/AIDM-163
Expand All @@ -31,7 +31,7 @@ dependencies {

configurations.matching({ it.name.startsWith('test') }).each({
it.resolutionStrategy {
force group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.9.2'
force group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.13.1'
force group: 'org.spockframework', name: 'spock-core', version: "2.2-groovy-${spockGroovyVersion}"
}
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datadog.trace.agent.test.base.AbstractPromiseTest
import io.netty.util.concurrent.DefaultEventExecutorGroup
import io.netty.util.concurrent.Future
import io.netty.util.concurrent.GenericProgressiveFutureListener
import io.netty.util.concurrent.ProgressiveFuture
import io.netty.util.concurrent.ProgressivePromise
import spock.lang.Shared

Expand Down Expand Up @@ -61,15 +61,12 @@ class NettyProgressivePromiseTest extends AbstractPromiseTest<ProgressivePromise
when:
runUnderTrace("parent") {
def listeners = iterations.collect { int i ->
return new GenericProgressiveFutureListener<Future<?>>() {

@Override
void operationComplete(Future<?> future) throws Exception {
return new GenericProgressiveFutureListener<ProgressiveFuture<?>>() {
void operationComplete(ProgressiveFuture<?> future) throws Exception {
runUnderTrace("listen$i") {}
}

@Override
void operationProgressed(Future<?> future, long progress, long total) throws Exception {
void operationProgressed(ProgressiveFuture<?> future, long progress, long total) throws Exception {
runUnderTrace("progress$i") {}
}
}
Copy link
Contributor Author

@sarahchen6 sarahchen6 Jun 10, 2025

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 for some reason 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.

Expand Down
12 changes: 6 additions & 6 deletions dd-java-agent/instrumentation/scala/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final testTasks = scalaVersions.collect { scalaLibrary ->
def (major, minor) = version.split('_').collect(Integer.&valueOf)
Copy link
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

final javaConcatenation = major > 2 || minor > 11 // after 2.11 scala uses java.lang.StringBuilder to perform concatenation

final configuration = configurations.create("${version}Implementation") {
final implementationConfiguration = configurations.create("${version}Implementation") {
canBeConsumed = false
canBeResolved = false
canBeDeclared = true
Expand All @@ -36,14 +36,14 @@ final testTasks = scalaVersions.collect { scalaLibrary ->
canBeConsumed = false
canBeResolved = true
canBeDeclared = false
extendsFrom(configuration)
extendsFrom(implementationConfiguration)
}

dependencies { handler ->
handler.add(configuration.name, scalaLibrary)
handler.add(configuration.name, libs.slf4j)
handler.add(implementationConfiguration.name, scalaLibrary)
handler.add(implementationConfiguration.name, libs.slf4j)
if (javaConcatenation) {
handler.add(configuration.name, project(':dd-java-agent:instrumentation:java-lang'))
handler.add(implementationConfiguration.name, project(':dd-java-agent:instrumentation:java-lang'))
}
}

Expand All @@ -59,7 +59,7 @@ final testTasks = scalaVersions.collect { scalaLibrary ->
.filter { !it.toString().contains('scala-library') } // exclude default scala-library
.minus(files(sourceSets.test.scala.classesDirectory)) // exclude default /build/classes/scala/test folder
.plus(customSourceSet.output.classesDirs) // add /build/classes/scala/${version} folder
.plus(classPathConfiguration) // add new scala-library configuration
.plus(classPathConfiguration) // add new scala-library configuration
systemProperty('uses.java.concat', javaConcatenation)
dependsOn(tasks.named("compile${version.capitalize()}Scala"))
group = 'verification'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class GradleLauncherSmokeTest extends AbstractGradleTest {
])
String[] command = ["./gradlew", "--no-daemon", "--info"]
if (gradleDaemonCmdLineParams) {
command += "-Dorg.gradle.jvmargs=$gradleDaemonCmdLineParams"
command += "-Dorg.gradle.jvmargs=$gradleDaemonCmdLineParams".toString()
}
Copy link
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…

return shellCommandExecutor.executeCommand(IOUtils::readFully, command)
}
Expand Down
3 changes: 2 additions & 1 deletion gradle/java_no_deps.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.gradle.api.internal.provider.PropertyFactory
import org.gradle.jvm.toolchain.internal.SpecificInstallationToolchainSpec

apply plugin: 'java-library'
Expand Down Expand Up @@ -164,7 +165,7 @@ project.afterEvaluate {
def testJvmHomePath = getJavaHomePath(testJvmHome)
// Only change test JVM if it's not the one we are running the gradle build with
if (currentJavaHomePath != testJvmHomePath) {
def jvmSpec = new SpecificInstallationToolchainSpec(project.getObjects(), file(testJvmHomePath))
def jvmSpec = new SpecificInstallationToolchainSpec(project.services.get(PropertyFactory), file(testJvmHomePath))
// The provider always says that a value is present so we need to wrap it for proper error messages
Copy link
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.

Provider<JavaLauncher> launcher = providers.provider {
try {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ okhttp-legacy = "[3.0,3.12.12]" # 3.12.x is last version to support Java7
okio = "1.17.6" # Datadog fork

spock = "2.3-groovy-3.0"
groovy = "3.0.17"
groovy = "3.0.24"
junit5 = "5.9.2"
Copy link
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

logback = "1.2.3"
bytebuddy = "1.17.5"
Expand Down
16 changes: 8 additions & 8 deletions gradle/test-suites.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.gradle.api.plugins.jvm.JvmTestSuite

ext.addTestSuiteExtendingForDir = (String testSuiteName, String parentSuiteName, String dirName) -> {
ext.addTestSuiteExtendingForDir = { testSuiteName, parentSuiteName, dirName ->
testing {
suites {
create(testSuiteName, JvmTestSuite, {
Expand All @@ -27,16 +27,12 @@ ext.addTestSuiteExtendingForDir = (String testSuiteName, String parentSuiteName,
}
}
}
dependencies {
implementation project(project.path)
}
})
}
}

configurations {
def extendConf = {
String suffix ->
def extendConf = { suffix ->
def config = named("${testSuiteName}${suffix}")
def parentConfig = named("${parentSuiteName}${suffix}")
if (parentConfig.present) {
Expand Down Expand Up @@ -65,12 +61,16 @@ ext.addTestSuiteExtendingForDir = (String testSuiteName, String parentSuiteName,
from(sourceSets.named(testSuiteName).get().output)
archiveClassifier = testSuiteName
}

project.dependencies {
"${testSuiteName}Implementation"(project(project.path))
}
}
Copy link
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


ext.addTestSuiteForDir = (String testSuiteName, String dirName) -> {
ext.addTestSuiteForDir = { testSuiteName, dirName ->
ext.addTestSuiteExtendingForDir(testSuiteName, 'test', dirName)
}

ext.addTestSuite = (String testSuiteName) -> {
ext.addTestSuite = { testSuiteName ->
ext.addTestSuiteForDir(testSuiteName, testSuiteName)
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
# Please note that the version specific cache directory in
# .gitlab-ci.yml needs to match this version.
distributionSha256Sum=c16d517b50dd28b3f5838f0e844b7520b8f1eb610f2f29de7e4e04a1b7c9c79b
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
distributionSha256Sum=443c9c8ee2ac1ee0e11881a40f2376d79c66386264a44b24a9f8ca67e633375f
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ class MetricPeriodicActionTest extends Specification {

class DefaultMetricPeriodicAction extends MetricPeriodicAction {

private final MetricCollector<Metric> collector
private final MetricCollector<MetricCollector.Metric> collector

DefaultMetricPeriodicAction(@NonNull final MetricCollector<Metric> collector) {
DefaultMetricPeriodicAction(@NonNull final MetricCollector<MetricCollector.Metric> collector) {
this.collector = collector
}

@Override
@NonNull
MetricCollector<Metric> collector() {
MetricCollector<MetricCollector.Metric> collector() {
return collector
Copy link
Contributor Author

@sarahchen6 sarahchen6 Jun 10, 2025

Choose a reason for hiding this comment

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

For some reason, upgrading Gradle leads to the new(?) 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.

}
}
Expand Down
Loading