Skip to content

Commit 1af3a6a

Browse files
committed
refactor: setJavaVersion becomes configureCompiler, handles release/source/target
1 parent f42b689 commit 1af3a6a

File tree

65 files changed

+283
-315
lines changed

Some content is hidden

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

65 files changed

+283
-315
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ apply from: "$rootDir/gradle/java.gradle"
1010
apply plugin: "idea"
1111

1212
tasks.named("compileJava", JavaCompile).configure {
13-
// need access to sun.* packages
14-
setJavaVersion(it, 8, true)
13+
configureCompiler(it, 8, JavaVersion.VERSION_1_8, "Need access to sun.* packages")
1514
}
1615

1716
// FIXME: Improve test coverage.
@@ -40,9 +39,7 @@ sourceSets {
4039
}
4140

4241
tasks.named("compileMain_java11Java", JavaCompile) {
43-
setJavaVersion(it, 11, true)
44-
sourceCompatibility = JavaVersion.VERSION_1_8
45-
targetCompatibility = JavaVersion.VERSION_1_8
42+
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
4643
}
4744

4845
dependencies {

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
compileMain_java11Java.configure {
23-
setJavaVersion(it, 11, true)
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-profiling/profiling-controller-ddprof/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ dependencies {
3939
*/
4040
[JavaCompile, GroovyCompile].each {
4141
tasks.withType(it).configureEach {
42-
setJavaVersion(it, 11, true)
43-
sourceCompatibility = JavaVersion.VERSION_1_8
44-
targetCompatibility = JavaVersion.VERSION_1_8
42+
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
4543
// Disable '-processing' because some annotations are not claimed.
4644
// Disable '-options' because we are compiling for java8 without specifying bootstrap - intentionally.
4745
// Disable '-path' because we do not have some of the paths seem to be missing.

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ excludedClassesCoverage += ['com.datadog.profiling.controller.jfr.JdkTypeIDs']
3131

3232
// Shared JFR implementation. The earliest Java version JFR is working on is Java 8
3333
tasks.named("compileTestJava", JavaCompile) {
34-
setJavaVersion(it, 11, true)
3534
// tests should be compiled in Java 8 compatible way
36-
sourceCompatibility = JavaVersion.VERSION_1_8
37-
targetCompatibility = JavaVersion.VERSION_1_8
35+
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
3836
// Disable '-processing' because some annotations are not claimed.
3937
// Disable '-options' because we are compiling for java8 without specifying bootstrap - intentionally.
4038
// Disable '-path' because we do not have some of the paths seem to be missing.

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ sourceSets {
1616
}
1717

1818
tasks.named("compileJava", JavaCompile) {
19-
setJavaVersion(it, 11, true)
19+
configureCompiler(it, 11, JavaVersion.VERSION_1_8, "Need access to jdk.jfr.internal.*")
2020
}
2121

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

2826
dependencies {

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ dependencies {
3737
*/
3838
[JavaCompile, GroovyCompile].each {
3939
tasks.withType(it).configureEach {
40-
setJavaVersion(it, 11)
41-
if (it instanceof JavaCompile) {
42-
// need access to jdk.jfr package
43-
options.release = null
44-
}
45-
sourceCompatibility = JavaVersion.VERSION_1_8
46-
targetCompatibility = JavaVersion.VERSION_1_8
40+
configureCompiler(it, 11, JavaVersion.VERSION_1_8, "Need access to jdk.jfr package")
4741
// Disable '-processing' because some annotations are not claimed.
4842
// Disable '-options' because we are compiling for java8 without specifying bootstrap - intentionally.
4943
// Disable '-path' because we do not have some of the paths seem to be missing.

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ configurations.configureEach {
4747

4848
[JavaCompile, GroovyCompile].each {
4949
tasks.withType(it).configureEach {
50-
setJavaVersion(it, 11, true)
51-
sourceCompatibility = JavaVersion.VERSION_1_8
52-
targetCompatibility = JavaVersion.VERSION_1_8
50+
configureCompiler(it, 11, JavaVersion.VERSION_1_8)
5351
// Disable '-processing' because some annotations are not claimed.
5452
// Disable '-options' because we are compiling for java8 without specifying bootstrap - intentionally.
5553
// Disable '-path' because we do not have some of the paths seem to be missing.

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,10 @@ forbiddenApisTest_java11 {
8080
failOnMissingClasses = false
8181
}
8282

83-
project.tasks.compileTestJava.dependsOn(project.tasks.generateTestClassNameTries)
84-
project.tasks.compileTestGroovy.dependsOn(project.tasks.compileTest_java11Java)
85-
project.tasks.compileTest_java11Java.configure {
86-
sourceCompatibility = JavaVersion.VERSION_11
87-
targetCompatibility = JavaVersion.VERSION_11
88-
setJavaVersion(it, 11)
83+
project.tasks.named("compileTestJava") { dependsOn(project.tasks.named("generateTestClassNameTries")) }
84+
project.tasks.named("compileTestGroovy") { dependsOn(project.tasks.named("compileTest_java11Java")) }
85+
project.tasks.named("compileTest_java11Java") {
86+
configureCompiler(it, 11, JavaVersion.VERSION_11)
8987
}
9088

9189
final jmh = project.tasks.jmh

dd-java-agent/benchmark-integration/play-perftest/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import com.github.spotbugs.snom.SpotBugsTask
2+
13
plugins {
24
id 'org.gradle.playframework'
35
}
@@ -14,6 +16,14 @@ play {
1416
injectedRoutesGenerator = true
1517
}
1618

19+
tasks.withType(ScalaCompile).configureEach {
20+
// Despite the compatibility matrix, scala compiler doesn't properly
21+
// ger the right compiler flags with JDK11 toolchain. Using 8 works.
22+
// * https://docs.scala-lang.org/overviews/jdk-compatibility/overview.html
23+
// * https://github.com/gradle/gradle/issues/19456
24+
configureCompiler(it, 8)
25+
}
26+
1727
dependencies {
1828
implementation "com.typesafe.play:play-guice_$scalaVer:$playVer"
1929
implementation "com.typesafe.play:play-logback_$scalaVer:$playVer"

dd-java-agent/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ sourceSets {
2525
}
2626
}
2727

28-
compileMain_java6Java.configure {
29-
setJavaVersion(it, 8, true)
30-
sourceCompatibility = JavaVersion.VERSION_1_6
31-
targetCompatibility = JavaVersion.VERSION_1_6
28+
def java6compileTask = tasks.named("compileMain_java6Java") {
29+
configureCompiler(it, 8, JavaVersion.VERSION_1_6)
3230
}
3331

34-
tasks.compileJava.dependsOn compileMain_java6Java
32+
tasks.named("compileJava") {
33+
dependsOn(java6compileTask)
34+
}
3535

3636
dependencies {
3737
main_java6CompileOnly 'de.thetaphi:forbiddenapis:3.8'

0 commit comments

Comments
 (0)