Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
3866a54
Bump Groovy: 3.0.24 -> 4.0.28
AlexeyKuznetsov-DD Oct 13, 2025
f128d3c
WIP
AlexeyKuznetsov-DD Oct 13, 2025
9dffccd
WIP 2
AlexeyKuznetsov-DD Oct 13, 2025
d88be22
WIP 3
AlexeyKuznetsov-DD Oct 13, 2025
51da522
WIP 4
AlexeyKuznetsov-DD Oct 13, 2025
fb2f81e
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 21, 2025
af5d06d
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 21, 2025
765fd92
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 22, 2025
1ca9595
Spotbugs tweaks.
AlexeyKuznetsov-DD Oct 22, 2025
226a2c5
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 22, 2025
a429354
WIP tweaks
AlexeyKuznetsov-DD Oct 23, 2025
ad15665
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Oct 25, 2025
8fdf26b
Fixed Groovy ambiguity. Tweaked
AlexeyKuznetsov-DD Oct 25, 2025
e687aa9
Build workaround.
AlexeyKuznetsov-DD Oct 25, 2025
6da67dd
Fixed Groovy compiler settings.
AlexeyKuznetsov-DD Oct 25, 2025
69ccd4a
Fixed Groovy compiler settings.
AlexeyKuznetsov-DD Oct 25, 2025
7c04a1c
Fixed Groovy compiler settings.
AlexeyKuznetsov-DD Oct 25, 2025
5b73524
Refactored Groovy compiler config. Disabled module `:dd-smoke-tests:s…
AlexeyKuznetsov-DD Oct 25, 2025
7a0bd21
Tests fixed.
AlexeyKuznetsov-DD Oct 25, 2025
e863a91
Revert some code. Ignore tests.
AlexeyKuznetsov-DD Oct 26, 2025
76dcdd8
Fixed tests. Ignore tests.
AlexeyKuznetsov-DD Oct 26, 2025
ca64f39
Ignore tests.
AlexeyKuznetsov-DD Oct 26, 2025
27c46bc
Ignore tests
AlexeyKuznetsov-DD Oct 26, 2025
ba98146
Ignore tests.
AlexeyKuznetsov-DD Oct 26, 2025
2b04db3
Tweaking Groovy setup.
AlexeyKuznetsov-DD Oct 26, 2025
612eae0
Tweaking build.
AlexeyKuznetsov-DD Oct 27, 2025
0196afe
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 5, 2025
0cf4bb1
Fixed Groovy compiler settings.
AlexeyKuznetsov-DD Nov 5, 2025
97a76dc
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 6, 2025
d3d8f43
Fixed build.
AlexeyKuznetsov-DD Nov 6, 2025
be3215f
Fixed build.
AlexeyKuznetsov-DD Nov 6, 2025
7ebb3db
Fixed tests.
AlexeyKuznetsov-DD Nov 6, 2025
d03fee4
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 7, 2025
bf02b3f
Fixed tests.
AlexeyKuznetsov-DD Nov 7, 2025
9a038e9
Fixed tests.
AlexeyKuznetsov-DD Nov 7, 2025
7b7df33
JUnit works only with Groovy 4.0.26 (Same as Spock)
AlexeyKuznetsov-DD Nov 7, 2025
e9128d5
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 7, 2025
f3152e3
Merged with master
AlexeyKuznetsov-DD Nov 10, 2025
df4602c
Fixed `:dd-smoke-tests:gradle` module tests.
AlexeyKuznetsov-DD Nov 10, 2025
aa5bcbf
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 12, 2025
9352e18
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 12, 2025
aa1c447
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 13, 2025
d5952a9
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 17, 2025
c05bf3c
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 18, 2025
0c6a9a4
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 18, 2025
4fedc8f
Refactored groovy and spock configuration to plugin.
AlexeyKuznetsov-DD Nov 20, 2025
7d882b5
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 20, 2025
a9856a1
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 20, 2025
17998ec
Added missing objenesis
AlexeyKuznetsov-DD Nov 21, 2025
6a4b28a
Fixed tests and refactored configurations.
AlexeyKuznetsov-DD Nov 21, 2025
8b8ba20
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 21, 2025
6d030ce
All spock dependencies should be in `groovySpock` config.
AlexeyKuznetsov-DD Nov 21, 2025
314ba85
Minor fix
AlexeyKuznetsov-DD Nov 21, 2025
5af7b01
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 21, 2025
a647df7
Cleanup.
AlexeyKuznetsov-DD Nov 21, 2025
7ff5d91
Merge branch 'master' into alexeyk/groovy-4
AlexeyKuznetsov-DD Nov 24, 2025
c692c4b
Bump Groovy and Spock versions.
AlexeyKuznetsov-DD Nov 24, 2025
6c13302
Reverted version of Groovy and Spock, to prev version.
AlexeyKuznetsov-DD Nov 24, 2025
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
14 changes: 8 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ import com.diffplug.gradle.spotless.SpotlessExtension
import datadog.gradle.plugin.ci.testAggregate

plugins {
id("datadog.gradle-debug")
kotlin("jvm") version libs.versions.kotlin.plugin apply false

id("datadog.ci-jobs")
id("datadog.config-inversion-linter")
id("datadog.dependency-locking")
id("datadog.tracer-version")
id("datadog.dump-hanged-test")
id("config-inversion-linter")
id("datadog.ci-jobs")
id("datadog.gradle-debug")
id("datadog.groovy-spock")
id("datadog.tracer-version")

id("com.diffplug.spotless") version "6.13.0"
id("com.github.spotbugs") version "5.0.14"
id("com.gradleup.shadow") version "8.3.6" apply false
id("de.thetaphi.forbiddenapis") version "3.8"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("com.gradleup.shadow") version "8.3.6" apply false
id("me.champeau.jmh") version "0.7.3" apply false
id("org.gradle.playframework") version "0.13" apply false
kotlin("jvm") version libs.versions.kotlin.plugin apply false
}

description = "dd-trace-java"
Expand Down
48 changes: 30 additions & 18 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,47 @@ java {
}

gradlePlugin {
// Sorted list of plugins:
plugins {
create("instrument-plugin") {
id = "instrument"
implementationClass = "InstrumentPlugin"
}
create("muzzle-plugin") {
id = "muzzle"
implementationClass = "datadog.gradle.plugin.muzzle.MuzzlePlugin"
}
create("call-site-instrumentation-plugin") {
id = "call-site-instrumentation"
implementationClass = "datadog.gradle.plugin.csi.CallSiteInstrumentationPlugin"
}
create("tracer-version-plugin") {
id = "datadog.tracer-version"
implementationClass = "datadog.gradle.plugin.version.TracerVersionPlugin"
}

create("dump-hanged-test-plugin") {
id = "datadog.dump-hanged-test"
implementationClass = "datadog.gradle.plugin.dump.DumpHangedTestPlugin"
}

create("groovy-spock-plugin") {
id = "datadog.groovy-spock"
implementationClass = "datadog.gradle.plugin.config.groovy.GroovySpockConventionPlugin"
}

create("instrument-plugin") {
id = "instrument"
implementationClass = "InstrumentPlugin"
}

create("muzzle-plugin") {
id = "muzzle"
implementationClass = "datadog.gradle.plugin.muzzle.MuzzlePlugin"
}

create("supported-config-generation") {
id = "supported-config-generator"
id = "datadog.supported-config-generator"
implementationClass = "datadog.gradle.plugin.config.SupportedConfigPlugin"
}

create("supported-config-linter") {
id = "config-inversion-linter"
id = "datadog.config-inversion-linter"
implementationClass = "datadog.gradle.plugin.config.ConfigInversionLinter"
}

create("tracer-version-plugin") {
id = "datadog.tracer-version"
implementationClass = "datadog.gradle.plugin.version.TracerVersionPlugin"
}
}
}

Expand Down Expand Up @@ -76,6 +88,10 @@ dependencies {
implementation("com.fasterxml.jackson.core:jackson-core")

compileOnly(libs.develocity)

// We have to use Spock with Groovy3 as Gradle 8.x bundled with Groovy3.
// TODO: We can refactor `buildSrc` folder to not use Groovy at all.
testImplementation(libs.spock.core.groovy3)
}

tasks.compileKotlin {
Expand All @@ -86,10 +102,6 @@ testing {
@Suppress("UnstableApiUsage")
suites {
val test by getting(JvmTestSuite::class) {
dependencies {
implementation(libs.groovy)
implementation(libs.spock.core)
}
targets.configureEach {
testTask.configure {
enabled = project.hasProperty("runBuildSrcTests")
Expand Down
7 changes: 4 additions & 3 deletions buildSrc/call-site-instrumentation-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ dependencies {
implementation("org.freemarker", "freemarker", "2.3.30")
implementation(libs.asm)
implementation(libs.asm.tree)
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")
implementation(libs.javaparser.solver)

testImplementation(libs.bytebuddy)
testImplementation(libs.groovy)
testImplementation(libs.bundles.spock)
testImplementation(libs.groovy4)
testImplementation(libs.spock.core.groovy4)
testImplementation(libs.objenesis)
testImplementation("javax.servlet", "javax.servlet-api", "3.0.1")
testImplementation("com.github.spotbugs", "spotbugs-annotations", "4.2.0")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package datadog.gradle.plugin.config.groovy

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.plugins.JavaLibraryPlugin
import org.gradle.api.plugins.JavaPlugin

@Suppress("unused")
class GroovySpockConventionPlugin : Plugin<Project> {
override fun apply(project: Project) {
if (project == project.rootProject) {
project.subprojects {
this.pluginManager.apply(GroovySpockConventionPlugin::class.java)
}
return
}

val extension = project.extensions.create("groovySpock", GroovySpockExtension::class.java)

project.plugins.withType(JavaPlugin::class.java) {
configure(project, extension)
}

project.plugins.withType(JavaLibraryPlugin::class.java) {
configure(project, extension)
}
}

private fun configure(
project: Project,
extension: GroovySpockExtension
) {
// TODO: check `afterEvaluate` is really needed.
project.afterEvaluate {
val groovyAlias = when (val groovyVersion = extension.groovyVersion.get()) {
3 -> "groovy3"
4 -> "groovy4"
else -> error("Unsupported groovyVersion=$groovyVersion (only 3 or 4 supported)")
}

val catalogs = project.extensions.getByType(VersionCatalogsExtension::class.java).named("libs")

fun findLibrary(alias: String) = catalogs.findLibrary(alias)
.orElseThrow { IllegalArgumentException("Library not found in catalog for alias: $alias") }

val defaultLibs = listOf(
findLibrary(groovyAlias),
findLibrary("$groovyAlias-json"),
findLibrary("spock-core-$groovyAlias"),
findLibrary("objenesis")
)

fun configureDependencies(cfg: String, deps: List<Any>) =
deps.forEach { project.dependencies.add(cfg, it) }

val configurations = extension.configurations

if (configurations.isEmpty()) {
// If nothing configured, setup default configuration, suitable in most cases.
configureDependencies("testImplementation", defaultLibs)
} else {
configurations.forEach { (cfg, deps) ->
configureDependencies(cfg, defaultLibs)
deps.forEach { project.dependencies.add(cfg, it) }
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package datadog.gradle.plugin.config.groovy

import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Property
import java.util.concurrent.ConcurrentHashMap
import javax.inject.Inject

/**
* Configuration for Groovy and Spock.
*/
abstract class GroovySpockExtension @Inject constructor(
objects: ObjectFactory
) {
internal val configurations: MutableMap<String, MutableList<Any>> = ConcurrentHashMap()

internal val groovyVersion: Property<Int> =
objects.property(Int::class.java)
.convention(4)

fun groovyVersion(version: Int) {
groovyVersion.set(version)
}

fun configureDependencies(taskName: String, vararg dependencies: Any) {
configurations.computeIfAbsent(taskName) { mutableListOf() }.addAll(dependencies)
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"

groovySpock {
configureDependencies("compileOnly")
}

dependencies {
api project(':dd-java-agent:instrumentation-testing')
api project(':dd-java-agent:agent-ci-visibility:civisibility-test-fixtures')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"

groovySpock {
configureDependencies("compileOnly")
}

dependencies {
api project(':dd-java-agent:agent-ci-visibility')
api project(':dd-java-agent:testing')
Expand All @@ -11,5 +15,7 @@ dependencies {
api libs.jackson.databind
api group: 'org.msgpack', name: 'jackson-dataformat-msgpack', version: '0.9.6'
api group: 'org.xmlunit', name: 'xmlunit-core', version: '2.10.3'

compileOnly libs.junit.jupiter
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import datadog.trace.api.DDSpanTypes
import datadog.trace.api.civisibility.config.LibraryCapability
import datadog.trace.api.civisibility.config.TestFQN
import datadog.trace.core.DDSpan
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import freemarker.core.Environment
import freemarker.core.InvalidReferenceException
import freemarker.template.Template
Expand Down Expand Up @@ -367,6 +368,7 @@ abstract class CiVisibilityTestUtils {
return compiledPaths
}

@SuppressFBWarnings("UPM_UNCALLED_PRIVATE_METHOD")
private static DynamicPath path(String rawPath, boolean unique = true) {
return new DynamicPath(rawPath, JsonPath.compile(rawPath), unique)
}
Expand Down
5 changes: 4 additions & 1 deletion dd-java-agent/agent-iast/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ protobuf {
}
}

groovySpock {
configureDependencies("testImplementation", libs.groovy4.yaml)
}

dependencies {
api libs.slf4j

Expand All @@ -50,7 +54,6 @@ dependencies {
testImplementation project(':dd-java-agent:agent-bootstrap')
testImplementation libs.bytebuddy
testImplementation('org.skyscreamer:jsonassert:1.5.1')
testImplementation libs.groovy.yaml
testImplementation libs.guava

testImplementation group: 'io.grpc', name: 'grpc-core', version: grpcVersion
Expand Down
4 changes: 4 additions & 0 deletions dd-java-agent/agent-iast/iast-test-fixtures/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"

groovySpock {
configureDependencies("compileOnly")
}

dependencies {
api project(':dd-java-agent:agent-iast')
api project(':dd-java-agent:instrumentation-testing')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.datadog.iast.taint

import datadog.trace.test.util.DDSpecification
import groovy.transform.CompileStatic
import spock.lang.IgnoreIf
import spock.lang.Shared

Expand Down Expand Up @@ -51,6 +52,7 @@ class HashCodeTest extends DDSpecification {
}
}

@CompileStatic // Workaround to avoid NPE in Groovy 4 `org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache()` method.
private static List<Integer> genHashCodes(final int n) {
(1..n).collect {
System.identityHashCode(Double.toString(Math.random()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package com.datadog.iast.taint

import static TaintedMap.POSITIVE_MASK

import groovy.transform.CompileStatic

/**
* Generate objects to test {@link TaintedMap}.
*/
@CompileStatic // Workaround to avoid java.lang.AbstractMethodError with Groovy 4.
class ObjectGen {

final int capacity
Expand Down Expand Up @@ -36,7 +39,8 @@ class ObjectGen {
}
}

def genBucket(int nObjects, Closure<Boolean> isValid) {
// Have to return specific type to avoid java.lang.AbstractMethodError with Groovy 4.
List<Object> genBucket(int nObjects, Closure<Boolean> isValid) {
assert nObjects > 0
while (true) {
for (int i = 0; i < capacity; i++) {
Expand Down
6 changes: 6 additions & 0 deletions dd-java-agent/appsec/appsec-test-fixtures/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"

groovySpock {
configureDependencies("compileOnly")
}

dependencies {
api project(':dd-java-agent:appsec')
api project(':dd-java-agent:instrumentation-testing')

compileOnly(libs.junit.jupiter)
}

configurations.named('api') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,8 @@ class WAFModuleSpecification extends DDSpecification {
stackTrace.language == 'java'
stackTrace.message == 'Exploit detected'
stackTrace.frames.size() >= 1
stackTrace.frames[0].class_name == 'org.codehaus.groovy.runtime.callsite.CallSiteArray'
stackTrace.frames[0].function == 'defaultCall'
stackTrace.frames[0].class_name == 'org.codehaus.groovy.vmplugin.v8.IndyInterface' // With Groovy 3 it was 'org.codehaus.groovy.runtime.callsite.CallSiteArray'
stackTrace.frames[0].function == 'fromCache' // With Groovy 3 it was 'defaultCall'

}

Expand Down
7 changes: 6 additions & 1 deletion dd-java-agent/instrumentation-testing/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
apply from: "$rootDir/gradle/java.gradle"

groovySpock {
configureDependencies("compileOnly")
configureDependencies("testImplementation")
}

dependencies {
api libs.bytebuddy
api libs.bytebuddyagent
api libs.slf4j
api libs.bundles.spock
api libs.bundles.test.logging
api libs.guava

api project(':dd-java-agent:testing')

implementation project(':dd-java-agent:agent-debugger')

implementation(libs.junit.jupiter)
implementation "org.junit.platform:junit-platform-runner:${libs.versions.junit.platform.get()}"

testImplementation project(':dd-java-agent:instrumentation:trace-annotation')
Expand Down
Loading
Loading