From c1984ee11154ca45fece267c22868f7fd47dcf99 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Sun, 25 Aug 2024 13:57:55 +0200 Subject: [PATCH 01/22] Decouple gradle JDK from compile/test JDK --- dd-java-agent/agent-bootstrap/build.gradle | 4 +- dd-java-agent/agent-builder/build.gradle | 2 +- dd-java-agent/agent-iast/build.gradle | 19 +- .../profiling-controller-jfr/build.gradle | 2 + .../exception-profiling/build.gradle | 4 + dd-smoke-tests/armeria-grpc/build.gradle | 3 +- dd-smoke-tests/build.gradle | 4 + dd-smoke-tests/iast-util/build.gradle | 4 + dd-smoke-tests/java9-modules/build.gradle | 7 +- dd-smoke-tests/play-2.4/build.gradle | 8 + dd-smoke-tests/play-2.5/build.gradle | 8 + .../datadog/smoketest/ProcessManager.groovy | 1 + dd-smoke-tests/vertx-3.4/build.gradle | 3 +- gradle/java_no_deps.gradle | 225 ++++++++++++------ internal-api/build.gradle | 11 +- 15 files changed, 199 insertions(+), 106 deletions(-) diff --git a/dd-java-agent/agent-bootstrap/build.gradle b/dd-java-agent/agent-bootstrap/build.gradle index 6e5ed6223de..e8e52d82934 100644 --- a/dd-java-agent/agent-bootstrap/build.gradle +++ b/dd-java-agent/agent-bootstrap/build.gradle @@ -6,7 +6,7 @@ plugins { ext { // need access to sun.* packages - skipSettingCompilerRelease = true + defaultJdkVersion = 8 } apply from: "$rootDir/gradle/java.gradle" @@ -36,7 +36,7 @@ sourceSets { } } -compileMain_java11Java.configure { +tasks.named("compileMain_java11Java", JavaCompile).configure { setJavaVersion(it, 11) sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/dd-java-agent/agent-builder/build.gradle b/dd-java-agent/agent-builder/build.gradle index d014ee79196..833a36969c4 100644 --- a/dd-java-agent/agent-builder/build.gradle +++ b/dd-java-agent/agent-builder/build.gradle @@ -19,7 +19,7 @@ sourceSets { } } -compileMain_java11Java.configure { +tasks.named("compileMain_java11Java", JavaCompile).configure { setJavaVersion(it, 11) sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/dd-java-agent/agent-iast/build.gradle b/dd-java-agent/agent-iast/build.gradle index cd061eb23fa..592ea61b986 100644 --- a/dd-java-agent/agent-iast/build.gradle +++ b/dd-java-agent/agent-iast/build.gradle @@ -8,21 +8,14 @@ plugins { id 'net.ltgt.errorprone' version '3.1.0' } -apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/version.gradle" - -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } - sourceCompatibility = 1.8 - targetCompatibility = 1.8 +ext { + defaultJdkVersion = 11 + defaultJavaVersion = 8 + defaultJavaCompilerRelease = 8 } -tasks.withType(AbstractCompile).configureEach { - // ensure no APIs beyond JDK8 are used - options.release = 8 -} +apply from: "$rootDir/gradle/java.gradle" +apply from: "$rootDir/gradle/version.gradle" // First version with Mac M1 support def grpcVersion = '1.42.2' diff --git a/dd-java-agent/agent-profiling/profiling-controller-jfr/build.gradle b/dd-java-agent/agent-profiling/profiling-controller-jfr/build.gradle index 6075335d867..0e8b90b1a68 100644 --- a/dd-java-agent/agent-profiling/profiling-controller-jfr/build.gradle +++ b/dd-java-agent/agent-profiling/profiling-controller-jfr/build.gradle @@ -5,6 +5,8 @@ ext { minJavaVersionForTests = JavaVersion.VERSION_11 // need access to jdk.jfr package + defaultJdkVersion = 11 + defaultJavaVersion = 8 skipSettingCompilerRelease = true excludeJdk = ['SEMERU11', 'SEMERU17'] diff --git a/dd-java-agent/instrumentation/exception-profiling/build.gradle b/dd-java-agent/instrumentation/exception-profiling/build.gradle index 3158abca382..a475c3f59ca 100644 --- a/dd-java-agent/instrumentation/exception-profiling/build.gradle +++ b/dd-java-agent/instrumentation/exception-profiling/build.gradle @@ -5,6 +5,10 @@ ext { // By default tests with be compiled for `minJavaVersionForTests` version, // but in this case we would like to avoid this since we would like to run with ZULU8 skipSettingTestJavaVersion = true + + defaultJdkVersion = 11 + defaultJavaVersion = 8 + skipSettingCompilerRelease = true } apply from: "$rootDir/gradle/java.gradle" diff --git a/dd-smoke-tests/armeria-grpc/build.gradle b/dd-smoke-tests/armeria-grpc/build.gradle index 34269915845..2e6d8f883f1 100644 --- a/dd-smoke-tests/armeria-grpc/build.gradle +++ b/dd-smoke-tests/armeria-grpc/build.gradle @@ -3,6 +3,7 @@ plugins { } ext { + defaultJdkVersion = 17 minJavaVersionForTests = JavaVersion.VERSION_17 } @@ -44,8 +45,8 @@ dependencies { implementation 'io.grpc:grpc-protobuf:1.56.0' implementation 'io.grpc:grpc-stub:1.56.0' + compileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+ testRuntimeOnly 'io.grpc:grpc-netty-shaded:1.56.0' - testCompileOnly 'org.apache.tomcat:annotations-api:6.0.53' // necessary for Java 9+ testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } diff --git a/dd-smoke-tests/build.gradle b/dd-smoke-tests/build.gradle index b53825da025..ec28d6f305c 100644 --- a/dd-smoke-tests/build.gradle +++ b/dd-smoke-tests/build.gradle @@ -1,3 +1,7 @@ +ext { + defaultJdkVersion = 8 +} + apply from: "$rootDir/gradle/java.gradle" description = 'dd-smoke-tests' diff --git a/dd-smoke-tests/iast-util/build.gradle b/dd-smoke-tests/iast-util/build.gradle index ab33dca3efd..41127b32990 100644 --- a/dd-smoke-tests/iast-util/build.gradle +++ b/dd-smoke-tests/iast-util/build.gradle @@ -2,6 +2,10 @@ plugins { id 'java-test-fixtures' } +ext { + defaultJdkVersion = 8 +} + apply from: "$rootDir/gradle/java.gradle" description = 'iast-smoke-tests-utils' diff --git a/dd-smoke-tests/java9-modules/build.gradle b/dd-smoke-tests/java9-modules/build.gradle index b5698701ba1..920e6310242 100644 --- a/dd-smoke-tests/java9-modules/build.gradle +++ b/dd-smoke-tests/java9-modules/build.gradle @@ -1,4 +1,7 @@ ext { + defaultJdkVersion = 11 + defaultJavaVersion = 11 + defaultJavaCompilerRelease = 11 minJavaVersionForTests = JavaVersion.VERSION_11 } @@ -10,12 +13,8 @@ jar { } } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - [JavaCompile, GroovyCompile].each { tasks.withType(it).configureEach { AbstractCompile ac -> - setJavaVersion(ac, 11) // read up classpath lazily to avoid early locking of gradle settings ac.options.compilerArgumentProviders.add(new CommandLineArgumentProvider() { @Override diff --git a/dd-smoke-tests/play-2.4/build.gradle b/dd-smoke-tests/play-2.4/build.gradle index cbb2a0d97cf..b65de33a80d 100644 --- a/dd-smoke-tests/play-2.4/build.gradle +++ b/dd-smoke-tests/play-2.4/build.gradle @@ -3,6 +3,7 @@ plugins { } ext { + defaultJdkVersion = 8 // TODO Java 17: This version of play doesn't support Java 17 maxJavaVersionForTests = JavaVersion.VERSION_15 } @@ -12,6 +13,13 @@ apply from: "$rootDir/gradle/java.gradle" def playVer = "2.4.11" def scalaVer = System.getProperty("scala.binary.version", /* default = */ "2.11") +java { + toolchain { + // ScalaPlugin won't pick up another JDK unless specified with a toolchain. + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + play { platform { playVersion = playVer diff --git a/dd-smoke-tests/play-2.5/build.gradle b/dd-smoke-tests/play-2.5/build.gradle index 55b187fb769..f4028c62b39 100644 --- a/dd-smoke-tests/play-2.5/build.gradle +++ b/dd-smoke-tests/play-2.5/build.gradle @@ -3,6 +3,7 @@ plugins { } ext { + defaultJdkVersion = 8 // TODO Java 17: This version of play doesn't support Java 17 maxJavaVersionForTests = JavaVersion.VERSION_15 } @@ -12,6 +13,13 @@ apply from: "$rootDir/gradle/java.gradle" def playVer = "2.5.19" def scalaVer = System.getProperty("scala.binary.version", /* default = */ "2.11") +java { + toolchain { + // ScalaPlugin won't pick up another JDK unless specified with a toolchain. + languageVersion.set(JavaLanguageVersion.of(8)) + } +} + play { platform { playVersion = playVer diff --git a/dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy b/dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy index fdcc9db82be..9dcb0844b6c 100644 --- a/dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy +++ b/dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy @@ -78,6 +78,7 @@ abstract class ProcessManager extends Specification { @AutoCleanup OutputThreads outputThreads = new OutputThreads() + @CompileStatic class OutputThreads implements Closeable { final ThreadGroup tg = new ThreadGroup("smoke-output") final List testLogMessages = new ArrayList<>() diff --git a/dd-smoke-tests/vertx-3.4/build.gradle b/dd-smoke-tests/vertx-3.4/build.gradle index 2ee69edf538..8cbcab8ffbd 100644 --- a/dd-smoke-tests/vertx-3.4/build.gradle +++ b/dd-smoke-tests/vertx-3.4/build.gradle @@ -17,7 +17,8 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' // define the task that builds the quarkus project tasks.register('vertxBuild', Exec) { workingDir "$appDir" - environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'"] + def toolchain8 = getJavaLauncherFor(8).get() + environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", "JAVA_HOME": "$toolchain8.metadata.installationPath"] commandLine "$appDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" outputs.cacheIf { true } diff --git a/gradle/java_no_deps.gradle b/gradle/java_no_deps.gradle index 95a87f0e8ed..78731c04e9a 100644 --- a/gradle/java_no_deps.gradle +++ b/gradle/java_no_deps.gradle @@ -1,5 +1,31 @@ import org.gradle.jvm.toolchain.internal.SpecificInstallationToolchainSpec +if (!project.hasProperty("skipSettingCompilerRelease")) { + ext { + skipSettingCompilerRelease = false + } +} +if (!project.hasProperty("defaultJdkVersion")) { + ext { + defaultJdkVersion = 8 + } +} +if (!project.hasProperty("defaultJavaCompilerRelease")) { + ext { + defaultJavaCompilerRelease = 8 + } +} +if (!project.hasProperty("defaultJavaVersion")) { + ext { + defaultJavaVersion = 8 + } +} +// TODO: add human readable messages including project path to these asserts +if (!project.skipSettingCompilerRelease) { + assert project.defaultJavaCompilerRelease <= project.defaultJdkVersion +} +assert project.defaultJavaVersion <= project.defaultJdkVersion + apply plugin: 'java-library' apply from: "$rootDir/gradle/codenarc.gradle" @@ -37,12 +63,79 @@ if (applyCodeCoverage) { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 -// when building with Java 9+, lazily set compiler --release flag to match target -def skipSettingCompilerRelease = project.findProperty('skipSettingCompilerRelease') -if (!skipSettingCompilerRelease && JavaVersion.current().isJava9Compatible()) { - compileJava.options.release = project.provider { - JavaVersion.toVersion(targetCompatibility).majorVersion as Integer +ext.setJavaVersion = (it, javaVersionInteger) -> { + // TODO: kotlin support? + AbstractCompile ac = (AbstractCompile) it + Provider compiler = javaToolchains.compilerFor { + languageVersion = JavaLanguageVersion.of(javaVersionInteger) + } + try { + //ac.configure { + it.options.fork = true + if (it.hasProperty('javaCompiler')) { + // Works for JavaCompile + it.javaCompiler = compiler + } else { + // Works for GroovyCompile and ScalaCompile + it.options.forkOptions.javaHome = compiler.get().metadata.installationPath.asFile + } + //} + } catch (NoSuchElementException ignored) { + throw new GradleException("Unable to find compiler for Java $javaVersionInteger. Have you set JAVA_${javaVersionInteger}_HOME?") + } +} as Closure + +ext.getJavaLauncherFor = (javaVersionInteger) -> { + def launcher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(javaVersionInteger) + } + if (!launcher.present) { + throw new GradleException("Unable to find launcher for Java $javaVersionInteger. Have you set JAVA_${javaVersionInteger}_HOME?") + } + return launcher +} as Closure> + +def isJavaVersionAllowedForProperty(JavaVersion version, String propertyPrefix = "") { + def minProp = propertyPrefix.isEmpty() ? 'minJavaVersionForTests' : "${propertyPrefix}MinJavaVersionForTests" + def maxProp = propertyPrefix.isEmpty() ? 'maxJavaVersionForTests' : "${propertyPrefix}MaxJavaVersionForTests" + def definedMin = project.hasProperty(minProp) + def definedMax = project.hasProperty(maxProp) + if (definedMin && project.getProperty(minProp).compareTo(version) > 0) { + return false + } + //default to the general min if defined and specific one is was not defined + if (!propertyPrefix.isEmpty() && !definedMin && project.hasProperty('minJavaVersionForTests') && project.getProperty('minJavaVersionForTests').compareTo(version) > 0) { + return false + } + if (definedMax && project.getProperty(maxProp).compareTo(version) < 0) { + return false + } + if (!propertyPrefix.isEmpty() && !definedMax && project.hasProperty('maxJavaVersionForTests') && project.getProperty('maxJavaVersionForTests').compareTo(version) < 0) { + return false } + return true +} + +def isJavaVersionAllowed(JavaVersion version, String testTaskName) { + return isJavaVersionAllowedForProperty(version, testTaskName) +} + +def isJavaLanguageVersionAllowed(JavaLanguageVersion languageVersion, String testTaskName) { + def version = JavaVersion.toVersion(languageVersion.asInt()) + return isJavaVersionAllowed(version, testTaskName) +} + +def isJdkForced(String javaName) { + return (project.hasProperty('forceJdk') && project.getProperty('forceJdk').any { it.equalsIgnoreCase(javaName) }) +} + +def isJdkExcluded(String javaName) { + return (project.hasProperty('excludeJdk') && project.getProperty('excludeJdk').any { it.equalsIgnoreCase(javaName) }) +} + +def getJavaHomePath(String path) { + def javaHome = new File(path).toPath().toRealPath() + return javaHome.endsWith("jre") ? javaHome.parent : javaHome } if (project.hasProperty('minJavaVersionForTests') && project.getProperty('minJavaVersionForTests') != JavaVersion.VERSION_1_7) { @@ -54,7 +147,8 @@ if (project.hasProperty('minJavaVersionForTests') && project.getProperty('minJav } } - "compileMain_${name}Java" { + tasks.named("compileMain_${name}Java", JavaCompile).configure { + setJavaVersion(it, version.majorVersion) sourceCompatibility = version targetCompatibility = version } @@ -80,6 +174,14 @@ if (project.hasProperty('minJavaVersionForTests') && project.getProperty('minJav if (!skipSettingTestJavaVersion) { tasks.withType(JavaCompile).configureEach { if (it.name.toLowerCase().contains("test")) { + setJavaVersion(it, version.majorVersion) + sourceCompatibility = version + targetCompatibility = version + } + } + tasks.withType(GroovyCompile).configureEach { + if (it.name.toLowerCase().contains("test")) { + setJavaVersion(it, defaultJavaVersion) sourceCompatibility = version targetCompatibility = version } @@ -110,11 +212,11 @@ jar { manifest { attributes( - "Implementation-Title": project.name, - "Implementation-Version": project.version, - "Implementation-Vendor": "Datadog", - "Implementation-URL": "https://github.com/datadog/dd-trace-java", - ) + "Implementation-Title": project.name, + "Implementation-Version": project.version, + "Implementation-Vendor": "Datadog", + "Implementation-URL": "https://github.com/datadog/dd-trace-java", + ) } } @@ -185,7 +287,7 @@ project.afterEvaluate { if (javaTestLauncher) { def metadata = javaTestLauncher.get().metadata def allowedOrForced = !isJdkExcluded(testJvm) && - (isJavaLanguageVersionAllowed(metadata.languageVersion, it.name) || isJdkForced(testJvm)) + (isJavaLanguageVersionAllowed(metadata.languageVersion, it.name) || isJdkForced(testJvm)) javaLauncher = javaTestLauncher onlyIf { allowedOrForced } if (applyCodeCoverage) { @@ -265,76 +367,51 @@ if (project.hasProperty("removeJarVersionNumbers") && removeJarVersionNumbers) { } } -ext.setJavaVersion = (it, javaVersionInteger) -> { - AbstractCompile ac = (AbstractCompile) it - Provider compiler = javaToolchains.compilerFor { - languageVersion = JavaLanguageVersion.of(javaVersionInteger) - } - try { - ac.configure { - options.fork = true - if (ac.hasProperty('javaCompiler')) { - javaCompiler = compiler - } else { - options.forkOptions.javaHome = compiler.get().metadata.installationPath.asFile - } +tasks.withType(JavaCompile).configureEach { + // Skip compileMain_java\d+Java + final isJavaVersionSpecific = it.name ==~ /compileMain_java\d+Java/ + if (!isJavaVersionSpecific) { + setJavaVersion(it, defaultJdkVersion) + if (defaultJdkVersion > 8 && !skipSettingCompilerRelease) { + it.options.release = defaultJavaCompilerRelease + } else { + sourceCompatibility = defaultJavaVersion + targetCompatibility = defaultJavaVersion } - } catch (NoSuchElementException ignored) { - throw new GradleException("Unable to find compiler for Java $javaVersionInteger. Have you set JAVA_${javaVersionInteger}_HOME?") - } -} as Closure - -ext.getJavaLauncherFor = (javaVersionInteger) -> { - def launcher = javaToolchains.launcherFor { - languageVersion = JavaLanguageVersion.of(javaVersionInteger) } - if (!launcher.present) { - throw new GradleException("Unable to find launcher for Java $javaVersionInteger. Have you set JAVA_${javaVersionInteger}_HOME?") - } - return launcher -} as Closure> - -def isJavaVersionAllowedForProperty(JavaVersion version, String propertyPrefix = "") { - def minProp = propertyPrefix.isEmpty() ? 'minJavaVersionForTests' : "${propertyPrefix}MinJavaVersionForTests" - def maxProp = propertyPrefix.isEmpty() ? 'maxJavaVersionForTests' : "${propertyPrefix}MaxJavaVersionForTests" - def definedMin = project.hasProperty(minProp) - def definedMax = project.hasProperty(maxProp) - if (definedMin && project.getProperty(minProp).compareTo(version) > 0) { - return false - } - //default to the general min if defined and specific one is was not defined - if (!propertyPrefix.isEmpty() && !definedMin && project.hasProperty('minJavaVersionForTests') && project.getProperty('minJavaVersionForTests').compareTo(version) > 0) { - return false - } - if (definedMax && project.getProperty(maxProp).compareTo(version) < 0) { - return false - } - if (!propertyPrefix.isEmpty() && !definedMax && project.hasProperty('maxJavaVersionForTests') && project.getProperty('maxJavaVersionForTests').compareTo(version) < 0) { - return false - } - return true } -def isJavaVersionAllowed(JavaVersion version, String testTaskName) { - return isJavaVersionAllowedForProperty(version, testTaskName) -} - -def isJavaLanguageVersionAllowed(JavaLanguageVersion languageVersion, String testTaskName) { - def version = JavaVersion.toVersion(languageVersion.asInt()) - return isJavaVersionAllowed(version, testTaskName) -} - -def isJdkForced(String javaName) { - return (project.hasProperty('forceJdk') && project.getProperty('forceJdk').any { it.equalsIgnoreCase(javaName) }) +if (project.plugins.hasPlugin('groovy')) { + tasks.withType(GroovyCompile).configureEach { + // XXX: Apparently options.release is ignored in Groovy? So we'll just set + // the JDK to the required target version. + setJavaVersion(it, defaultJavaVersion) + sourceCompatibility = defaultJavaVersion + targetCompatibility = defaultJavaVersion + } } -def isJdkExcluded(String javaName) { - return (project.hasProperty('excludeJdk') && project.getProperty('excludeJdk').any { it.equalsIgnoreCase(javaName) }) +if (project.plugins.hasPlugin('scala')) { + tasks.withType(ScalaCompile).configureEach { + setJavaVersion(it, defaultJdkVersion) + if (defaultJdkVersion > 8 && !skipSettingCompilerRelease) { + it.options.release = defaultJavaCompilerRelease + } else { + sourceCompatibility = defaultJavaVersion + targetCompatibility = defaultJavaVersion + } + } } -def getJavaHomePath(String path) { - def javaHome = new File(path).toPath().toRealPath() - return javaHome.endsWith("jre") ? javaHome.parent : javaHome +if (project.hasProperty('extraJavaVersionSourceSets')) { + project.extraJavaVersionSourceSets.each { version -> + sourceSets.create("main_java$version") { + java.srcDirs "${project.projectDir}/src/main/java$version" + } + tasks.named("compileMain_java${version}Java").configure { + setJavaVersion(it, version) + } + } } tasks.register('testJar', Jar) { diff --git a/internal-api/build.gradle b/internal-api/build.gradle index edaaf1d860f..aac5638d4af 100644 --- a/internal-api/build.gradle +++ b/internal-api/build.gradle @@ -3,15 +3,7 @@ plugins { } ext { - // need access to sun.misc.SharedSecrets - skipSettingCompilerRelease = true -} - -// sun.misc.SharedSecrets is gone in later versions -compileJava { - javaCompiler = javaToolchains.compilerFor { - languageVersion = JavaLanguageVersion.of(8) - } + defaultJdkVersion = 8 } apply from: "$rootDir/gradle/java.gradle" @@ -260,4 +252,3 @@ jmh { jmhVersion = '1.32' duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE } - From 9f2a0de8f94024708443f5ee3ac31d8ce5e19212 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Tue, 17 Sep 2024 16:49:42 +0200 Subject: [PATCH 02/22] wip: remove spotbugs error --- .../src/main/groovy/datadog/smoketest/ProcessManager.groovy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy b/dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy index 9dcb0844b6c..200b5ee1f3d 100644 --- a/dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy +++ b/dd-smoke-tests/src/main/groovy/datadog/smoketest/ProcessManager.groovy @@ -2,6 +2,7 @@ package datadog.smoketest import datadog.trace.agent.test.utils.PortUtils import de.thetaphi.forbiddenapis.SuppressForbidden +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings import groovy.transform.CompileStatic import spock.lang.AutoCleanup import spock.lang.Shared @@ -83,6 +84,7 @@ abstract class ProcessManager extends Specification { final ThreadGroup tg = new ThreadGroup("smoke-output") final List testLogMessages = new ArrayList<>() + @SuppressFBWarnings(value = "UC_USELESS_OBJECT", justification = "Apparent false positive on threads being unused") void close() { tg.interrupt() Thread[] threads = new Thread[tg.activeCount()] From c778002cc93da6c9ac7bfccb3b4ab2a86a0c49d7 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Sat, 19 Oct 2024 00:09:29 +0200 Subject: [PATCH 03/22] wip: java 7 --- dd-java-agent/build.gradle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dd-java-agent/build.gradle b/dd-java-agent/build.gradle index 95737b79eeb..e4300be44b3 100644 --- a/dd-java-agent/build.gradle +++ b/dd-java-agent/build.gradle @@ -17,8 +17,10 @@ configurations { traceShadowInclude } -sourceCompatibility = JavaVersion.VERSION_1_7 -targetCompatibility = JavaVersion.VERSION_1_7 +tasks.named("compileJava", JavaCompile).configure { + sourceCompatibility = JavaVersion.VERSION_1_7 + targetCompatibility = JavaVersion.VERSION_1_7 +} /* * Several shadow jars are created From 53ab29ef89351d5fb614aa3c1f24252aea7ed956 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Tue, 14 Jan 2025 17:20:20 +0100 Subject: [PATCH 04/22] WIP: use JDK 11 for gradle --- .circleci/config.continue.yml.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.continue.yml.j2 b/.circleci/config.continue.yml.j2 index b563de669d9..936c5aabae8 100644 --- a/.circleci/config.continue.yml.j2 +++ b/.circleci/config.continue.yml.j2 @@ -311,6 +311,7 @@ jobs: {% if is_nightly %} ./gradlew resolveAndLockAll --write-locks && {% endif %} + JAVA_HOME="$JAVA_11_HOME" MAVEN_OPTS="-Xms64M -Xmx256M" GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2560M -Xms2560M -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'" ./gradlew clean @@ -566,6 +567,7 @@ jobs: fi << parameters.environment >> + JAVA_HOME="$JAVA_11_HOME" MAVEN_OPTS="-Xms64M -Xmx512M" GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xms<< parameters.maxDaemonHeapSize >> -Xmx<< parameters.maxDaemonHeapSize >> $PROFILER_COMMAND -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp' -Ddatadog.forkedMaxHeapSize=768M -Ddatadog.forkedMinHeapSize=128M" ./gradlew @@ -726,6 +728,7 @@ jobs: mvn_local_repo=$(./mvnw help:evaluate -Dexpression=settings.localRepository -q -DforceStdout) rm -rf "${mvn_local_repo}/com/datadoghq" export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'" + export JAVA_HOME="$JAVA_11_HOME" ./gradlew publishToMavenLocal << pipeline.parameters.gradle_flags >> --max-workers=3 - run: From 319fe15af972ade96249fb40a92ec20e0f08e3b3 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Tue, 14 Jan 2025 17:44:22 +0100 Subject: [PATCH 05/22] Fix javadoc 8 support --- gradle/java_no_deps.gradle | 10 ++++++++++ internal-api/build.gradle | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gradle/java_no_deps.gradle b/gradle/java_no_deps.gradle index 78731c04e9a..e3994a0b112 100644 --- a/gradle/java_no_deps.gradle +++ b/gradle/java_no_deps.gradle @@ -65,6 +65,12 @@ targetCompatibility = JavaVersion.VERSION_1_8 ext.setJavaVersion = (it, javaVersionInteger) -> { // TODO: kotlin support? + if (it instanceof Javadoc) { + (it as Javadoc).javadocTool = javaToolchains.javadocToolFor() { + languageVersion = JavaLanguageVersion.of(javaVersionInteger) + } + return + } AbstractCompile ac = (AbstractCompile) it Provider compiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(javaVersionInteger) @@ -381,6 +387,10 @@ tasks.withType(JavaCompile).configureEach { } } +tasks.withType(Javadoc).configureEach { + setJavaVersion(it, defaultJdkVersion) +} + if (project.plugins.hasPlugin('groovy')) { tasks.withType(GroovyCompile).configureEach { // XXX: Apparently options.release is ignored in Groovy? So we'll just set diff --git a/internal-api/build.gradle b/internal-api/build.gradle index aac5638d4af..2efe2976124 100644 --- a/internal-api/build.gradle +++ b/internal-api/build.gradle @@ -9,7 +9,7 @@ ext { apply from: "$rootDir/gradle/java.gradle" apply from: "$rootDir/gradle/tries.gradle" -tasks.compileTestJava.configure { +tasks.withType(JavaCompile).configureEach { setJavaVersion(it, 8) } From d2596fceea4c756fbd86cec7f606dc6de6f678f2 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Tue, 14 Jan 2025 17:57:22 +0100 Subject: [PATCH 06/22] Fix forbiddenApi warn for debugger --- .../src/main/java/com/datadog/debugger/probe/LogProbe.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java index 0bfa18528df..a285f8642cc 100644 --- a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java +++ b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java @@ -54,6 +54,8 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; + +import de.thetaphi.forbiddenapis.SuppressForbidden; import org.slf4j.Logger; import org.slf4j.LoggerFactory; From f28dc30065211374c6b3b2f53d09358aa25468fd Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Tue, 14 Jan 2025 19:34:40 +0100 Subject: [PATCH 07/22] WIP: forbiddenapis attempts --- gradle/java_no_deps.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle/java_no_deps.gradle b/gradle/java_no_deps.gradle index e3994a0b112..14fe2020444 100644 --- a/gradle/java_no_deps.gradle +++ b/gradle/java_no_deps.gradle @@ -29,7 +29,6 @@ assert project.defaultJavaVersion <= project.defaultJdkVersion apply plugin: 'java-library' apply from: "$rootDir/gradle/codenarc.gradle" -apply from: "$rootDir/gradle/forbiddenapis.gradle" apply from: "$rootDir/gradle/spotless.gradle" apply from: "$rootDir/gradle/spotbugs.gradle" apply from: "$rootDir/gradle/repositories.gradle" @@ -431,3 +430,5 @@ tasks.register('testJar', Jar) { } apply from: "$rootDir/gradle/configure_tests.gradle" +// Run last to pick up targetCompatibility changes +apply from: "$rootDir/gradle/forbiddenapis.gradle" From ca00a0bf62e2b2a39d7b4bfdd25c29afac6fb260 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Tue, 14 Jan 2025 21:12:06 +0100 Subject: [PATCH 08/22] WIP: attempt at forbidden apis --- .../src/main/java/com/datadog/debugger/probe/LogProbe.java | 2 -- .../trace/util/stacktrace/HotSpotStackTraceIterator.java | 2 ++ .../java/datadog/trace/util/stacktrace/HotSpotStackWalker.java | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java index a285f8642cc..0bfa18528df 100644 --- a/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java +++ b/dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/LogProbe.java @@ -54,8 +54,6 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; - -import de.thetaphi.forbiddenapis.SuppressForbidden; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/internal-api/src/main/java/datadog/trace/util/stacktrace/HotSpotStackTraceIterator.java b/internal-api/src/main/java/datadog/trace/util/stacktrace/HotSpotStackTraceIterator.java index 799079a2818..83a9b1ba106 100644 --- a/internal-api/src/main/java/datadog/trace/util/stacktrace/HotSpotStackTraceIterator.java +++ b/internal-api/src/main/java/datadog/trace/util/stacktrace/HotSpotStackTraceIterator.java @@ -1,8 +1,10 @@ package datadog.trace.util.stacktrace; +import de.thetaphi.forbiddenapis.SuppressForbidden; import java.util.Iterator; import java.util.NoSuchElementException; +@SuppressForbidden // sun.misc.JavaLangAccess public class HotSpotStackTraceIterator implements Iterator { private int index = 0; diff --git a/internal-api/src/main/java/datadog/trace/util/stacktrace/HotSpotStackWalker.java b/internal-api/src/main/java/datadog/trace/util/stacktrace/HotSpotStackWalker.java index b3b92ef3af9..28a3f127493 100644 --- a/internal-api/src/main/java/datadog/trace/util/stacktrace/HotSpotStackWalker.java +++ b/internal-api/src/main/java/datadog/trace/util/stacktrace/HotSpotStackWalker.java @@ -1,10 +1,12 @@ package datadog.trace.util.stacktrace; import datadog.trace.api.Platform; +import de.thetaphi.forbiddenapis.SuppressForbidden; import java.util.function.Function; import java.util.stream.Stream; import java.util.stream.StreamSupport; +@SuppressForbidden // sun.misc.SharedSecrets and sun.misc.JavaLangAccess public class HotSpotStackWalker extends AbstractStackWalker { sun.misc.JavaLangAccess access; From 5378632113e8cddbbcd788434a82590ffe166a3c Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Wed, 15 Jan 2025 00:11:50 +0100 Subject: [PATCH 09/22] WIP: fix kotlin --- gradle/java_no_deps.gradle | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gradle/java_no_deps.gradle b/gradle/java_no_deps.gradle index 14fe2020444..9fcbee35ee2 100644 --- a/gradle/java_no_deps.gradle +++ b/gradle/java_no_deps.gradle @@ -332,16 +332,6 @@ project.afterEvaluate { } } - if (project.plugins.hasPlugin('kotlin')) { - ['compileKotlin', 'compileTestKotlin'].each { type -> - tasks.named(type).configure { - kotlinOptions { - freeCompilerArgs += '-Xmx256m' - } - } - } - } - tasks.withType(JavaExec).configureEach { if (!it.maxHeapSize) { it.maxHeapSize('256M') @@ -349,6 +339,18 @@ project.afterEvaluate { } } +if (project.plugins.hasPlugin('kotlin')) { + ['compileKotlin', 'compileTestKotlin'].each { type -> + tasks.named(type).configure { + kotlinOptions { + freeCompilerArgs += '-Xmx256m' + // Kotlin's jvmTarget must match Java's targetCompatibility, see https://kotl.in/gradle/jvm/target-validation + jvmTarget = defaultJdkVersion == 8 ? '1.8' : defaultJavaCompilerRelease.toString() + } + } + } +} + if (project.plugins.hasPlugin('com.github.johnrengelman.shadow')) { // Remove the no-deps jar from the archives to prevent publication configurations.archives.with { From a07cb217ea7a4f53942bcc9df5bc1330981d695c Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Thu, 16 Jan 2025 20:40:39 +0100 Subject: [PATCH 10/22] jakarta-jms compile deps --- dd-java-agent/instrumentation/jakarta-jms/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dd-java-agent/instrumentation/jakarta-jms/build.gradle b/dd-java-agent/instrumentation/jakarta-jms/build.gradle index 9f3c53f4af5..92cd6d438f2 100644 --- a/dd-java-agent/instrumentation/jakarta-jms/build.gradle +++ b/dd-java-agent/instrumentation/jakarta-jms/build.gradle @@ -30,7 +30,7 @@ compileTestGroovy { dependencies { implementation project(':dd-java-agent:instrumentation:jms') - + compileOnly 'jakarta.jms:jakarta.jms-api:3.0.0' testImplementation 'jakarta.jms:jakarta.jms-api:3.0.0' testImplementation 'jakarta.ejb:jakarta.ejb-api:4.0.0' testImplementation group: 'org.springframework', name: 'spring-jms', version: '6.0.11' From 7b0832e038198380feb8527a3fd0b334ffae79f6 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Fri, 17 Jan 2025 16:51:45 +0100 Subject: [PATCH 11/22] Fix setJavaVersion for groovy --- gradle/java_no_deps.gradle | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/gradle/java_no_deps.gradle b/gradle/java_no_deps.gradle index 9fcbee35ee2..2d7a1fef248 100644 --- a/gradle/java_no_deps.gradle +++ b/gradle/java_no_deps.gradle @@ -74,17 +74,23 @@ ext.setJavaVersion = (it, javaVersionInteger) -> { Provider compiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(javaVersionInteger) } + Provider launcher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(javaVersionInteger) + } try { - //ac.configure { it.options.fork = true - if (it.hasProperty('javaCompiler')) { - // Works for JavaCompile - it.javaCompiler = compiler + if (it instanceof JavaCompile) { + JavaCompile jc = (JavaCompile) it + jc.javaCompiler = compiler + } else if (it instanceof GroovyCompile) { + GroovyCompile gc = (GroovyCompile) it + gc.javaLauncher = launcher + } else if (it instanceof ScalaCompile) { + ScalaCompile sc = (ScalaCompile) it + sc.javaLauncher = launcher } else { - // Works for GroovyCompile and ScalaCompile - it.options.forkOptions.javaHome = compiler.get().metadata.installationPath.asFile + throw new GradleException("Unsupported compile type: ${it.getClass()}") } - //} } catch (NoSuchElementException ignored) { throw new GradleException("Unable to find compiler for Java $javaVersionInteger. Have you set JAVA_${javaVersionInteger}_HOME?") } From 71da1891633dc76db098d094c71c8c3e6b67c50b Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Fri, 17 Jan 2025 18:25:48 +0100 Subject: [PATCH 12/22] Fix java version for tests in jetty-9 module --- dd-java-agent/instrumentation/jetty-9/build.gradle | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/dd-java-agent/instrumentation/jetty-9/build.gradle b/dd-java-agent/instrumentation/jetty-9/build.gradle index de8c939dab4..8da846b6085 100644 --- a/dd-java-agent/instrumentation/jetty-9/build.gradle +++ b/dd-java-agent/instrumentation/jetty-9/build.gradle @@ -60,6 +60,10 @@ muzzle { } } +ext { + latestDepForkedTestMinJavaVersionForTests = JavaVersion.VERSION_11 +} + apply plugin: 'java-test-fixtures' apply from: "$rootDir/gradle/java.gradle" @@ -114,13 +118,6 @@ addTestSuiteForDir('jetty94ForkedTest', 'test') addTestSuiteForDir('latestDepJetty9ForkedTest', 'test') addTestSuiteForDir('latestDepForkedTest', 'test') -tasks.named("latestDepForkedTest").configure { - javaLauncher = getJavaLauncherFor(11) -} -tasks.named("compileLatestDepForkedTestGroovy").configure { - setJavaVersion(it, 11) -} - dependencies { compileOnly group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.0.0.v20130308' From 0917c3ffcb97d753fa6bbb202cbb21e148692960 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Fri, 17 Jan 2025 18:28:46 +0100 Subject: [PATCH 13/22] Fix java version for tests in play-2.6 module --- dd-java-agent/instrumentation/play-2.6/build.gradle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dd-java-agent/instrumentation/play-2.6/build.gradle b/dd-java-agent/instrumentation/play-2.6/build.gradle index a13487d0063..66bf591fa14 100644 --- a/dd-java-agent/instrumentation/play-2.6/build.gradle +++ b/dd-java-agent/instrumentation/play-2.6/build.gradle @@ -50,6 +50,10 @@ muzzle { } } +ext { + latestDepTestMinJavaVersionForTests = JavaVersion.VERSION_11 +} + apply from: "$rootDir/gradle/java.gradle" apply plugin: 'scala' @@ -180,7 +184,6 @@ tasks.register('buildLatestDepTestRoutes', JavaExec) { dependsOn compileRouteGeneratorScala, compileLatestDepTestScala } compileLatestDepTestGeneratedScala { - javaLauncher = getJavaLauncherFor(11) classpath = classpath + files(compileLatestDepTestScala.destinationDirectory) dependsOn buildLatestDepTestRoutes, compileLatestDepTestScala } @@ -189,7 +192,6 @@ forbiddenApisLatestDepTestGenerated { } compileLatestDepTestGroovy { - javaLauncher = getJavaLauncherFor(11) classpath = classpath + files(compileLatestDepTestScala.destinationDirectory) + files(compileBaseTestGroovy.destinationDirectory) + From bfa3220cdea5110ca29ef7e02f8b618c17567c12 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Sat, 18 Jan 2025 17:41:47 +0100 Subject: [PATCH 14/22] Fix jdbc latestDepTest --- dd-java-agent/instrumentation/jdbc/build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dd-java-agent/instrumentation/jdbc/build.gradle b/dd-java-agent/instrumentation/jdbc/build.gradle index 1898efd78b4..bb6b96c5731 100644 --- a/dd-java-agent/instrumentation/jdbc/build.gradle +++ b/dd-java-agent/instrumentation/jdbc/build.gradle @@ -11,6 +11,10 @@ muzzle { } } +ext { + latestDepJava11TestMinJavaVersionForTests = JavaVersion.VERSION_11 +} + apply from: "$rootDir/gradle/java.gradle" apply plugin: 'call-site-instrumentation' @@ -78,10 +82,6 @@ tasks.named("check").configure { dependsOn "oldPostgresTest" } -tasks.named("latestDepJava11Test").configure { - javaLauncher = getJavaLauncherFor(11) -} - tasks.withType(Test).configureEach { usesService(testcontainersLimit) } From 651749661754dbbc3fcc5bae30bca1b9eea80c9a Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Sat, 18 Jan 2025 17:46:23 +0100 Subject: [PATCH 15/22] Fix kafka-clients-0.11 jdk --- .../instrumentation/kafka-clients-0.11/build.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dd-java-agent/instrumentation/kafka-clients-0.11/build.gradle b/dd-java-agent/instrumentation/kafka-clients-0.11/build.gradle index 1fa13c7d2af..ff6e06d19b7 100644 --- a/dd-java-agent/instrumentation/kafka-clients-0.11/build.gradle +++ b/dd-java-agent/instrumentation/kafka-clients-0.11/build.gradle @@ -15,6 +15,10 @@ muzzle { } } +ext { + iastLatestDepTest3MinJavaVersionForTests = JavaVersion.VERSION_17 +} + apply from: "$rootDir/gradle/java.gradle" addTestSuite('latestDepTest') @@ -71,8 +75,7 @@ configurations.testRuntimeClasspath { resolutionStrategy.force 'org.assertj:assertj-core:2.9.1' } -iastLatestDepTest3.configure { - javaLauncher = getJavaLauncherFor(17) +tasks.named("iastLatestDepTest3").configure { jvmArgs = ['--add-opens', 'java.base/java.util=ALL-UNNAMED'] } From 2d7658007a21c799f9a3b2c6295e1ece73da6db5 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Sat, 18 Jan 2025 17:49:59 +0100 Subject: [PATCH 16/22] Fix jakarta-rs-annotations-3 jdk --- .../jakarta-rs-annotations-3/build.gradle | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dd-java-agent/instrumentation/jakarta-rs-annotations-3/build.gradle b/dd-java-agent/instrumentation/jakarta-rs-annotations-3/build.gradle index 555b8ba60d5..98b9c05993f 100644 --- a/dd-java-agent/instrumentation/jakarta-rs-annotations-3/build.gradle +++ b/dd-java-agent/instrumentation/jakarta-rs-annotations-3/build.gradle @@ -7,6 +7,10 @@ muzzle { } } +ext { + latestDepJava11TestMinJavaVersionForTests = JavaVersion.VERSION_11 +} + apply from: "$rootDir/gradle/java.gradle" addTestSuiteForDir('latestDepTest', 'test') @@ -16,10 +20,7 @@ tasks.named("compileLatestDepJava11TestJava").configure { setJavaVersion(it, 11) } tasks.named("compileLatestDepJava11TestGroovy").configure { - javaLauncher = getJavaLauncherFor(11) -} -tasks.named("latestDepJava11Test").configure { - javaLauncher = getJavaLauncherFor(11) + setJavaVersion(it, 11) } dependencies { From 27792ca3d28d6745c10814cb5b0d7b1f7c6014c2 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Sat, 18 Jan 2025 17:52:53 +0100 Subject: [PATCH 17/22] Fix armeria-jetty-11 jdk --- .../instrumentation/armeria-jetty/build.gradle | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dd-java-agent/instrumentation/armeria-jetty/build.gradle b/dd-java-agent/instrumentation/armeria-jetty/build.gradle index 669d428c9ff..79c48f17fc1 100644 --- a/dd-java-agent/instrumentation/armeria-jetty/build.gradle +++ b/dd-java-agent/instrumentation/armeria-jetty/build.gradle @@ -15,6 +15,11 @@ muzzle { } } +ext { + jetty11TestMinJavaVersionForTests = JavaVersion.VERSION_11 + jetty11LatestDepTestMinJavaVersionForTests = JavaVersion.VERSION_11 +} + apply from: "$rootDir/gradle/java.gradle" apply from: "$rootDir/gradle/configure_tests.gradle" @@ -25,12 +30,6 @@ addTestSuiteForDir("jetty11Test", "test/jetty11") addTestSuiteExtendingForDir("jetty9LatestDepTest", "latestDepTest", "test/jetty9") addTestSuiteExtendingForDir("jetty11LatestDepTest", "latestDepTest", "test/jetty11") -[compileJetty11TestGroovy, jetty11Test, compileJetty11LatestDepTestGroovy, jetty11LatestDepTest].each { - it.configure { - javaLauncher = getJavaLauncherFor(11) - } -} - dependencies { compileOnly group: 'com.linecorp.armeria', name: 'armeria-jetty9', version: '1.24.0' jetty11TestImplementation group: 'com.linecorp.armeria', name: 'armeria-jetty11', version: '1.24.0', { From d6caa34ee11bd4aa3f2e2542ff621e6e358fcec8 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Sat, 18 Jan 2025 18:29:37 +0100 Subject: [PATCH 18/22] WIP: wildfly smoke test --- dd-smoke-tests/wildfly/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/dd-smoke-tests/wildfly/build.gradle b/dd-smoke-tests/wildfly/build.gradle index d10e2ed4e73..fca4b9f9c42 100644 --- a/dd-smoke-tests/wildfly/build.gradle +++ b/dd-smoke-tests/wildfly/build.gradle @@ -47,6 +47,7 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' // define the task that builds the quarkus project tasks.register('earBuild', Exec) { workingDir "$appDir" + environment += ["JAVA_HOME": "$System.env.JAVA_8_HOME"] environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'"] commandLine "$rootDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" From 015d0541d5baa89b8e65aee2717472b65e3afa10 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Sat, 18 Jan 2025 18:49:32 +0100 Subject: [PATCH 19/22] WIP: fix wildfly smoke test --- dd-smoke-tests/wildfly/build.gradle | 4 +++- dd-smoke-tests/wildfly/spring-ear/build.gradle | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dd-smoke-tests/wildfly/build.gradle b/dd-smoke-tests/wildfly/build.gradle index fca4b9f9c42..8028572bd54 100644 --- a/dd-smoke-tests/wildfly/build.gradle +++ b/dd-smoke-tests/wildfly/build.gradle @@ -47,7 +47,9 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' // define the task that builds the quarkus project tasks.register('earBuild', Exec) { workingDir "$appDir" - environment += ["JAVA_HOME": "$System.env.JAVA_8_HOME"] + String java8Home = "$System.env.JAVA_8_HOME" + assert java8Home != null + environment += ["JAVA_HOME": java8Home] environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'"] commandLine "$rootDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" diff --git a/dd-smoke-tests/wildfly/spring-ear/build.gradle b/dd-smoke-tests/wildfly/spring-ear/build.gradle index 5b9f55672a2..ae1e86169da 100644 --- a/dd-smoke-tests/wildfly/spring-ear/build.gradle +++ b/dd-smoke-tests/wildfly/spring-ear/build.gradle @@ -27,3 +27,6 @@ dependencies { implementation "com.datadoghq:dd-trace-api:1.2.0" } } + +targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_1_8 From 2a4ee3f6cff1e8d0e127142101fe09228fc56da9 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Sat, 18 Jan 2025 18:53:00 +0100 Subject: [PATCH 20/22] WIP: fix spring-boot-2.7-webflux smoke test --- .../spring-boot-2.7-webflux/application/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dd-smoke-tests/spring-boot-2.7-webflux/application/build.gradle b/dd-smoke-tests/spring-boot-2.7-webflux/application/build.gradle index c71daf29759..801ff22d42e 100644 --- a/dd-smoke-tests/spring-boot-2.7-webflux/application/build.gradle +++ b/dd-smoke-tests/spring-boot-2.7-webflux/application/build.gradle @@ -30,3 +30,6 @@ dependencies { implementation "com.datadoghq:dd-trace-api:0.110.0" } } + +targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_1_8 From 1e3b8fc80bbebc6ba5d7127bb3feece12cd419e8 Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Mon, 20 Jan 2025 13:14:37 +0100 Subject: [PATCH 21/22] fix quarkus smoke test --- dd-smoke-tests/quarkus/application/build.gradle | 3 +++ dd-smoke-tests/quarkus/build.gradle | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dd-smoke-tests/quarkus/application/build.gradle b/dd-smoke-tests/quarkus/application/build.gradle index 4319e66e02a..2b48008f055 100644 --- a/dd-smoke-tests/quarkus/application/build.gradle +++ b/dd-smoke-tests/quarkus/application/build.gradle @@ -30,3 +30,6 @@ dependencies { quarkusBuild { uberJar = true } + +targetCompatibility = JavaVersion.VERSION_1_8 +sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/dd-smoke-tests/quarkus/build.gradle b/dd-smoke-tests/quarkus/build.gradle index b93f55ac268..cce07452de3 100644 --- a/dd-smoke-tests/quarkus/build.gradle +++ b/dd-smoke-tests/quarkus/build.gradle @@ -13,8 +13,11 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' // define the task that builds the quarkus project tasks.register('quarkusBuild', Exec) { workingDir "$appDir" + String java11Home = "$System.env.JAVA_11_HOME" + assert java11Home != null + environment += ["JAVA_HOME": java11Home] environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'"] - commandLine "${rootDir}/${gradlewCommand}", "build", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" + commandLine "${rootDir}/${gradlewCommand}", "build", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}", "-Dorg.gradle.java.home=${java11Home}" outputs.cacheIf { true } From d67f8fd0fd334df6057542e3c187b4bf67572bed Mon Sep 17 00:00:00 2001 From: Santiago Mola Date: Fri, 28 Mar 2025 16:17:51 +0100 Subject: [PATCH 22/22] Fix vertx-web-5.0 --- dd-java-agent/instrumentation/vertx-web-5.0/build.gradle | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/dd-java-agent/instrumentation/vertx-web-5.0/build.gradle b/dd-java-agent/instrumentation/vertx-web-5.0/build.gradle index c11c4b7ab13..67ac0c0fca4 100644 --- a/dd-java-agent/instrumentation/vertx-web-5.0/build.gradle +++ b/dd-java-agent/instrumentation/vertx-web-5.0/build.gradle @@ -1,5 +1,7 @@ // Set properties before any plugins get loaded ext { + defaultJdkVersion = 11 + defaultJavaVersion = 8 minJavaVersionForTests = JavaVersion.VERSION_11 } @@ -22,12 +24,6 @@ configurations { testArtifacts } -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) - } -} - // Create test artifacts so vertx-rx can reuse the server test instrumentation and base class artifacts { testArtifacts testJar