Allow to avoid using JDK 1.6 and JDK 1.7 in the repo.
This behaviour could be enabled via adding 'kotlin.build.isObsoleteJdkOverrideEnabled=true' to the 'local.properties' file. ^KT-46972 Fixed
This commit is contained in:
@@ -56,6 +56,10 @@ Alternatively, it is still possible to only provide required JDKs via environmen
|
|||||||
from environmental variables - disable Gradle toolchain auto-detection by passing `-Porg.gradle.java.installations.auto-detect=false` option
|
from environmental variables - disable Gradle toolchain auto-detection by passing `-Porg.gradle.java.installations.auto-detect=false` option
|
||||||
(or put it into `$GRADLE_USER_HOME/gradle.properties`).
|
(or put it into `$GRADLE_USER_HOME/gradle.properties`).
|
||||||
|
|
||||||
|
For local development, if you're not working on bytecode generation or the standard library, it's OK to avoid installing JDK 1.6 and JDK 1.7.
|
||||||
|
Add `kotlin.build.isObsoleteJdkOverrideEnabled=true` to the `local.properties` file, so build will only use JDK 1.8+. Note, that in this
|
||||||
|
case, build will have Gradle remote build cache misses for some tasks.
|
||||||
|
|
||||||
Note: The JDK 6 for MacOS is not available on Oracle's site. You can install it by
|
Note: The JDK 6 for MacOS is not available on Oracle's site. You can install it by
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -20,3 +20,7 @@ val KotlinBuildProperties.jarCompression: Boolean get() = getBoolean("kotlin.bui
|
|||||||
val KotlinBuildProperties.ignoreTestFailures: Boolean get() = getBoolean("ignoreTestFailures", isTeamcityBuild)
|
val KotlinBuildProperties.ignoreTestFailures: Boolean get() = getBoolean("ignoreTestFailures", isTeamcityBuild)
|
||||||
|
|
||||||
val KotlinBuildProperties.disableWerror: Boolean get() = getBoolean("kotlin.build.disable.werror", false)
|
val KotlinBuildProperties.disableWerror: Boolean get() = getBoolean("kotlin.build.disable.werror", false)
|
||||||
|
|
||||||
|
val KotlinBuildProperties.isObsoleteJdkOverrideEnabled: Boolean
|
||||||
|
get() = !isTeamcityBuild &&
|
||||||
|
getBoolean("kotlin.build.isObsoleteJdkOverrideEnabled", false)
|
||||||
|
|||||||
@@ -10,16 +10,18 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||||||
|
|
||||||
enum class JdkMajorVersion(
|
enum class JdkMajorVersion(
|
||||||
val majorVersion: Int,
|
val majorVersion: Int,
|
||||||
|
val targetName: String = majorVersion.toString(),
|
||||||
|
val overrideMajorVersion: Int? = null,
|
||||||
private val mandatory: Boolean = true
|
private val mandatory: Boolean = true
|
||||||
) {
|
) {
|
||||||
JDK_1_6(6),
|
JDK_1_6(6, targetName = "1.6", overrideMajorVersion = 8),
|
||||||
JDK_1_7(7),
|
JDK_1_7(7, targetName = "1.7", overrideMajorVersion = 8),
|
||||||
JDK_1_8(8),
|
JDK_1_8(8, targetName = "1.8"),
|
||||||
JDK_9(9),
|
JDK_9(9),
|
||||||
JDK_10(10, false),
|
JDK_10(10, mandatory = false),
|
||||||
JDK_11(11, false),
|
JDK_11(11, mandatory = false),
|
||||||
JDK_15(15, false),
|
JDK_15(15, mandatory = false),
|
||||||
JDK_16(16, false);
|
JDK_16(16, mandatory = false);
|
||||||
|
|
||||||
fun isMandatory(): Boolean = mandatory
|
fun isMandatory(): Boolean = mandatory
|
||||||
}
|
}
|
||||||
@@ -34,9 +36,19 @@ fun Project.configureJvmToolchain(
|
|||||||
plugins.withId("org.jetbrains.kotlin.jvm") {
|
plugins.withId("org.jetbrains.kotlin.jvm") {
|
||||||
val kotlinExtension = extensions.getByType<KotlinTopLevelExtension>()
|
val kotlinExtension = extensions.getByType<KotlinTopLevelExtension>()
|
||||||
|
|
||||||
kotlinExtension.jvmToolchain {
|
if (project.kotlinBuildProperties.isObsoleteJdkOverrideEnabled &&
|
||||||
(this as JavaToolchainSpec).languageVersion
|
jdkVersion.overrideMajorVersion != null
|
||||||
.set(JavaLanguageVersion.of(jdkVersion.majorVersion))
|
) {
|
||||||
|
kotlinExtension.jvmToolchain {
|
||||||
|
(this as JavaToolchainSpec).languageVersion
|
||||||
|
.set(JavaLanguageVersion.of(jdkVersion.overrideMajorVersion))
|
||||||
|
}
|
||||||
|
updateJvmTarget(jdkVersion.targetName)
|
||||||
|
} else {
|
||||||
|
kotlinExtension.jvmToolchain {
|
||||||
|
(this as JavaToolchainSpec).languageVersion
|
||||||
|
.set(JavaLanguageVersion.of(jdkVersion.majorVersion))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks
|
tasks
|
||||||
|
|||||||
Reference in New Issue
Block a user