Skip to content

Use JDK 8 by default #8883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 9 additions & 10 deletions buildSrc/src/main/groovy/InstrumentPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,16 @@ abstract class InstrumentTask extends DefaultTask {
}

private workQueue() {
if (this.javaVersion) {
def javaLauncher = this.javaToolchainService.launcherFor { spec ->
spec.languageVersion.set(JavaLanguageVersion.of(this.javaVersion))
}.get()
return this.workerExecutor.processIsolation { spec ->
spec.forkOptions { fork ->
fork.executable = javaLauncher.executablePath
}
if (!this.javaVersion) {
this.javaVersion = "8"
}
def javaLauncher = this.javaToolchainService.launcherFor { spec ->
spec.languageVersion.set(JavaLanguageVersion.of(this.javaVersion))
}.get()
return this.workerExecutor.processIsolation { spec ->
spec.forkOptions { fork ->
fork.executable = javaLauncher.executablePath
}
} else {
return this.workerExecutor.noIsolation()
}
}
}
Expand Down
18 changes: 7 additions & 11 deletions buildSrc/src/main/groovy/MuzzlePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -715,18 +715,14 @@ abstract class MuzzleTask extends DefaultTask {
Project instrumentationProject,
MuzzleDirective muzzleDirective = null) {
def workQueue
String javaVersion = muzzleDirective?.javaVersion
if (javaVersion) {
def javaLauncher = javaToolchainService.launcherFor { spec ->
spec.languageVersion.set(JavaLanguageVersion.of(javaVersion))
}.get()
workQueue = workerExecutor.processIsolation { spec ->
spec.forkOptions { fork ->
fork.executable = javaLauncher.executablePath
}
String javaVersion = muzzleDirective?.javaVersion ?: "8"
def javaLauncher = javaToolchainService.launcherFor { spec ->
spec.languageVersion.set(JavaLanguageVersion.of(javaVersion))
}.get()
workQueue = workerExecutor.processIsolation { spec ->
spec.forkOptions { fork ->
fork.executable = javaLauncher.executablePath
}
} else {
workQueue = workerExecutor.noIsolation()
}
workQueue.submit(MuzzleAction.class, parameters -> {
parameters.buildStartedTime.set(invocationDetails.buildStartedTime)
Expand Down
10 changes: 5 additions & 5 deletions dd-java-agent/agent-bootstrap/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ plugins {
id 'me.champeau.jmh'
}

ext {
// need access to sun.* packages
skipSettingCompilerRelease = true
}

apply from: "$rootDir/gradle/java.gradle"
apply plugin: "idea"

tasks.named("compileJava", JavaCompile).configure {
// need access to sun.* packages
setJavaVersion(it, 8)
}

// FIXME: Improve test coverage.
minimumBranchCoverage = 0.0
minimumInstructionCoverage = 0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ 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
// need access to jdk.jfr package
skipSettingCompilerRelease = true
excludeJdk = ['SEMERU11', 'SEMERU17']
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ ext {
// of ByteBuffer.position(int) which is binary incompatible with Java 8 ¯\_(ツ)_/¯
minJavaVersionForTests = JavaVersion.VERSION_11

// need access to jdk.jfr package
skipSettingCompilerRelease = true

excludeJdk = ['SEMERU11', 'SEMERU17']
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Set properties before any plugins get loaded
ext {
minJavaVersionForTests = JavaVersion.VERSION_1_8

// need access to jdk.jfr package
skipSettingCompilerRelease = true
}

apply from: "$rootDir/gradle/java.gradle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ 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
// need access to jdk.jfr package
skipSettingCompilerRelease = true
}

apply from: "$rootDir/gradle/java.gradle"
Expand Down Expand Up @@ -39,6 +37,10 @@ dependencies {
[JavaCompile, GroovyCompile].each {
tasks.withType(it).configureEach {
setJavaVersion(it, 11)
if (it instanceof JavaCompile) {
// need access to jdk.jfr package
options.release = null
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// Disable '-processing' because some annotations are not claimed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ 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 ORACLE8
skipSettingTestJavaVersion = true
// need access to jdk.jfr package
skipSettingCompilerRelease = true
}

apply from: "$rootDir/gradle/java.gradle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ muzzle {
}
}

ext {
skipSettingCompilerRelease = true
}
apply from: "${rootDir}/gradle/java.gradle"

compileJava {
Expand Down
1 change: 1 addition & 0 deletions dd-java-agent/instrumentation/mule-4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ tasks.register('extractLatestMuleServices', Sync) {
// build the mule application via maven
tasks.register('mvnPackage', Exec) {
workingDir "$appDir"
environment.JAVA_HOME = System.getenv("JAVA_8_HOME")
commandLine "$rootDir/mvnw", "-Ddatadog.builddir=$buildDir", "-Ddatadog.name=mule-test-application", "-Ddatadog.version=$version", 'package'
outputs.dir("$buildDir/target")
inputs.dir("$appDir/src")
Expand Down
7 changes: 5 additions & 2 deletions dd-java-agent/instrumentation/rmi/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
ext {
// need access to sun.rmi package
skipSettingCompilerRelease = true
// TODO Java 17: The necessary packages are not opened on Java 17
maxJavaVersionForTests = JavaVersion.VERSION_15
}
Expand All @@ -13,6 +11,11 @@ muzzle {

apply from: "$rootDir/gradle/java.gradle"

tasks.withType(JavaCompile).configureEach {
// need access to sun.rmi package
setJavaVersion(it, 8)
}

def rmic = tasks.register('rmic', Exec) {
dependsOn testClasses

Expand Down
8 changes: 4 additions & 4 deletions dd-java-agent/testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ plugins {
id 'com.gradleup.shadow'
}

ext {
apply from: "$rootDir/gradle/java.gradle"

tasks.withType(JavaCompile).configureEach {
// need access to sun.misc package
skipSettingCompilerRelease = true
setJavaVersion(it, 8)
}

apply from: "$rootDir/gradle/java.gradle"

minimumBranchCoverage = 0.5
minimumInstructionCoverage = 0.5
excludedClassesCoverage += [
Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/quarkus/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew'
// define the task that builds the quarkus project
tasks.register('quarkusBuild', Exec) {
workingDir "$appDir"
environment.JAVA_HOME = System.getenv("JAVA_8_HOME")
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()}"

Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/spring-boot-2.7-webflux/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew'
// define the task that builds the quarkus project
tasks.register('webfluxBuild', Exec) {
workingDir "$appDir"
environment.JAVA_HOME = System.getenv("JAVA_8_HOME")
environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'"]
commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}"

Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/springboot-openliberty-20/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def mvnwCommand = isWindows ? 'mvnw.cmd' : 'mvnw'
// compile the Open liberty spring boot server
tasks.register('mvnStage', Exec) {
workingDir "$appDir"
environment.JAVA_HOME = System.getenv("JAVA_8_HOME")
commandLine "$rootDir/${mvnwCommand}", 'package', "-Dtarget.dir=${buildDir}/application/target"
inputs.dir "$appDir/src"
inputs.file "$appDir/pom.xml"
Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/springboot-openliberty-23/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def mvnwCommand = isWindows ? 'mvnw.cmd' : 'mvnw'
// compile the Open liberty spring boot server
tasks.register('mvnStage', Exec) {
workingDir "$appDir"
environment.JAVA_HOME = System.getenv("JAVA_8_HOME")
commandLine "$rootDir/${mvnwCommand}", 'package', "-Dtarget.dir=${buildDir}/application/target"
inputs.dir "$appDir/src"
inputs.file "$appDir/pom.xml"
Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/vertx-3.4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew'
// define the task that builds the quarkus project
tasks.register('vertxBuild', Exec) {
workingDir "$appDir"
environment.JAVA_HOME = System.getenv("JAVA_8_HOME")
environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'"]
commandLine "$appDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}"

Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/vertx-3.9-resteasy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew'
// define the task that builds the quarkus project
tasks.register('vertxBuild', Exec) {
workingDir "$appDir"
environment.JAVA_HOME = System.getenv("JAVA_8_HOME")
environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'"]
commandLine "$appDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}"

Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/vertx-3.9/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew'
// define the task that builds the quarkus project
tasks.register('vertxBuild', Exec) {
workingDir "$appDir"
environment.JAVA_HOME = System.getenv("JAVA_8_HOME")
environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'"]
commandLine "$appDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}"

Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/vertx-4.2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew'
// define the task that builds the quarkus project
tasks.register('vertxBuild', Exec) {
workingDir "$appDir"
environment.JAVA_HOME = System.getenv("JAVA_8_HOME")
environment += ["GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'"]
commandLine "$appDir/${gradlewCommand}", "assemble", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}"

Expand Down
1 change: 1 addition & 0 deletions dd-smoke-tests/wildfly/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.getenv("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()}"

Expand Down
20 changes: 9 additions & 11 deletions gradle/java_no_deps.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import org.gradle.jvm.toolchain.internal.SpecificInstallationToolchainSpec

apply plugin: 'java-library'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

apply from: "$rootDir/gradle/codenarc.gradle"
apply from: "$rootDir/gradle/forbiddenapis.gradle"
apply from: "$rootDir/gradle/spotless.gradle"
Expand Down Expand Up @@ -34,17 +43,6 @@ if (applyCodeCoverage) {
apply from: "$rootDir/gradle/jacoco.gradle"
}

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
}
}

if (project.hasProperty('minJavaVersionForTests') && project.getProperty('minJavaVersionForTests') != JavaVersion.VERSION_1_7) {
def version = JavaVersion.toVersion(project.getProperty('minJavaVersionForTests'))
def name = "java$version.majorVersion"
Expand Down
15 changes: 2 additions & 13 deletions internal-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,11 @@ plugins {
id 'me.champeau.jmh'
}

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)
}
}

apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/tries.gradle"

tasks.compileTestJava.configure {
tasks.withType(JavaCompile).configureEach {
// need access to sun.misc.SharedSecrets
setJavaVersion(it, 8)
}

Expand Down
Loading