Store Kotlin/Native version in properties
Previously the Kotlin/Native version was hardcoded in sources of the Gradle plugin. Such an approach is inconvenient when we want to build Kotlin with a custom K/N version but without changes in sources (e.g. during CI daily runs). This patch adds a project property `versions.kotlin-native` which can be set during build to override Kotlin/Native version. Also this patch gets rid of hardcoding this version in sources and stores it in a properties file packed with the Gradle plugin in a jar.
This commit is contained in:
@@ -158,6 +158,10 @@ extra["versions.jflex"] = "1.7.0"
|
|||||||
extra["versions.markdown"] = "0.1.25"
|
extra["versions.markdown"] = "0.1.25"
|
||||||
extra["versions.trove4j"] = "1.0.20181211"
|
extra["versions.trove4j"] = "1.0.20181211"
|
||||||
|
|
||||||
|
if (!project.hasProperty("versions.kotlin-native")) {
|
||||||
|
extra["versions.kotlin-native"] = "1.3-dev-8848"
|
||||||
|
}
|
||||||
|
|
||||||
val isTeamcityBuild = project.hasProperty("teamcity") || System.getenv("TEAMCITY_VERSION") != null
|
val isTeamcityBuild = project.hasProperty("teamcity") || System.getenv("TEAMCITY_VERSION") != null
|
||||||
val intellijUltimateEnabled = project.getBooleanProperty("intellijUltimateEnabled") ?: isTeamcityBuild
|
val intellijUltimateEnabled = project.getBooleanProperty("intellijUltimateEnabled") ?: isTeamcityBuild
|
||||||
val effectSystemEnabled by extra(project.getBooleanProperty("kotlin.compiler.effectSystemEnabled") ?: false)
|
val effectSystemEnabled by extra(project.getBooleanProperty("kotlin.compiler.effectSystemEnabled") ?: false)
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ val Project.protobufRepo: String
|
|||||||
fun Project.protobufLite(): String = "org.jetbrains.kotlin:protobuf-lite:$protobufVersion"
|
fun Project.protobufLite(): String = "org.jetbrains.kotlin:protobuf-lite:$protobufVersion"
|
||||||
fun Project.protobufFull(): String = "org.jetbrains.kotlin:protobuf-relocated:$protobufVersion"
|
fun Project.protobufFull(): String = "org.jetbrains.kotlin:protobuf-relocated:$protobufVersion"
|
||||||
|
|
||||||
|
val Project.kotlinNativeVersion: String get() = property("versions.kotlin-native") as String
|
||||||
|
|
||||||
fun File.matchMaybeVersionedArtifact(baseName: String) = name.matches(baseName.toMaybeVersionedJarRegex())
|
fun File.matchMaybeVersionedArtifact(baseName: String) = name.matches(baseName.toMaybeVersionedJarRegex())
|
||||||
|
|
||||||
private val wildcardsRe = """[^*?]+|(\*)|(\?)""".toRegex()
|
private val wildcardsRe = """[^*?]+|(\*)|(\?)""".toRegex()
|
||||||
|
|||||||
@@ -101,12 +101,15 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
named<ProcessResources>("processResources") {
|
named<ProcessResources>("processResources") {
|
||||||
val propertiesToExpand = mapOf("projectVersion" to project.version)
|
val propertiesToExpand = mapOf(
|
||||||
|
"projectVersion" to project.version,
|
||||||
|
"kotlinNativeVersion" to project.kotlinNativeVersion
|
||||||
|
)
|
||||||
for ((name, value) in propertiesToExpand) {
|
for ((name, value) in propertiesToExpand) {
|
||||||
inputs.property(name, value)
|
inputs.property(name, value)
|
||||||
}
|
}
|
||||||
filesMatching("project.properties") {
|
filesMatching("project.properties") {
|
||||||
expand("projectVersion" to project.version)
|
expand(propertiesToExpand)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-10
@@ -33,8 +33,7 @@ import org.jetbrains.kotlin.gradle.targets.js.KotlinJsPlugin
|
|||||||
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_COMPILER_EMBEDDABLE
|
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_COMPILER_EMBEDDABLE
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_MODULE_GROUP
|
import org.jetbrains.kotlin.gradle.tasks.KOTLIN_MODULE_GROUP
|
||||||
import org.jetbrains.kotlin.gradle.utils.checkGradleCompatibility
|
import org.jetbrains.kotlin.gradle.utils.checkGradleCompatibility
|
||||||
import java.io.FileNotFoundException
|
import org.jetbrains.kotlin.gradle.utils.loadPropertyFromResources
|
||||||
import java.util.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@@ -168,14 +167,7 @@ fun Project.getKotlinPluginVersion(): String? =
|
|||||||
|
|
||||||
fun Plugin<*>.loadKotlinVersionFromResource(log: Logger): String {
|
fun Plugin<*>.loadKotlinVersionFromResource(log: Logger): String {
|
||||||
log.kotlinDebug("Loading version information")
|
log.kotlinDebug("Loading version information")
|
||||||
val props = Properties()
|
val projectVersion = loadPropertyFromResources("project.properties", "project.version")
|
||||||
val propFileName = "project.properties"
|
|
||||||
val inputStream = javaClass.classLoader!!.getResourceAsStream(propFileName)
|
|
||||||
?: throw FileNotFoundException("property file '$propFileName' not found in the classpath")
|
|
||||||
|
|
||||||
props.load(inputStream)
|
|
||||||
|
|
||||||
val projectVersion = props["project.version"] as String
|
|
||||||
log.kotlinDebug("Found project version [$projectVersion]")
|
log.kotlinDebug("Found project version [$projectVersion]")
|
||||||
return projectVersion
|
return projectVersion
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-5
@@ -12,8 +12,8 @@ import org.gradle.api.file.FileTree
|
|||||||
import org.gradle.api.logging.Logger
|
import org.gradle.api.logging.Logger
|
||||||
import org.jetbrains.kotlin.compilerRunner.KonanCompilerRunner
|
import org.jetbrains.kotlin.compilerRunner.KonanCompilerRunner
|
||||||
import org.jetbrains.kotlin.compilerRunner.konanVersion
|
import org.jetbrains.kotlin.compilerRunner.konanVersion
|
||||||
|
import org.jetbrains.kotlin.gradle.logging.kotlinInfo
|
||||||
import org.jetbrains.kotlin.konan.KonanVersion
|
import org.jetbrains.kotlin.konan.KonanVersion
|
||||||
import org.jetbrains.kotlin.konan.KonanVersionImpl
|
|
||||||
import org.jetbrains.kotlin.konan.MetaVersion
|
import org.jetbrains.kotlin.konan.MetaVersion
|
||||||
import org.jetbrains.kotlin.konan.target.HostManager
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
import org.jetbrains.kotlin.konan.util.DependencyDirectories
|
import org.jetbrains.kotlin.konan.util.DependencyDirectories
|
||||||
@@ -25,7 +25,9 @@ class NativeCompilerDownloader(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
internal companion object {
|
internal companion object {
|
||||||
val DEFAULT_KONAN_VERSION = KonanVersionImpl(MetaVersion.EAP, 1, 2, 0, 8879)
|
val DEFAULT_KONAN_VERSION: KonanVersion by lazy {
|
||||||
|
KonanVersion.fromString(loadPropertyFromResources("project.properties", "kotlin.native.version"))
|
||||||
|
}
|
||||||
const val BASE_DOWNLOAD_URL = "https://download.jetbrains.com/kotlin/native/builds"
|
const val BASE_DOWNLOAD_URL = "https://download.jetbrains.com/kotlin/native/builds"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,8 +94,8 @@ class NativeCompilerDownloader(
|
|||||||
val configuration = project.configurations.detachedConfiguration(compilerDependency)
|
val configuration = project.configurations.detachedConfiguration(compilerDependency)
|
||||||
val archive = configuration.files.single()
|
val archive = configuration.files.single()
|
||||||
|
|
||||||
logger.info("Use Kotlin/Native compiler archive: ${archive.absolutePath}")
|
logger.kotlinInfo("Using Kotlin/Native compiler archive: ${archive.absolutePath}")
|
||||||
logger.lifecycle("Unpack Kotlin/Native compiler (version $versionString)...")
|
logger.lifecycle("Unpacking Kotlin/Native compiler (version $versionString)...")
|
||||||
project.copy {
|
project.copy {
|
||||||
it.from(archiveFileTree(archive))
|
it.from(archiveFileTree(archive))
|
||||||
it.into(DependencyDirectories.localKonanDir)
|
it.into(DependencyDirectories.localKonanDir)
|
||||||
@@ -110,4 +112,4 @@ class NativeCompilerDownloader(
|
|||||||
downloadAndExtract()
|
downloadAndExtract()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.utils
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
fun Any.loadPropertyFromResources(propFileName: String, property: String): String {
|
||||||
|
val props = Properties()
|
||||||
|
val inputStream = javaClass.classLoader!!.getResourceAsStream(propFileName)
|
||||||
|
?: throw FileNotFoundException("property file '$propFileName' not found in the classpath")
|
||||||
|
|
||||||
|
inputStream.use { props.load(it) }
|
||||||
|
return props[property] as String
|
||||||
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
project.version=${projectVersion}
|
project.version=${projectVersion}
|
||||||
|
kotlin.native.version=${kotlinNativeVersion}
|
||||||
Reference in New Issue
Block a user