Skip to content

Commit c9c3e60

Browse files
bric3smola
andauthored
Decouple Gradle JDK from JDK8 (#9514)
* Set default java toolchain to 8 * Set toolchain early * Set JAVA_HOME for smoke test builds * Do not set compiler release by default (remove skipSettingCompilerRelease) # Conflicts: # internal-api/build.gradle was converted to internal-api/build.gradle.kts # Conflicts: # dd-java-agent/instrumentation/java-concurrent/java-completablefuture/build.gradle * build: Run instrument plugin with toolchain # Conflicts: # buildSrc/src/main/groovy/MuzzlePlugin.groovy # Conflicts: # buildSrc/src/main/kotlin/datadog/gradle/plugin/muzzle/MuzzleTask.kt * build: Check version in CI * fix: call-instrumentation-site test due to the appearance of SequenceCollection::getFirst in JDK 21 * chore: Explicit setup of the compiler # Conflicts: # dd-java-agent/instrumentation/kafka/kafka-clients-3.8/build.gradle # Conflicts: # dd-java-agent/agent-profiling/profiling-controller-jfr/build.gradle # dd-java-agent/instrumentation/play/play-2.6/build.gradle # dd-java-agent/instrumentation/wildfly-9.0/build.gradle # dd-smoke-tests/concurrent/java-25/build.gradle # utils/socket-utils/build.gradle.kts # Conflicts: # dd-java-agent/agent-bootstrap/build.gradle # dd-java-agent/agent-builder/build.gradle # dd-java-agent/agent-profiling/profiling-controller-jfr/build.gradle # dd-java-agent/instrumentation/akka/akka-http/akka-http-10.6/build.gradle # dd-java-agent/instrumentation/exception-profiling/build.gradle # dd-java-agent/instrumentation/graal/native-image/build.gradle # dd-java-agent/instrumentation/jetty/jetty-server/jetty-server-12.0/build.gradle # dd-java-agent/instrumentation/kafka/kafka-clients-3.8/build.gradle # dd-java-agent/instrumentation/liberty-20/build.gradle # dd-java-agent/instrumentation/micronaut/http-server-netty-4.0/build.gradle # dd-java-agent/instrumentation/play/play-2.6/build.gradle # dd-java-agent/instrumentation/spring/spring-scheduling-3.1/build.gradle # dd-java-agent/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/build.gradle # dd-java-agent/instrumentation/vertx/vertx-web/vertx-web-4.0/build.gradle # dd-java-agent/instrumentation/websocket/jetty-websocket/jetty-websocket-10/build.gradle # dd-java-agent/instrumentation/wildfly-9.0/build.gradle * refactor: setJavaVersion becomes configureCompiler, handles release/source/target # Conflicts: # dd-java-agent/agent-tooling/build.gradle * fix: project.afterEvaluate messing with setting up "testJvm" * fix: duplicated task config * fix: Failing :dd-java-agent:agent-tooling tests When Groovy compiles this code against JDK 21 **but targeting Java 8**, ``` URLClassLoader loader = new URLClassLoader(classpath, null, null) { @OverRide Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { ... } } ``` Groovy will generate super class synthetic accessor methods like * `super$2$loadClass(Ljava/lang/String;)Ljava/lang/Class;` * `super$2$loadClass(Ljava/lang/String;Z)Ljava/lang/Class;` * `super$2$loadClass(Ljava/lang/Module;Ljava/lang/String;)Ljava/lang/Class;` `java.lang.Module` being missing from Java 8 won't run. java.lang.NoClassDefFoundError: java/lang/Module at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2729) at java.lang.Class.privateGetPublicMethods(Class.java:2930) at java.lang.Class.getMethods(Class.java:1643) at groovy.lang.MetaClassImpl.inheritInterfaceNewMetaMethods(MetaClassImpl.java:628) at groovy.lang.MetaClassImpl.fillMethodIndex(MetaClassImpl.java:368) at groovy.lang.MetaClassImpl.reinitialize(MetaClassImpl.java:3381) at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3376) at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:273) at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:315) at datadog.trace.agent.test.BaseExceptionHandlerTest$1.$getStaticMetaClass(BaseExceptionHandlerTest.groovy) at datadog.trace.agent.test.BaseExceptionHandlerTest$1.<init>(BaseExceptionHandlerTest.groovy) at datadog.trace.agent.test.BaseExceptionHandlerTest.$spock_feature_1_1(BaseExceptionHandlerTest.groovy:131) ... Caused by: java.lang.ClassNotFoundException: java.lang.Module at java.net.URLClassLoader.findClass(URLClassLoader.java:387) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... * fix: Failing :dd-java-agent:agent-ci-visibility When Groovy compiles this code against JDK 21 **but targeting Java 8**, ``` private static final class MisbehavingClassLoader extends ClassLoader { ... } ``` Groovy will generate super class synthetic accessor methods like * `super$2$loadClass(Ljava/lang/String;)Ljava/lang/Class;` * `super$2$loadClass(Ljava/lang/String;Z)Ljava/lang/Class;` * `super$2$loadClass(Ljava/lang/Module;Ljava/lang/String;)Ljava/lang/Class;` `java.lang.Module` being missing from Java 8 won't run. java.lang.NoClassDefFoundError: java/lang/Module at java.lang.Class.privateGetDeclaredMethods(Class.java:2729) at java.lang.Class.privateGetPublicMethods(Class.java:2930) at java.lang.Class.getMethods(Class.java:1643) at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1336) at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1197) at java.beans.Introspector.getBeanInfo(Introspector.java:426) at java.beans.Introspector.getBeanInfo(Introspector.java:173) at datadog.trace.civisibility.source.ByteCodeLinesResolverTest.test returns empty method lines when class cannot be loaded(ByteCodeLinesResolverTest.groovy:45) Caused by: java.lang.ClassNotFoundException: java.lang.Module at java.net.URLClassLoader.findClass(URLClassLoader.java:387) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 8 more * fix: Fix Groovy delegation that was adding interfaces to object delegation. There was a `NoClassDefFoundError` of `java.lang.constant.Constable` when run on JDK8, this happened because the `Delegate` annotation makes Groovy adds the interfaces of the delegated object to the enclosing class. Since JDK12 types like `Integer`, `String` implement `Constable` this fails when the class is loaded on JDK8 or 11. See groovy/groovy-eclipse#1436 java.lang.NoClassDefFoundError: java/lang/constant/Constable at java.lang.ClassLoader.defineClass(ClassLoader.java:756) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:473) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at com.datadog.appsec.event.data.ObjectIntrospectionSpecification.conversion of an element throws(ObjectIntrospectionSpecification.groovy:305) Caused by: java.lang.ClassNotFoundException: java.lang.constant.Constable at java.net.URLClassLoader.findClass(URLClassLoader.java:387) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 11 more * fix: Fix muzzle detected that compiler generated an invokeinterface for getClass on HttpRequest Instead, the byte code is now an invokevirtual on Object as the javac in JDK8 does * fix: Fix jdbc tests because `java.sql.Connection` introduced methods with new types in JDK9 E.g. methods with `java.sql.ShardingKey`, while these methods are default, Groovy still implements them (implementation actually invokes the interface default method). org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 66. at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:65) ... Caused by: org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:165) ... Caused by: org.junit.platform.commons.JUnitException: ClassSelector [className = 'foo.bar.IastInstrumentedConnection', classLoader = sun.misc.Launcher$AppClassLoader@73d16e93] resolution failed at org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener.selectorProcessed(AbortOnFailureLauncherDiscoveryListener.java:39) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:103) at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:83) ... Caused by: java.lang.NoClassDefFoundError: java/sql/ShardingKey at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2729) at java.lang.Class.privateGetPublicMethods(Class.java:2930) * fix: dd-smoke-tests needs to use Java 8 ProcessManager uses the `CharBuffer.flip` method, which is coming from the super class in JDK 8 so its signature is `()Ljava.nio.Buffer`, but since JDK9 `CharBuffer` overrides it, in the bytecode the signatures becomes `()Ljava.nio.CharBuffer`. This code fails when running with testJvm=8. * chore: Make spotless happy * fix: iast-agent was not using configureCompiler * fix: Make resilience4j modules use configureCompiler * fix: Replace Groovy's getProperty by Project.findProperty * fix: vertx-web-5.0 now uses configureCompiler * fix: smoke appsec/springboot-graphql needs to compile to Java 1.8 * chore: fail early when testJvm is blank * fix: Enforce ByteCode 1.8 on some jetty projects * style: Typo * Revert "fix: Fix muzzle detected that compiler generated an invokeinterface for getClass on HttpRequest" This reverts commit bc1b15c because muzzle now handles https://bugs.openjdk.org/browse/JDK-8272715 since #9649 --------- Co-authored-by: Santiago Mola <[email protected]>
1 parent 0d75905 commit c9c3e60

File tree

111 files changed

+796
-583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+796
-583
lines changed

.gitlab-ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ build:
256256
DEPENDENCY_CACHE_POLICY: pull
257257
script:
258258
- if [ $CI_PIPELINE_SOURCE == "schedule" ] ; then ./gradlew resolveAndLockAll --write-locks $GRADLE_ARGS; fi
259+
- ./gradlew --version
259260
- ./gradlew clean :dd-java-agent:shadowJar :dd-trace-api:jar :dd-trace-ot:shadowJar -PskipTests $GRADLE_ARGS
260261
- echo UPSTREAM_TRACER_VERSION=$(java -jar workspace/dd-java-agent/build/libs/*.jar) >> upstream.env
261262
- echo "BUILD_JOB_NAME=$CI_JOB_NAME" >> build.env
@@ -296,6 +297,7 @@ build_tests:
296297

297298
script:
298299
- *gitlab_base_ref_params
300+
- ./gradlew --version
299301
- ./gradlew clean $GRADLE_TARGET $GRADLE_PARAMS -PskipTests $GRADLE_ARGS
300302

301303
populate_dep_cache:
@@ -362,7 +364,7 @@ spotless:
362364
stage: tests
363365
needs: []
364366
script:
365-
- export JAVA_HOME=$JAVA_11_HOME
367+
- ./gradlew --version
366368
- ./gradlew spotlessCheck $GRADLE_ARGS
367369

368370
test_published_artifacts:
@@ -381,6 +383,7 @@ test_published_artifacts:
381383
- ./gradlew publishToMavenLocal $GRADLE_ARGS
382384
- cd test-published-dependencies
383385
- export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1G -Xms1G -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp'"
386+
- ./gradlew --version
384387
- ./gradlew check --info $GRADLE_ARGS
385388
after_script:
386389
- *cgroup_info
@@ -401,6 +404,7 @@ test_published_artifacts:
401404
CACHE_TYPE: lib
402405
script:
403406
- *gitlab_base_ref_params
407+
- ./gradlew --version
404408
- ./gradlew $GRADLE_TARGET $GRADLE_PARAMS -PskipTests -PrunBuildSrcTests -PskipSpotless -PtaskPartitionCount=$NORMALIZED_NODE_TOTAL -PtaskPartition=$NORMALIZED_NODE_INDEX $GRADLE_ARGS
405409
after_script:
406410
- *cgroup_info
@@ -461,6 +465,7 @@ muzzle:
461465
CACHE_TYPE: inst
462466
script:
463467
- export SKIP_BUILDSCAN="true"
468+
- ./gradlew --version
464469
- ./gradlew :runMuzzle -PtaskPartitionCount=$NORMALIZED_NODE_TOTAL -PtaskPartition=$NORMALIZED_NODE_INDEX $GRADLE_ARGS
465470
after_script:
466471
- *cgroup_info
@@ -482,6 +487,7 @@ muzzle-dep-report:
482487
CACHE_TYPE: inst
483488
script:
484489
- export SKIP_BUILDSCAN="true"
490+
- ./gradlew --version
485491
- ./gradlew generateMuzzleReport muzzleInstrumentationReport $GRADLE_ARGS
486492
after_script:
487493
- *cgroup_info
@@ -541,6 +547,7 @@ muzzle-dep-report:
541547
fi
542548
- *prepare_test_env
543549
- export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xms$GRADLE_MEM -Xmx$GRADLE_MEM $PROFILER_COMMAND -XX:ErrorFile=/tmp/hs_err_pid%p.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp' -Ddatadog.forkedMaxHeapSize=1024M -Ddatadog.forkedMinHeapSize=128M"
550+
- ./gradlew --version
544551
- ./gradlew $GRADLE_TARGET $GRADLE_PARAMS -PtestJvm=$testJvm -PtaskPartitionCount=$NORMALIZED_NODE_TOTAL -PtaskPartition=$NORMALIZED_NODE_INDEX $GRADLE_ARGS --continue || $CONTINUE_ON_FAILURE
545552
after_script:
546553
- *restore_pretest_env

buildSrc/call-site-instrumentation-plugin/src/test/groovy/datadog/trace/plugin/csi/impl/assertion/AssertBuilder.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ class AssertBuilder<C extends CallSiteAssert> {
5959
return [null, null]
6060
}
6161
final isEnabled = type.getMethodsByName('isEnabled').first()
62-
final returnStatement = isEnabled.body.get().statements.first.get().asReturnStmt()
62+
// JavaParser's NodeList has method getFirst() returning an Optional, however with Java 21's
63+
// SequencedCollection, Groovy picks the getFirst() that returns the object itself.
64+
// Using `first()` rather than `first` picks the groovy method instead, fixing the situation.
65+
final returnStatement = isEnabled.body.get().statements.first().asReturnStmt()
6366
final enabledMethodCall = returnStatement.expression.get().asMethodCallExpr()
6467
final enabled = resolveMethod(enabledMethodCall)
6568
final enabledArgs = enabledMethodCall.getArguments().collect { it.asStringLiteralExpr().asString() }.toSet()

buildSrc/src/main/groovy/InstrumentPlugin.groovy

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,16 @@ abstract class InstrumentTask extends DefaultTask {
152152
}
153153

154154
private workQueue() {
155-
if (this.javaVersion) {
156-
def javaLauncher = this.javaToolchainService.launcherFor { spec ->
157-
spec.languageVersion.set(JavaLanguageVersion.of(this.javaVersion))
158-
}.get()
159-
return this.workerExecutor.processIsolation { spec ->
160-
spec.forkOptions { fork ->
161-
fork.executable = javaLauncher.executablePath
162-
}
155+
if (!this.javaVersion) {
156+
this.javaVersion = "8"
157+
}
158+
def javaLauncher = this.javaToolchainService.launcherFor { spec ->
159+
spec.languageVersion.set(JavaLanguageVersion.of(this.javaVersion))
160+
}.get()
161+
return this.workerExecutor.processIsolation { spec ->
162+
spec.forkOptions { fork ->
163+
fork.executable = javaLauncher.executablePath
163164
}
164-
} else {
165-
return this.workerExecutor.noIsolation()
166165
}
167166
}
168167
}

buildSrc/src/main/kotlin/datadog/gradle/plugin/muzzle/tasks/MuzzleTask.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,17 @@ abstract class MuzzleTask @Inject constructor(
9393
val javaLauncher = javaToolchainService.launcherFor {
9494
languageVersion.set(JavaLanguageVersion.of(muzzleDirective.javaVersion!!))
9595
}.get()
96+
// Note process isolation leaks gradle dependencies to the child process
97+
// and may need additional code on muzzle plugin to filter those out
98+
// See https://github.com/gradle/gradle/issues/33987
9699
workerExecutor.processIsolation {
97100
forkOptions {
98101
executable(javaLauncher.executablePath)
99102
}
100103
}
101104
} else {
105+
// noIsolation worker is OK for muzzle tasks as their checks will inspect classes outline
106+
// and should not be impacted by the actual running JDK.
102107
workerExecutor.noIsolation()
103108
}
104109
workQueue.submit(MuzzleAction::class.java) {

dd-java-agent/agent-bootstrap/build.gradle

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
2+
13
// The shadowJar of this project will be injected into the JVM's bootstrap classloader
24
plugins {
35
id 'com.gradleup.shadow'
46
id 'me.champeau.jmh'
57
}
68

7-
ext {
8-
// need access to sun.* packages
9-
skipSettingCompilerRelease = true
10-
}
11-
129
apply from: "$rootDir/gradle/java.gradle"
1310
apply plugin: "idea"
1411

12+
tasks.named("compileJava", JavaCompile).configure {
13+
configureCompiler(it, 8, JavaVersion.VERSION_1_8, "Need access to sun.* packages")
14+
}
15+
1516
// FIXME: Improve test coverage.
1617
minimumBranchCoverage = 0.0
1718
minimumInstructionCoverage = 0.0
@@ -37,10 +38,8 @@ sourceSets {
3738
}
3839
}
3940

40-
compileMain_java11Java.configure {
41-
setJavaVersion(it, 11)
42-
sourceCompatibility = JavaVersion.VERSION_1_8
43-
targetCompatibility = JavaVersion.VERSION_1_8
41+
tasks.named("compileMain_java11Java", JavaCompile) {
42+
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
4443
}
4544

4645
dependencies {
@@ -52,7 +51,7 @@ tasks.named("jar", Jar) {
5251
from sourceSets.main_java11.output
5352
}
5453

55-
tasks.named("forbiddenApisMain_java11") {
54+
tasks.named("forbiddenApisMain_java11", CheckForbiddenApis) {
5655
failOnMissingClasses = false
5756
}
5857

@@ -63,14 +62,15 @@ idea {
6362
}
6463

6564
jmh {
66-
jmhVersion = libs.versions.jmh.get()
65+
jmhVersion = libs.versions.jmh
6766
duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
6867
}
6968

70-
project.afterEvaluate {
71-
tasks.withType(Test).configureEach {
72-
if (javaLauncher.get().metadata.languageVersion.asInt() >= 16) {
73-
jvmArgs += ['--add-opens', 'java.base/java.net=ALL-UNNAMED'] // for HostNameResolverForkedTest
74-
}
75-
}
69+
tasks.withType(Test).configureEach {
70+
configureJvmArgs(
71+
it,
72+
JavaVersion.VERSION_16,
73+
['--add-opens', 'java.base/java.net=ALL-UNNAMED'] // for HostNameResolverForkedTest
74+
)
75+
7676
}

dd-java-agent/agent-builder/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ sourceSets {
2020
}
2121

2222
tasks.named("compileMain_java11Java", JavaCompile) {
23-
setJavaVersion(it, 11)
24-
sourceCompatibility = JavaVersion.VERSION_1_8
25-
targetCompatibility = JavaVersion.VERSION_1_8
23+
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
2624
}
2725

2826
dependencies {

dd-java-agent/agent-ci-visibility/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@ tasks.named("shadowJar", ShadowJar) {
6666
tasks.named("jar", Jar) {
6767
archiveClassifier = 'unbundled'
6868
}
69+
70+
tasks.named("compileTestGroovy") {
71+
configureCompiler(
72+
it,
73+
8,
74+
JavaVersion.VERSION_1_8,
75+
"Groovy generates synthetic accessors methods from superclass, we don't want that for `MisbehavingClassLoader`," +
76+
" otherwise anonymous class has one `loadClass` accessor's signature has `java.lang.Module`"
77+
)
78+
}

dd-java-agent/agent-debugger/debugger-test-scala/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ apply from: "$rootDir/gradle/java.gradle"
77
dependencies {
88
implementation group: 'org.scala-lang', name: 'scala-compiler', version: '2.13.3'
99
}
10+
11+
tasks.withType(ScalaCompile).configureEach {
12+
// Despite the compatibility matrix, scala compiler doesn't properly
13+
// get the right compiler flags with JDK11 toolchain. Using 8 works.
14+
// * https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html
15+
// * https://github.com/gradle/gradle/issues/19456
16+
configureCompiler(it, 8)
17+
}

dd-java-agent/agent-iast/build.gradle

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,8 @@ plugins {
1111
apply from: "$rootDir/gradle/java.gradle"
1212
apply from: "$rootDir/gradle/version.gradle"
1313

14-
java {
15-
toolchain {
16-
languageVersion.set(JavaLanguageVersion.of(11))
17-
}
18-
sourceCompatibility = JavaVersion.VERSION_1_8
19-
targetCompatibility = JavaVersion.VERSION_1_8
20-
}
21-
2214
tasks.withType(AbstractCompile).configureEach {
23-
// ensure no APIs beyond JDK8 are used
24-
options.release = 8
15+
configureCompiler(it, 11, JavaVersion.VERSION_1_8, "Ensure no APIs beyond JDK8 are used")
2516
}
2617

2718
// First version with Mac M1 support

dd-java-agent/agent-profiling/profiling-controller-ddprof/build.gradle

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ ext {
44
// By default tests with be compiled for `minJavaVersionForTests` version,
55
// but in this case we would like to avoid this since we would like to run with ZULU8
66
skipSettingTestJavaVersion = true
7-
// need access to jdk.jfr package
8-
skipSettingCompilerRelease = true
97
excludeJdk = ['SEMERU11', 'SEMERU17']
108
}
119

@@ -39,16 +37,12 @@ dependencies {
3937
* We specify source/target as Java8 to get code that is loadable on Java8 - JFR defs are Java8 compatible.
4038
* We force IDEA to treat this as Java11 project with 'idea' plugin below.
4139
*/
42-
[JavaCompile, GroovyCompile].each {
43-
tasks.withType(it).configureEach {
44-
setJavaVersion(it, 11)
45-
sourceCompatibility = JavaVersion.VERSION_1_8
46-
targetCompatibility = JavaVersion.VERSION_1_8
47-
// Disable '-processing' because some annotations are not claimed.
48-
// Disable '-options' because we are compiling for java8 without specifying bootstrap - intentionally.
49-
// Disable '-path' because we do not have some of the paths seem to be missing.
50-
options.compilerArgs.addAll(['-Xlint:all,-processing,-options,-path'/*, '-Werror'*/])
51-
}
40+
tasks.withType(AbstractCompile).configureEach {
41+
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
42+
// Disable '-processing' because some annotations are not claimed.
43+
// Disable '-options' because we are compiling for java8 without specifying bootstrap - intentionally.
44+
// Disable '-path' because we do not have some of the paths seem to be missing.
45+
options.compilerArgs.addAll(['-Xlint:all,-processing,-options,-path'/*, '-Werror'*/])
5246
}
5347

5448
tasks.named("forbiddenApisMain") {

0 commit comments

Comments
 (0)