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.
This commit is contained in:
parent
e609011754
commit
941c215d52
|
@ -120,9 +120,9 @@ public class GenerateGlobalBuildInfoTask extends DefaultTask {
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
public void generate() {
|
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 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") + "]";
|
+ " " + System.getProperty("java.vm.version") + "]";
|
||||||
|
|
||||||
String compilerJavaVersionDetails = gradleJavaVersionDetails;
|
String compilerJavaVersionDetails = gradleJavaVersionDetails;
|
||||||
|
@ -231,8 +231,10 @@ public class GenerateGlobalBuildInfoTask extends DefaultTask {
|
||||||
*/
|
*/
|
||||||
private String findJavaVersionDetails(File javaHome) {
|
private String findJavaVersionDetails(File javaHome) {
|
||||||
String versionInfoScript = "print(" +
|
String versionInfoScript = "print(" +
|
||||||
"java.lang.System.getProperty(\"java.vendor\") + \" \" + java.lang.System.getProperty(\"java.version\") + " +
|
"java.lang.System.getProperty(\"java.vendor.version\", java.lang.System.getProperty(\"java.vendor\")) + \" \" + " +
|
||||||
"\" [\" + java.lang.System.getProperty(\"java.vm.name\") + \" \" + java.lang.System.getProperty(\"java.vm.version\") + \"]\");";
|
"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();
|
return runJavaAsScript(javaHome, versionInfoScript).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue