Skip to content

Commit 4596de2

Browse files
authored
CSI plugin use too configuration classpath (#9955)
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
1 parent efa3210 commit 4596de2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

buildSrc/src/main/kotlin/datadog/gradle/plugin/CallSiteInstrumentationPlugin.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,14 @@ abstract class CallSiteInstrumentationPlugin : Plugin<Project>{
228228

229229
private fun getProgramClasspath(project: Project): List<File> {
230230
val classpath = ArrayList<File>()
231-
// 1. Compilation outputs
231+
// 1. Compilation outputs - exclude latestDep and forked test variants
232232
project.tasks.withType(AbstractCompile::class.java)
233+
.filter { task -> !task.name.contains("LatestDep", ignoreCase = true) && !task.name.contains("Forked", ignoreCase = true) }
233234
.map { it.destinationDirectory.asFile.get() }
234235
.forEach(classpath::add)
235-
// 2. Compile time dependencies
236+
// 2. Compile time dependencies - exclude latestDep and forked test variants
236237
project.tasks.withType(AbstractCompile::class.java)
237-
.flatMap { it.classpath }
238-
.forEach(classpath::add)
239-
// 3. Test time dependencies
240-
project.tasks.withType(Test::class.java)
238+
.filter { task -> !task.name.contains("LatestDep", ignoreCase = true) && !task.name.contains("Forked", ignoreCase = true) }
241239
.flatMap { it.classpath }
242240
.forEach(classpath::add)
243241
return classpath

0 commit comments

Comments
 (0)