Skip to content

WIP / DRAFT gradle 9.x#10402

Draft
bric3 wants to merge 3 commits into
masterfrom
bdu/gradle
Draft

WIP / DRAFT gradle 9.x#10402
bric3 wants to merge 3 commits into
masterfrom
bdu/gradle

Conversation

@bric3
Copy link
Copy Markdown
Contributor

@bric3 bric3 commented Jan 19, 2026

What Does This Do

This is a workspace to try upgrading to Gradle 9.

Motivation

Keep tool up-to-date. Support later JDKs and libraries.

Gradle 9.3 Compatibility Report

Executive Summary

This report documents the compatibility issues encountered when upgrading dd-trace-java to Gradle 9.3.0. While several issues have been resolved, a fundamental blocker remains: Spring Boot 2.x Gradle plugin is incompatible with Gradle 9.

Related work:

Issues Fixed

  • Provider API Changes (TestJvmSpec.kt) 👉 Superseded by Remove nullable type in TestJvmSpec #11336

    Details

    Commit: 23f79d6821

    Problem: Gradle 9 changed the Provider API for handling nullable types. The old code used project.providers.provider<JavaLauncher?> { null } which is no longer compatible.

    Fix:

    // Before (Gradle 8)
    project.providers.provider<JavaLauncher?> { null }
    
    // After (Gradle 9)
    project.objects.property(JavaLauncher::class.java) // Empty property - no value set

    File: buildSrc/src/main/kotlin/datadog/gradle/plugin/testJvmConstraints/TestJvmSpec.kt:141

  • Dependency Locking Configuration (dd-trace-java.dependency-locking.gradle.kts) not needed

    Details

    Commit: 23f79d6821

    Problem: Gradle 9's new JVM Test Suite plugin automatically creates test configurations when the java plugin is applied. The dependency locking configuration was being applied too early, causing conflicts.

    Fix: Wrap dependency locking in pluginManager.withPlugin("java"):

    pluginManager.withPlugin("java") {
      project.dependencyLocking {
        lockAllConfigurations()
        lockMode = LockMode.LENIENT
      }
    }

    File: buildSrc/src/main/kotlin/dd-trace-java.dependency-locking.gradle.kts:13-23

  • SelfResolvingDependency API Removal (publish.gradle) 👉 Superseded by Replace SelfResolvingDependency by ExternalModuleDependency #11340

    Details

    Commit: 23f79d6821

    Problem: The SelfResolvingDependency class was removed from Gradle 9.

    Fix:

    // Before (Gradle 8)
    if ((it instanceof ProjectDependency) || !(it instanceof SelfResolvingDependency)) {
    
    // After (Gradle 9)
    if (it instanceof ProjectDependency || it instanceof ExternalModuleDependency) {

    File: gradle/publish.gradle:41

  • sourceCompatibility/targetCompatibility Configuration (benchmark-integration/build.gradle) 👉 Superseded by Small Gradle Style tweaks #11306

    Details

    Commit: 23f79d6821

    Problem: Gradle 9 requires that sourceCompatibility and targetCompatibility be set within the java {} configuration block rather than at the project root level.

    Fix:

    // Before (Gradle 8)
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
    
    // After (Gradle 9)
    java {
      sourceCompatibility = JavaVersion.VERSION_1_8
      targetCompatibility = JavaVersion.VERSION_1_8
    }

    File: dd-java-agent/benchmark-integration/build.gradle:28-31

  • Protobuf Gradle Plugin Updates 👉 Superseded by Upgrade protobuf Gradle plugin to 0.10.0 across all modules #11310

    Details

    Commit: 23f79d6821

    Problem: Old protobuf plugin versions (0.8.18 and 0.9.4) are not compatible with Gradle 9.

    Fix: Update to version 0.9.6

    Files affected (8 modules):

    • dd-java-agent/agent-iast/build.gradle
    • dd-java-agent/instrumentation/grpc-1.5/build.gradle
    • dd-java-agent/instrumentation/armeria/armeria-grpc-0.84/build.gradle
    • dd-java-agent/instrumentation/protobuf-3.0/build.gradle
    • dd-smoke-tests/springboot-grpc/build.gradle
    • dd-smoke-tests/grpc-1.5/build.gradle
    • dd-smoke-tests/armeria-grpc/build.gradle
    • dd-smoke-tests/armeria-grpc/application/build.gradle
  • Configuration Creation Order (log4j-1.2.4/build.gradle) 👉 Superseded by Small Gradle Style tweaks #11306

    Details

    Problem: Accessing testImplementation configuration before applying java.gradle caused the configuration to be created prematurely. When the Java plugin later tried to create its JVM Test Suite, it failed because testImplementation already existed.

    Error:

    Cannot add a configuration with name 'testImplementation' as a configuration with that name already exists.
    

    Fix: Move apply from: "$rootDir/gradle/java.gradle" before the configurations {} block.

    File: dd-java-agent/instrumentation/log4j/log4j-1.2.4/build.gradle

  • Bnd Plugin Compatibility (osgi/build.gradle) 👉 Superseded by Bump aQute bnd plugin (osgi) to 7.2.3 #11341

    Details

    Problem: The bnd plugin version 6.4.0 uses the removed Convention API (Jar.getConvention()).

    Error:

    'org.gradle.api.plugins.Convention org.gradle.api.tasks.bundling.Jar.getConvention()'
    

    Fix: Upgrade bnd plugin from 6.4.0 to 7.2.3

    File: dd-smoke-tests/osgi/build.gradle:4

  • Project.exec() Removal (version.gradle), 👉 superseded by Migrate version.gradle script plugin to Kotlin convention plugin #11345

    Details

    Problem: project.exec() method was removed in Gradle 9.

    Error:

    Could not find method exec() for arguments [...] on project
    

    Fix: Inject ExecOperations via @Inject and use execOperations.exec() instead:

    import javax.inject.Inject
    import org.gradle.process.ExecOperations
    
    abstract class WriteVersionNumberFile extends DefaultTask {
      @Inject
      abstract ExecOperations getExecOperations()
    
      // Use execOperations.exec { } instead of project.exec { }
    }

    File: gradle/version.gradle:11-12, 19

  • Protobuf Generated Source Path Change 👉 Superseded by Upgrade protobuf Gradle plugin to 0.10.0 across all modules #11310, Remove redundant manual proto srcDir from protobuf-3.0 instrumentation #11343

    Details

    Problem: Protobuf Gradle plugin 0.9.x changed the generated source path from source (singular) to sources (plural).

    Error:

    unable to resolve class com.datadog.iast.protobuf.Test2
    

    Fix:

    // Before
    srcDirs += ["$buildDir/generated/source/proto/test/java"]
    
    // After
    srcDirs += [layout.buildDirectory.dir("generated/sources/proto/test/java")]

    Files:

    • dd-java-agent/agent-iast/build.gradle:121
    • dd-java-agent/instrumentation/protobuf-3.0/build.gradle:40
  • Cross-Project Test Source Sharing via sourceSets 👉 Fixed in Migrate cross-project test source sharing to java-test-fixtures for Gradle 9.5 compatibility #11367, and Migrate debugger-integration-tests cross-project test source sharing to java-test-fixtures for Gradle 9.5 compatibility #11416

    Details

    Problem: Gradle 9.5 added a DependencyHandler.project(String) overload returning a ProjectDependency. In Groovy DSL dependencies {} closures, this shadows the previously-used Project.project(String) fallback, so expressions like project(':foo').sourceSets now fail because DefaultProjectDependency has no sourceSets property.

    Error:

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

    Fix:

    • profiling-controller-jfr: migrated test resource sharing to the java-test-fixtures plugin; JFP resource paths are now provided by JfpTestResources, which extracts classpath resources to temp files (test-fixture JARs are not accessible via File directly).
    • Nine mongo driver/test consumers: removed redundant testImplementation project(':...:mongo-common').sourceSets.test.output declarations that duplicated an already-correct testFixtures(project(':...:mongo-common')) dependency.
  • Spring Boot 2.x Incompatibility, done via Add smoke-test plugin for nested Gradle builds #11405 and follow ups: Remove unused Spring Boot plugin from kafkaschemaregistry #11406, Switch spring-boot-2.7-webflux to the smoke-test plugin #11407, Extract Spring Boot 2.x app source into nested-build subprojects #11408, Convert wildfly earBuild tasks to the smoke-test plugin #11417, Convert Spring Boot 3 / quarkus / armeria / vertx to smoke-test plugin #11421

    Details

    Problem: The Spring Boot Gradle plugin versions 2.x use the Configuration.getUploadTaskName() method which was removed in Gradle 9.

    Error:

    java.lang.NoSuchMethodError: 'java.lang.String org.gradle.api.artifacts.Configuration.getUploadTaskName()'
        at org.springframework.boot.gradle.plugin.SpringBootPlugin.registerPluginActions(SpringBootPlugin.java:122)
    

    Compatibility Matrix

    Spring Boot Version Gradle 9 Support Servlet API
    2.5.x ❌ No javax.servlet
    2.6.x ❌ No javax.servlet
    2.7.x ❌ No javax.servlet
    3.0.x ❌ No jakarta.servlet
    3.1.x ❌ No jakarta.servlet
    3.2.x ❌ No jakarta.servlet
    3.3.x ❌ No jakarta.servlet
    3.4.x ❌ No jakarta.servlet
    3.5.x+ ✅ Yes jakarta.servlet

    Affected Smoke Tests

    The following smoke tests use Spring Boot 2.x and are incompatible with Gradle 9:

    Module Current Version Notes
    dd-smoke-tests/apm-tracing-disabled 2.7.18 Uses javax.servlet
    dd-smoke-tests/springboot-jpa 2.6.0 Uses javax.persistence
    dd-smoke-tests/springboot-freemarker 2.7.15
    dd-smoke-tests/springboot-java-11 2.7.15
    dd-smoke-tests/springboot-java-17 2.7.15
    dd-smoke-tests/springboot-jetty-jsp 2.7.15
    dd-smoke-tests/springboot-thymeleaf 2.7.15
    dd-smoke-tests/springboot-tomcat-jsp 2.7.15
    dd-smoke-tests/springboot-tomcat 2.5.12
    dd-smoke-tests/springboot-velocity 2.7.15
    dd-smoke-tests/kafka-2 2.7.15
    dd-smoke-tests/openfeature 2.7.15
    dd-smoke-tests/spring-boot-2.7-webflux 2.7.4
    dd-smoke-tests/datastreams/kafkaschemaregistry 2.6.3

    Root Cause

    Spring Boot 3.0 migrated from Java EE (javax.*) to Jakarta EE (jakarta.*). This is a breaking change that requires source code modifications:

    // Spring Boot 2.x (Java EE)
    import javax.servlet.http.HttpServletRequest;
    import javax.persistence.Entity;
    
    // Spring Boot 3.x (Jakarta EE)
    import jakarta.servlet.http.HttpServletRequest;
    import jakarta.persistence.Entity;

    Additionally, Spring Boot 3.x requires Java 17 or later, whereas several smoke tests target Java 8 or 11.

    Explored ways to do that in Isolate Spring Boot <3.5 apps in smoke-tests subprojects for Gradle 9 compatibility #11379 and Build smoke-test apps via Gradle Tooling API for Gradle 9 readiness #11404 before moving to smaller PRs

  • :dd-smoke-tests:gradle inherits Groovy 4 which is incompatible with pock 2.4.0-groovy-3.0, Fixed by Migrate CI Visibility Smoke tests from Groovy to Java #11439

    Details

    Problem: Spock's 2.4-groovy-3.0 artifact only works when Groovy 3.x is on the test classpath. Groovy 4 reaches a module via gradleTestKit(), gradleApi(), localGroovy(), used by this module.

    Fix: Bump to Groovy 4, or convert the test to java (but they are inheriting a parent)

  • Test discovery now fails the build with no tests (failOnNoDiscoveredTests)

    Details

    Problem: Gradle 9 introduces Test.failOnNoDiscoveredTests and defaults it to true. Every Test task that has compiled test sources but discovers zero executable tests (typical for latestDepTest / latest*Test / extra addTestSuite variants that only ship sources for some JVM/library combinations) now fails the build.

    Error:

    There are test sources present and no filters are applied, but the test
    task did not discover any tests to execute. This is likely due to a
    misconfiguration. Please check your test configuration. If this is not
    a misconfiguration, this error can be disabled by setting the
    'failOnNoDiscoveredTests' property to false.
    

    Affected jobs (pipeline 114751498):

    • test_inst: [*, 8/8]:aws-java-sdk-2.2:payloadTaggingTest, :vertx-redis-client-3.9:redis4xTest
    • test_inst: [8, 7/8]:ignite-2.0:ignite216Test
    • test_inst_latest: [*, {1,2,4,5}/6] — many *latestDepTest / latestPre207Test / latest7DepTest / latestPayloadTaggingTest across hazelcast-{3.6,3.9,4.0}, wildfly-9.0, valkey-java-5.3, aerospike-4.0, aws-java-sdk-2.2, javax-servlet-2.2, vertx-mysql-client-{3.9,4.0}, vertx-pg-client-4.0, vertx-redis-client-3.9, jedis-4.0, jax-rs-client-1.1, synapse-3.0, finatra-2.9

    Fix: disable globally on every Test task in buildSrc/src/main/kotlin/dd-trace-java.configure-tests.gradle.kts, alongside the other tasks.withType<Test>().configureEach { ... } configuration:

    tasks.withType<Test>().configureEach {
      failOnNoDiscoveredTests = false
    }
  • JUnit Platform launcher no longer auto-injected 👉 Fixed by Convert test-published-dependencies to Gradle Kotlin DSL #11445

    Details

    Problem: Gradle 9 stopped putting junit-platform-launcher on the test runtime classpath automatically. Subprojects that only depend on junit-jupiter now fail at startup.

    Error:

    Caused by: org.gradle.api.internal.tasks.testing.TestSuiteExecutionException:
      Could not start Gradle Test Executor N.
    Caused by: RequiresTestFrameworkTestDefinitionProcessor$TestFrameworkNotAvailableException:
      Failed to load JUnit Platform. Please ensure that all JUnit Platform
      dependencies are available on the test's runtime classpath, including
      the JUnit Platform launcher.
    

    Affected job: test_published_artifacts:agent-logs-on-java-7:test, :ot-pulls-in-api:test

    Fix: add testRuntimeOnly("org.junit.platform:junit-platform-launcher") in both test-published-dependencies/agent-logs-on-java-7/build.gradle(.kts) and test-published-dependencies/ot-pulls-in-api/build.gradle(.kts). Handled in Convert test-published-dependencies to Gradle Kotlin DSL #11445.

  • GraalVM native build plugin too old for Gradle 9 (org.graalvm.buildtools.native:0.9.28)

    Details

    Problem: The native-image plugin pinned in dd-smoke-tests/spring-boot-3.0-native/application/build.gradle calls LenientConfiguration.getArtifacts(Spec), an overload that was removed in Gradle 9.

    Error: (from the nested ./gradlew nativeCompile invocation in springNativeBuild)

    Could not determine the dependencies of task ':nativeCompile'.
    > Failed to notify dependency resolution listener.
       > 'java.util.Set org.gradle.api.artifacts.LenientConfiguration.getArtifacts(org.gradle.api.specs.Spec)'
    

    Affected jobs: test_smoke_graalvm: [graalvm17], [graalvm21], [graalvm25]

    Fix: bump org.graalvm.buildtools.native from 0.9.28 to a Gradle-9-compatible release (≥ 0.10.6).

    File: dd-smoke-tests/spring-boot-3.0-native/application/build.gradle:5


References

bric3 and others added 3 commits January 14, 2026 17:14
Update from 9.3.0-rc-3 to the official 9.3.0 release.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- TestJvmSpec.kt: Use `project.objects.property()` instead of
  `project.providers.provider { null }` for empty provider values
  (provider API changes in Gradle 9)

- dependency-locking.gradle.kts: Wrap dependency locking in
  `pluginManager.withPlugin("java")` to avoid conflicts with
  Gradle 9's JVM Test Suite creation

- publish.gradle: Replace `SelfResolvingDependency` check with
  explicit `ExternalModuleDependency` check (deprecated API)

- benchmark-integration/build.gradle: Wrap sourceCompatibility and
  targetCompatibility in `java { }` block (required in Gradle 9)

- Update protobuf plugin from 0.8.18/0.9.4 to 0.9.6 across all
  modules using it (gRPC, protobuf instrumentations and smoke tests)

- springboot-tomcat smoke test: Update Spring Boot to 3.5.9 and
  remove obsolete `bootWarMainClassName` task

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bric3 bric3 requested review from a team as code owners January 19, 2026 12:49
@bric3 bric3 added the tag: do not merge Do not merge changes label Jan 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 19, 2026

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@bric3 bric3 marked this pull request as draft January 19, 2026 12:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

This pull request has been marked as stale because it has not had activity over the past quarter. It will be closed in 7 days if no further activity occurs. Feel free to reopen the PR if you are still working on it.

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

Labels

tag: do not merge Do not merge changes tag: stale Stale pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant