Make some build properties extensions in buildSrc
They are used only in main build's .gradle.kts files, so it is more flexible to define them as extensions - no need to republish kotlin-build-gradle-plugin when another such property is to be added.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
val KotlinBuildProperties.includeJava9: Boolean
|
||||
get() = !isInJpsBuildIdeaSync && getBoolean("kotlin.build.java9", true)
|
||||
|
||||
val KotlinBuildProperties.useBootstrapStdlib: Boolean
|
||||
get() = isInJpsBuildIdeaSync || getBoolean("kotlin.build.useBootstrapStdlib", false)
|
||||
|
||||
val KotlinBuildProperties.postProcessing: Boolean get() = isTeamcityBuild || getBoolean("kotlin.build.postprocessing", true)
|
||||
|
||||
val KotlinBuildProperties.relocation: Boolean get() = postProcessing
|
||||
|
||||
val KotlinBuildProperties.proguard: Boolean get() = postProcessing && getBoolean("kotlin.build.proguard", isTeamcityBuild)
|
||||
|
||||
val KotlinBuildProperties.jarCompression: Boolean get() = getBoolean("kotlin.build.jar.compression", isTeamcityBuild)
|
||||
@@ -33,10 +33,10 @@ class KotlinBuildProperties(
|
||||
}
|
||||
}
|
||||
|
||||
private fun getOrNull(key: String): Any? =
|
||||
fun getOrNull(key: String): Any? =
|
||||
localProperties.getProperty(key) ?: propertiesProvider.getProperty(key) ?: rootProperties.getProperty(key)
|
||||
|
||||
private fun getBoolean(key: String, default: Boolean = false): Boolean =
|
||||
fun getBoolean(key: String, default: Boolean = false): Boolean =
|
||||
this.getOrNull(key)?.toString()?.trim()?.toBoolean() ?: default
|
||||
|
||||
private fun hasProperty(key: String): Boolean = getOrNull(key) != null
|
||||
@@ -61,12 +61,6 @@ class KotlinBuildProperties(
|
||||
val isInJpsBuildIdeaSync: Boolean
|
||||
get() = isJpsBuildEnabled && isInIdeaSync
|
||||
|
||||
val includeJava9: Boolean
|
||||
get() = !isInJpsBuildIdeaSync && getBoolean("kotlin.build.java9", true)
|
||||
|
||||
val useBootstrapStdlib: Boolean
|
||||
get() = isInJpsBuildIdeaSync || getBoolean("kotlin.build.useBootstrapStdlib", false)
|
||||
|
||||
private val kotlinUltimateExists: Boolean = propertiesProvider.rootProjectDir.resolve("kotlin-ultimate").exists()
|
||||
|
||||
val isTeamcityBuild: Boolean = getBoolean("teamcity") || System.getenv("TEAMCITY_VERSION") != null
|
||||
@@ -84,14 +78,6 @@ class KotlinBuildProperties(
|
||||
|
||||
val includeUltimate: Boolean = kotlinUltimateExists && (isTeamcityBuild || intellijUltimateEnabled)
|
||||
|
||||
val postProcessing: Boolean get() = isTeamcityBuild || getBoolean("kotlin.build.postprocessing", true)
|
||||
|
||||
val relocation: Boolean get() = postProcessing
|
||||
|
||||
val proguard: Boolean get() = postProcessing && getBoolean("kotlin.build.proguard", isTeamcityBuild)
|
||||
|
||||
val jarCompression: Boolean get() = getBoolean("kotlin.build.jar.compression", isTeamcityBuild)
|
||||
|
||||
val buildCacheUrl: String? = getOrNull("kotlin.build.cache.url") as String?
|
||||
|
||||
val pushToBuildCache: Boolean = getBoolean("kotlin.build.cache.push", isTeamcityBuild)
|
||||
|
||||
@@ -5,7 +5,7 @@ apply plugin: 'kotlin-platform-jvm'
|
||||
configureJvm6Project(project)
|
||||
configurePublishing(project)
|
||||
|
||||
def includeJava9 = BuildPropertiesKt.getKotlinBuildProperties(project).includeJava9
|
||||
def includeJava9 = BuildPropertiesExtKt.getIncludeJava9(project.kotlinBuildProperties)
|
||||
|
||||
sourceSets {
|
||||
if (includeJava9) {
|
||||
|
||||
@@ -4,7 +4,7 @@ apply plugin: 'kotlin'
|
||||
|
||||
configureJvm6Project(project)
|
||||
|
||||
def includeJava9 = BuildPropertiesKt.getKotlinBuildProperties(project).includeJava9
|
||||
def includeJava9 = BuildPropertiesExtKt.getIncludeJava9(project.kotlinBuildProperties)
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
|
||||
Reference in New Issue
Block a user