Skip to content

Conversation

@bric3
Copy link
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.

Issues Fixed

1. Provider API Changes (TestJvmSpec.kt)

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


2. Dependency Locking Configuration (dd-trace-java.dependency-locking.gradle.kts)

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


3. SelfResolvingDependency API Removal (publish.gradle)

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


4. sourceCompatibility/targetCompatibility Configuration (benchmark-integration/build.gradle)

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


5. Protobuf Gradle Plugin Updates

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

6. Configuration Creation Order (log4j-1.2.4/build.gradle)

Commit: (this session)

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


7. Bnd Plugin Compatibility (osgi/build.gradle)

Commit: (this session)

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.1

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


8. Project.exec() Removal (version.gradle)

Commit: (this session)

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


9. Protobuf Generated Source Path Change

Commit: (this session)

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

Blocking Issue: Spring Boot 2.x Incompatibility

Problem Description

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.


Options

Option 1: Stay on Gradle 8.x

Description: Do not upgrade to Gradle 9 until smoke tests can be migrated to Spring Boot 3.5+.

Pros Cons
No code changes required Cannot benefit from Gradle 9 improvements
All smoke tests continue to work Delays adoption of latest Gradle features

Option 2: Migrate Smoke Tests to Jakarta EE

Description: Update all affected smoke tests to use Spring Boot 3.5+ and migrate javax.* imports to jakarta.*.

Pros Cons
Full Gradle 9 compatibility Significant effort (~14 modules)
Keeps tests on supported Spring Boot versions Changes test behavior (different Spring Boot version)
Requires Java 17+ (breaks Java 8/11 testing)

Migration steps per module:

  1. Update Spring Boot plugin version to 3.5.9
  2. Update sourceCompatibility to Java 17+
  3. Replace all javax.servlet.*jakarta.servlet.*
  4. Replace all javax.persistence.*jakarta.persistence.*
  5. Update any other Java EE dependencies

Option 3: Exclude Smoke Tests from Gradle 9 Build

Description: Configure the build to skip affected smoke tests when using Gradle 9.

Pros Cons
Quick to implement Reduced test coverage in Gradle 9 builds
Core library builds with Gradle 9 Maintenance complexity (two Gradle versions)

Option 4: Hybrid Approach

Description:

  1. Keep Gradle 8.x as the primary build for now
  2. Preserve all Gradle 9 fixes (already done)
  3. Plan Jakarta EE migration as a separate initiative
  4. Upgrade to Gradle 9 after migration is complete
Pros Cons
Incremental approach Delayed Gradle 9 adoption
Fixes are ready for future use
No immediate disruption

Recommendations

Timeline Action
Short-term Revert to Gradle 8.x for the main build
Medium-term Plan and execute Jakarta EE migration for smoke tests
Long-term Upgrade to Gradle 9 after migration is complete

The Gradle 9 compatibility fixes documented in this report should be preserved as they will be needed once the Jakarta EE migration is complete.


Summary of All Files Changed

From commit 23f79d6821 (to preserve):

File Change
buildSrc/.../TestJvmSpec.kt Provider API fix
buildSrc/.../dd-trace-java.dependency-locking.gradle.kts withPlugin wrapper
gradle/publish.gradle SelfResolvingDependency removal
dd-java-agent/benchmark-integration/build.gradle java {} block
dd-java-agent/agent-iast/build.gradle protobuf plugin 0.9.6
dd-java-agent/instrumentation/grpc-1.5/build.gradle protobuf plugin 0.9.6
dd-java-agent/instrumentation/armeria/armeria-grpc-0.84/build.gradle protobuf plugin 0.9.6
dd-java-agent/instrumentation/protobuf-3.0/build.gradle protobuf plugin 0.9.6
dd-smoke-tests/springboot-grpc/build.gradle protobuf plugin 0.9.6
dd-smoke-tests/grpc-1.5/build.gradle protobuf plugin 0.9.6
dd-smoke-tests/armeria-grpc/build.gradle protobuf plugin 0.9.6
dd-smoke-tests/armeria-grpc/application/build.gradle protobuf plugin 0.9.6

From this session (to preserve):

File Change
dd-java-agent/instrumentation/log4j/log4j-1.2.4/build.gradle Configuration order fix
dd-smoke-tests/osgi/build.gradle Bnd plugin 7.2.1
gradle/version.gradle ExecOperations injection
dd-java-agent/agent-iast/build.gradle Protobuf sources path
dd-java-agent/instrumentation/protobuf-3.0/build.gradle Protobuf sources path

Spring Boot version changes (reverted - do not use with Gradle 9):

All smoke tests have been reverted to their original Spring Boot 2.x versions since upgrading to 3.5.9 requires jakarta namespace migration.


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
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
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants