Skip to content

Commit 1555846

Browse files
committed
chore: Explicit setup of the compiler
1 parent bccddcb commit 1555846

File tree

44 files changed

+259
-210
lines changed

Some content is hidden

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

44 files changed

+259
-210
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
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'
@@ -9,7 +11,7 @@ apply plugin: "idea"
911

1012
tasks.named("compileJava", JavaCompile).configure {
1113
// need access to sun.* packages
12-
setJavaVersion(it, 8)
14+
setJavaVersion(it, 8, true)
1315
}
1416

1517
// FIXME: Improve test coverage.
@@ -37,8 +39,8 @@ sourceSets {
3739
}
3840
}
3941

40-
compileMain_java11Java.configure {
41-
setJavaVersion(it, 11)
42+
tasks.named("compileMain_java11Java", JavaCompile) {
43+
setJavaVersion(it, 11, true)
4244
sourceCompatibility = JavaVersion.VERSION_1_8
4345
targetCompatibility = JavaVersion.VERSION_1_8
4446
}
@@ -48,11 +50,11 @@ dependencies {
4850
main_java11CompileOnly sourceSets.main.output
4951
}
5052

51-
jar {
53+
tasks.named("jar", Jar) {
5254
from sourceSets.main_java11.output
5355
}
5456

55-
forbiddenApisMain_java11 {
57+
tasks.named("forbiddenApisMain_java11", CheckForbiddenApis) {
5658
failOnMissingClasses = false
5759
}
5860

@@ -63,14 +65,12 @@ idea {
6365
}
6466

6567
jmh {
66-
jmhVersion = libs.versions.jmh.get()
68+
jmhVersion = libs.versions.jmh
6769
duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
6870
}
6971

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-
}
72+
tasks.withType(Test).configureEach {
73+
if (javaLauncher.get().metadata.languageVersion.asInt() >= 16) {
74+
jvmArgs += ['--add-opens', 'java.base/java.net=ALL-UNNAMED'] // for HostNameResolverForkedTest
7575
}
7676
}

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

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

2222
compileMain_java11Java.configure {
23-
setJavaVersion(it, 11)
23+
setJavaVersion(it, 11, true)
2424
sourceCompatibility = JavaVersion.VERSION_1_8
2525
targetCompatibility = JavaVersion.VERSION_1_8
2626
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies {
3939
*/
4040
[JavaCompile, GroovyCompile].each {
4141
tasks.withType(it).configureEach {
42-
setJavaVersion(it, 11)
42+
setJavaVersion(it, 11, true)
4343
sourceCompatibility = JavaVersion.VERSION_1_8
4444
targetCompatibility = JavaVersion.VERSION_1_8
4545
// Disable '-processing' because some annotations are not claimed.

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
2+
13
// Set properties before any plugins get loaded
24
ext {
35
// the tests need Java 11 because the JFR writer got compiled with a version
@@ -28,9 +30,8 @@ excludedClassesCoverage += ['com.datadog.profiling.controller.jfr.JdkTypeIDs']
2830

2931

3032
// Shared JFR implementation. The earliest Java version JFR is working on is Java 8
31-
32-
tasks.named("compileTestJava").configure {
33-
setJavaVersion(it, 11)
33+
tasks.named("compileTestJava", JavaCompile) {
34+
setJavaVersion(it, 11, true)
3435
// tests should be compiled in Java 8 compatible way
3536
sourceCompatibility = JavaVersion.VERSION_1_8
3637
targetCompatibility = JavaVersion.VERSION_1_8
@@ -40,7 +41,7 @@ tasks.named("compileTestJava").configure {
4041
options.compilerArgs.addAll(['-Xlint:all,-processing,-options,-path'/*, '-Werror'*/])
4142
}
4243

43-
forbiddenApisMain {
44+
tasks.named("forbiddenApisMain", CheckForbiddenApis) {
4445
failOnMissingClasses = false
4546
}
4647

dd-java-agent/agent-profiling/profiling-controller-jfr/implementation/build.gradle

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import de.thetaphi.forbiddenapis.gradle.CheckForbiddenApis
2+
13
// Set properties before any plugins get loaded
24
ext {
35
minJavaVersionForTests = JavaVersion.VERSION_1_8
@@ -13,8 +15,12 @@ sourceSets {
1315
}
1416
}
1517

16-
compileMain_java11Java.configure {
17-
setJavaVersion(it, 11)
18+
tasks.named("compileJava", JavaCompile) {
19+
setJavaVersion(it, 11, true)
20+
}
21+
22+
tasks.named("compileMain_java11Java", JavaCompile) {
23+
setJavaVersion(it, 11, true)
1824
sourceCompatibility = JavaVersion.VERSION_1_9
1925
targetCompatibility = JavaVersion.VERSION_1_9
2026
}
@@ -37,12 +43,12 @@ excludedClassesCoverage += [
3743
'com.datadog.profiling.controller.jfr.SimpleJFRAccess*'
3844
]
3945

40-
jar {
46+
tasks.named("jar", Jar) {
4147
from sourceSets.main_java11.output
4248
}
4349

44-
forbiddenApisMain {
45-
failOnMissingClasses = false
50+
tasks.named("forbiddenApisMain", CheckForbiddenApis) {
51+
it.failOnMissingClasses = false
4652
}
4753

4854
idea {
@@ -51,12 +57,10 @@ idea {
5157
}
5258
}
5359

54-
project.afterEvaluate {
55-
tasks.withType(Test).configureEach {
56-
if (javaLauncher.get().metadata.languageVersion.asInt() >= 9) {
57-
jvmArgs += [
58-
'--add-opens',
59-
'jdk.jfr/jdk.jfr.internal=ALL-UNNAMED'] // JPMSJFRAccess needs access to jdk.jfr.internal package
60-
}
60+
tasks.withType(Test).configureEach {
61+
if (javaLauncher.get().metadata.languageVersion.asInt() >= 9) {
62+
jvmArgs += [
63+
'--add-opens',
64+
'jdk.jfr/jdk.jfr.internal=ALL-UNNAMED'] // JPMSJFRAccess needs access to jdk.jfr.internal package
6165
}
6266
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ dependencies {
4141
}
4242

4343

44-
configurations.all {
44+
configurations.configureEach {
4545
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
4646
}
4747

4848
[JavaCompile, GroovyCompile].each {
4949
tasks.withType(it).configureEach {
50-
setJavaVersion(it, 11)
50+
setJavaVersion(it, 11, true)
5151
sourceCompatibility = JavaVersion.VERSION_1_8
5252
targetCompatibility = JavaVersion.VERSION_1_8
5353
// Disable '-processing' because some annotations are not claimed.

dd-java-agent/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sourceSets {
2626
}
2727

2828
compileMain_java6Java.configure {
29-
setJavaVersion(it, 8)
29+
setJavaVersion(it, 8, true)
3030
sourceCompatibility = JavaVersion.VERSION_1_6
3131
targetCompatibility = JavaVersion.VERSION_1_6
3232
}

dd-java-agent/instrumentation/akka/akka-http/akka-http-10.6/build.gradle

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ repositories {
4141

4242
addTestSuiteForDir('latestDepTest', 'test')
4343

44-
[compileMain_java11Java, compileTestScala, compileLatestDepTestScala].each {
45-
it.configure {
46-
setJavaVersion(it, 11)
44+
["compileMain_java11Java", "compileTestScala", "compileLatestDepTestScala"].each {
45+
tasks.named(it) {
46+
setJavaVersion(it, 11, true)
4747
sourceCompatibility = JavaVersion.VERSION_1_8
4848
targetCompatibility = JavaVersion.VERSION_1_8
4949
}
5050
}
5151

52-
compileTestGroovy {
53-
javaLauncher = getJavaLauncherFor(11)
52+
tasks.named("compileTestGroovy") {
53+
setJavaVersion(it, 11)
5454
dependsOn compileTestScala
5555
classpath += files(compileTestScala.destinationDirectory)
5656
}
5757

58-
compileLatestDepTestGroovy {
59-
javaLauncher = getJavaLauncherFor(11)
58+
tasks.named("compileLatestDepTestGroovy") {
59+
setJavaVersion(it, 11)
6060
dependsOn compileLatestDepTestScala
6161
classpath += files(compileLatestDepTestScala.destinationDirectory)
6262
}
@@ -87,6 +87,8 @@ dependencies {
8787
latestDepTestImplementation group: 'org.scala-lang.modules', name: 'scala-java8-compat_2.13', version: '1.0.+'
8888
}
8989

90-
configurations.getByName("latestDepTestRuntimeClasspath").resolutionStrategy {
91-
it.force libs.slf4j
90+
configurations.named("latestDepTestRuntimeClasspath") {
91+
it.resolutionStrategy {
92+
it.force libs.slf4j
93+
}
9294
}

dd-java-agent/instrumentation/exception-profiling/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies {
2020

2121
// Must use Java 11 to build JFR enabled code - there is no JFR in OpenJDK 8 (revisit once JFR in Java 8 is available)
2222
[compileMain_java11Java, compileTestJava].each {
23-
setJavaVersion(it, 11)
23+
setJavaVersion(it, 11, true)
2424
it.sourceCompatibility = JavaVersion.VERSION_1_8
2525
it.targetCompatibility = JavaVersion.VERSION_1_8
2626
it.options.compilerArgs.addAll(['-Xlint:all,-processing,-options,-path'])

dd-java-agent/instrumentation/graal/native-image/build.gradle

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ muzzle {
1313
apply from: "$rootDir/gradle/java.gradle"
1414
apply plugin: "idea"
1515

16-
[compileMain_java11Java, compileTestJava].each {
17-
it.sourceCompatibility = JavaVersion.VERSION_11
18-
it.targetCompatibility = JavaVersion.VERSION_11
19-
setJavaVersion(it, 11)
20-
it.options.compilerArgs.addAll([
21-
'-Xlint:all,-processing,-options,-path',
22-
'--add-modules',
23-
'jdk.internal.vm.ci',
24-
'--add-exports',
25-
'jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED'
26-
])
16+
["compileMain_java11Java", "compileTestJava"].each {
17+
tasks.named(it) {
18+
setJavaVersion(it, 11, true)
19+
it.sourceCompatibility = JavaVersion.VERSION_11
20+
it.targetCompatibility = JavaVersion.VERSION_11
21+
it.options.compilerArgs.addAll([
22+
'-Xlint:all,-processing,-options,-path',
23+
'--add-modules',
24+
'jdk.internal.vm.ci',
25+
'--add-exports',
26+
'jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED'
27+
])
28+
}
2729
}
2830

2931
dependencies {
@@ -32,7 +34,7 @@ dependencies {
3234
main_java11CompileOnly group: 'org.graalvm.nativeimage', name: 'svm', version: '20.0.0'
3335
}
3436

35-
forbiddenApisMain_java11 {
37+
tasks.named("forbiddenApisMain_java11") {
3638
failOnMissingClasses = false
3739
}
3840

0 commit comments

Comments
 (0)