From 941c215d52a04a95a7bdecd800125173cd57f40a Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 11 Sep 2019 15:20:08 -0400 Subject: [PATCH] Favor java.vendor.version over java.vendor (#46615) In some cases (for example some AdoptOpenJDK builds), the java.vendor is mistakenly populated as "Oracle Corporation" while the real value is under "java.vendor.version". Since "java.vendor.version" is mandatory since JDK 10, this commit changes to use "java.vendor.version" as the favored system property to find the JVM vendor, and we fallback to "java.vendor" if this is not populated (as happens in some Oracle builds). Ugh. --- .../gradle/info/GenerateGlobalBuildInfoTask.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GenerateGlobalBuildInfoTask.java b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GenerateGlobalBuildInfoTask.java index 3d247d2dd3e..cbe61a54ae9 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GenerateGlobalBuildInfoTask.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GenerateGlobalBuildInfoTask.java @@ -120,9 +120,9 @@ public class GenerateGlobalBuildInfoTask extends DefaultTask { @TaskAction public void generate() { - String javaVendor = System.getProperty("java.vendor"); + String javaVendorVersion = System.getProperty("java.vendor.version", System.getProperty("java.vendor")); String gradleJavaVersion = System.getProperty("java.version"); - String gradleJavaVersionDetails = javaVendor + " " + gradleJavaVersion + " [" + System.getProperty("java.vm.name") + String gradleJavaVersionDetails = javaVendorVersion + " " + gradleJavaVersion + " [" + System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version") + "]"; String compilerJavaVersionDetails = gradleJavaVersionDetails; @@ -231,8 +231,10 @@ public class GenerateGlobalBuildInfoTask extends DefaultTask { */ private String findJavaVersionDetails(File javaHome) { String versionInfoScript = "print(" + - "java.lang.System.getProperty(\"java.vendor\") + \" \" + java.lang.System.getProperty(\"java.version\") + " + - "\" [\" + java.lang.System.getProperty(\"java.vm.name\") + \" \" + java.lang.System.getProperty(\"java.vm.version\") + \"]\");"; + "java.lang.System.getProperty(\"java.vendor.version\", java.lang.System.getProperty(\"java.vendor\")) + \" \" + " + + "java.lang.System.getProperty(\"java.version\") + \" [\" + " + + "java.lang.System.getProperty(\"java.vm.name\") + \" \" + " + + "java.lang.System.getProperty(\"java.vm.version\") + \"]\");"; return runJavaAsScript(javaHome, versionInfoScript).trim(); }