diff --git a/build.gradle.kts b/build.gradle.kts index 34aa4434e70..f8178d00ddc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -158,6 +158,10 @@ extra["versions.jflex"] = "1.7.0" extra["versions.markdown"] = "0.1.25" 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 intellijUltimateEnabled = project.getBooleanProperty("intellijUltimateEnabled") ?: isTeamcityBuild val effectSystemEnabled by extra(project.getBooleanProperty("kotlin.compiler.effectSystemEnabled") ?: false) diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/src/main/kotlin/dependencies.kt index 12aaefe9470..713f2e8d02b 100644 --- a/buildSrc/src/main/kotlin/dependencies.kt +++ b/buildSrc/src/main/kotlin/dependencies.kt @@ -96,6 +96,8 @@ val Project.protobufRepo: String fun Project.protobufLite(): String = "org.jetbrains.kotlin:protobuf-lite:$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()) private val wildcardsRe = """[^*?]+|(\*)|(\?)""".toRegex() diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts index 8d95877c241..541fad39efd 100644 --- a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts @@ -101,12 +101,15 @@ tasks { } named("processResources") { - val propertiesToExpand = mapOf("projectVersion" to project.version) + val propertiesToExpand = mapOf( + "projectVersion" to project.version, + "kotlinNativeVersion" to project.kotlinNativeVersion + ) for ((name, value) in propertiesToExpand) { inputs.property(name, value) } filesMatching("project.properties") { - expand("projectVersion" to project.version) + expand(propertiesToExpand) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt index 9a231c5efe3..2f59ba59647 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt @@ -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_MODULE_GROUP import org.jetbrains.kotlin.gradle.utils.checkGradleCompatibility -import java.io.FileNotFoundException -import java.util.* +import org.jetbrains.kotlin.gradle.utils.loadPropertyFromResources import javax.inject.Inject import kotlin.reflect.KClass @@ -168,14 +167,7 @@ fun Project.getKotlinPluginVersion(): String? = fun Plugin<*>.loadKotlinVersionFromResource(log: Logger): String { log.kotlinDebug("Loading version information") - val props = Properties() - 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 + val projectVersion = loadPropertyFromResources("project.properties", "project.version") log.kotlinDebug("Found project version [$projectVersion]") return projectVersion } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/NativeCompilerDownloader.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/NativeCompilerDownloader.kt index defa4ff9494..693711b6d7e 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/NativeCompilerDownloader.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/NativeCompilerDownloader.kt @@ -12,8 +12,8 @@ import org.gradle.api.file.FileTree import org.gradle.api.logging.Logger import org.jetbrains.kotlin.compilerRunner.KonanCompilerRunner import org.jetbrains.kotlin.compilerRunner.konanVersion +import org.jetbrains.kotlin.gradle.logging.kotlinInfo import org.jetbrains.kotlin.konan.KonanVersion -import org.jetbrains.kotlin.konan.KonanVersionImpl import org.jetbrains.kotlin.konan.MetaVersion import org.jetbrains.kotlin.konan.target.HostManager import org.jetbrains.kotlin.konan.util.DependencyDirectories @@ -25,7 +25,9 @@ class NativeCompilerDownloader( ) { 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" } @@ -92,8 +94,8 @@ class NativeCompilerDownloader( val configuration = project.configurations.detachedConfiguration(compilerDependency) val archive = configuration.files.single() - logger.info("Use Kotlin/Native compiler archive: ${archive.absolutePath}") - logger.lifecycle("Unpack Kotlin/Native compiler (version $versionString)...") + logger.kotlinInfo("Using Kotlin/Native compiler archive: ${archive.absolutePath}") + logger.lifecycle("Unpacking Kotlin/Native compiler (version $versionString)...") project.copy { it.from(archiveFileTree(archive)) it.into(DependencyDirectories.localKonanDir) @@ -110,4 +112,4 @@ class NativeCompilerDownloader( downloadAndExtract() } } -} +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/resourceUtils.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/resourceUtils.kt new file mode 100644 index 00000000000..84d60542954 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/resourceUtils.kt @@ -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 +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/resources/project.properties b/libraries/tools/kotlin-gradle-plugin/src/main/resources/project.properties index 652aef75695..0e7465705cb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/resources/project.properties +++ b/libraries/tools/kotlin-gradle-plugin/src/main/resources/project.properties @@ -1 +1,2 @@ -project.version=${projectVersion} \ No newline at end of file +project.version=${projectVersion} +kotlin.native.version=${kotlinNativeVersion} \ No newline at end of file