From 3d8486e8a6a5b828acf42e1fe588dfa3b08e454a Mon Sep 17 00:00:00 2001 From: Andrey Mischenko Date: Thu, 21 Sep 2017 05:50:50 +0200 Subject: [PATCH] Allow to use Gradle property to configure JDK path --- ReadMe.md | 2 ++ buildSrc/src/main/kotlin/jdksFinder.kt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ReadMe.md b/ReadMe.md index 6bc7e7d5305..1e2cec4c29f 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -40,6 +40,8 @@ In order to build Kotlin distribution you need to have: For local development, if you're not working on bytecode generation or the standard library, it's OK to have only JDK 8 installed, and to point all of the environment variables mentioned above to your JDK 8 installation. +You also can use [Gradle properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_properties_and_system_properties) to setup JDK_* variables. + > Note: The JDK 6 for MacOS is not available on Oracle's site. You can [download it here](https://support.apple.com/kb/DL1572). ## Building diff --git a/buildSrc/src/main/kotlin/jdksFinder.kt b/buildSrc/src/main/kotlin/jdksFinder.kt index d8677660167..ae4607a1a2d 100644 --- a/buildSrc/src/main/kotlin/jdksFinder.kt +++ b/buildSrc/src/main/kotlin/jdksFinder.kt @@ -19,7 +19,8 @@ data class JdkId(val explicit: Boolean, val majorVersion: JdkMajorVersion, var v fun Project.getConfiguredJdks(): List { val res = arrayListOf() for (jdkMajorVersion in JdkMajorVersion.values()) { - val explicitJdkEnvVal = System.getenv(jdkMajorVersion.name) + val explicitJdkEnvVal = findProperty(jdkMajorVersion.name)?.toString() + ?: System.getenv(jdkMajorVersion.name) ?: jdkAlternativeVarNames[jdkMajorVersion]?.mapNotNull { System.getenv(it) }?.firstOrNull() ?: continue val explicitJdk = File(explicitJdkEnvVal)