Store resolved toolchain info as custom values in build scan
Prior to this commit, we registered custom values in the build scan for the main and test toolchains based on input values provided via the mainToolchain and testToolchain project properties. Beginning with this commit, the custom values we register are based on the available metadata for the resolved JDK/JVM for each toolchain. For example, instead of registering the following custom value... Test toolchain : JDK11 ... we now register the following which includes the vendor, version, and installation path of the JDK/JVM. Test toolchain : AdoptOpenJDK 11 (/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home) Once Gradle's JavaInstallationMetadata includes the exact version, we will likely use that instead of the installation path. See gh-25787
This commit is contained in:
parent
2c2464b1e7
commit
38b592444d
|
|
@ -29,6 +29,7 @@
|
|||
* }
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
|
||||
def mainToolchainConfigured() {
|
||||
|
|
@ -129,7 +130,7 @@ pluginManager.withPlugin("kotlin") {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (testToolchainConfigured()) {
|
||||
def testLanguageVersion = testToolchainLanguageVersion()
|
||||
def compiler = javaToolchains.compilerFor {
|
||||
|
|
@ -160,4 +161,22 @@ pluginManager.withPlugin("me.champeau.jmh") {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store resolved Toolchain JVM information as custom values in the build scan.
|
||||
rootProject.ext {
|
||||
resolvedMainToolchain = false
|
||||
resolvedTestToolchain = false
|
||||
}
|
||||
gradle.taskGraph.afterTask { Task task, TaskState state ->
|
||||
if (mainToolchainConfigured() && !resolvedMainToolchain && task instanceof JavaCompile && task.javaCompiler.isPresent()) {
|
||||
def metadata = task.javaCompiler.get().metadata
|
||||
task.project.buildScan.value('Main toolchain', "$metadata.vendor $metadata.languageVersion ($metadata.installationPath)")
|
||||
resolvedMainToolchain = true
|
||||
}
|
||||
if (testToolchainConfigured() && !resolvedTestToolchain && task instanceof Test && task.javaLauncher.isPresent()) {
|
||||
def metadata = task.javaLauncher.get().metadata
|
||||
task.project.buildScan.value('Test toolchain', "$metadata.vendor $metadata.languageVersion ($metadata.installationPath)")
|
||||
resolvedTestToolchain = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,12 +45,6 @@ rootProject.children.each {project ->
|
|||
settings.gradle.projectsLoaded {
|
||||
gradleEnterprise {
|
||||
buildScan {
|
||||
if (settings.gradle.rootProject.hasProperty('mainToolchain') && settings.gradle.rootProject.getProperty('mainToolchain')) {
|
||||
value("Main toolchain", 'JDK' + settings.gradle.rootProject.getProperty('mainToolchain'))
|
||||
}
|
||||
if (settings.gradle.rootProject.hasProperty('testToolchain') && settings.gradle.rootProject.getProperty('testToolchain')) {
|
||||
value("Test toolchain", 'JDK' + settings.gradle.rootProject.getProperty('testToolchain'))
|
||||
}
|
||||
File buildDir = settings.gradle.rootProject.getBuildDir()
|
||||
buildDir.mkdirs()
|
||||
new File(buildDir, "build-scan-uri.txt").text = "(build scan not generated)"
|
||||
|
|
|
|||
Loading…
Reference in New Issue