From 7396eb1c7ca74b5d3fcbaa953ff87dd1273ab4cf Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Thu, 13 Nov 2025 18:12:29 +0100 Subject: [PATCH] fix: CSI plugin use too configuration classpath The `generateCallSiteJava` task can fail when trying to resolve dependencies that have constraints, that can be set by the constraints DSL or by Dependency Locking (lockfile). Indeed `CallSiteInstrumentationPlugin`'s `getProgramClasspath()` method is collecting classpaths from **all** `AbstractCompile` tasks, including `compileLatestDepForkedTestJava` and `compileLatestDepTestJava`, which can have conflicting version constraints E.g. in javax-servlet-3.0 - testImplementation required strictly 8.2.0.v20160908 - latestDepTestImplementation wanted 9.+ - Dependency locking enforced 9.4.58.v20250814 for latestDepForkedTestCompileClasspath,latestDepForkedTestRuntimeClasspath,latestDepTestCompileClasspath,latestDepTestRuntimeClasspath (cherry picked from commit 39eef9c8059d5736f6a6a7084052fc8f62d4d9d4) --- .../gradle/plugin/CallSiteInstrumentationPlugin.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/buildSrc/src/main/kotlin/datadog/gradle/plugin/CallSiteInstrumentationPlugin.kt b/buildSrc/src/main/kotlin/datadog/gradle/plugin/CallSiteInstrumentationPlugin.kt index 40e1270dd54..ad1d97f1240 100644 --- a/buildSrc/src/main/kotlin/datadog/gradle/plugin/CallSiteInstrumentationPlugin.kt +++ b/buildSrc/src/main/kotlin/datadog/gradle/plugin/CallSiteInstrumentationPlugin.kt @@ -228,16 +228,14 @@ abstract class CallSiteInstrumentationPlugin : Plugin{ private fun getProgramClasspath(project: Project): List { val classpath = ArrayList() - // 1. Compilation outputs + // 1. Compilation outputs - exclude latestDep and forked test variants project.tasks.withType(AbstractCompile::class.java) + .filter { task -> !task.name.contains("LatestDep", ignoreCase = true) && !task.name.contains("Forked", ignoreCase = true) } .map { it.destinationDirectory.asFile.get() } .forEach(classpath::add) - // 2. Compile time dependencies + // 2. Compile time dependencies - exclude latestDep and forked test variants project.tasks.withType(AbstractCompile::class.java) - .flatMap { it.classpath } - .forEach(classpath::add) - // 3. Test time dependencies - project.tasks.withType(Test::class.java) + .filter { task -> !task.name.contains("LatestDep", ignoreCase = true) && !task.name.contains("Forked", ignoreCase = true) } .flatMap { it.classpath } .forEach(classpath::add) return classpath