From 36fe07e159b2fee6cee11970dbaa4607d411522a Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Tue, 24 Apr 2018 17:13:34 +0700 Subject: [PATCH] [gradle-plugin] Fix version according to the new versioning system --- samples/curl/build.gradle | 2 +- .../org/jetbrains/kotlin/VersionGenerator.kt | 4 +++- .../kotlin-native-gradle-plugin/build.gradle | 24 +++++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/samples/curl/build.gradle b/samples/curl/build.gradle index 2788acf56a7..cb530c66b62 100644 --- a/samples/curl/build.gradle +++ b/samples/curl/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+" + classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:${project.property('konan.plugin.version')}" } } konan.targets = ['macbook', 'linux'] diff --git a/shared/buildSrc/src/main/kotlin/org/jetbrains/kotlin/VersionGenerator.kt b/shared/buildSrc/src/main/kotlin/org/jetbrains/kotlin/VersionGenerator.kt index 655b5f6c4cf..719575dd862 100644 --- a/shared/buildSrc/src/main/kotlin/org/jetbrains/kotlin/VersionGenerator.kt +++ b/shared/buildSrc/src/main/kotlin/org/jetbrains/kotlin/VersionGenerator.kt @@ -17,7 +17,9 @@ open class VersionGenerator: DefaultTask() { @Input get() = project.properties["konanVersion"].toString() val buildNumber: String? - @Optional @Input get() = System.getenv("BUILD_NUMBER") + // TeamCity passes all configuration parameters into a build script as project properties. + // Thus we can use them here instead of environment variables. + @Optional @Input get() = project.findProperty("build.number")?.toString() val meta: String @Input get() = project.properties["konanMetaVersion"]?.let { diff --git a/tools/kotlin-native-gradle-plugin/build.gradle b/tools/kotlin-native-gradle-plugin/build.gradle index d351a896b50..964fef85f8a 100644 --- a/tools/kotlin-native-gradle-plugin/build.gradle +++ b/tools/kotlin-native-gradle-plugin/build.gradle @@ -42,7 +42,23 @@ apply plugin: 'com.jfrog.bintray' apply plugin: 'com.github.johnrengelman.shadow' group = 'org.jetbrains.kotlin' -version = konanVersion + +// Gradle doesn't allow using the KonanVersion class defined in `shared` from this build. +// TODO: Investigate if we can workaround this issue in better way. +def metaVersion = project.findProperty("konanMetaVersion")?.toString()?.toLowerCase() ?: "dev" +switch (metaVersion) { + case "dev": + // Use a full build number (e.g. 0.7-dev-123) for dev builds to distinguish them. + version = project.findProperty("build.number")?.toString() ?: konanVersion + break + case "rel": + // Use the version specified for the project (e.g. 0.7) in case of release builds. + version = konanVersion + break + default: + // Just append the meta-version in other cases, e.g. 0.7-rc1, 0.7-beta + version = "$konanVersion-$metaVersion" +} repositories { mavenCentral() @@ -161,11 +177,11 @@ bintray { licenses = ['Apache-2.0'] vcsUrl = 'https://github.com/JetBrains/kotlin-native' version { - name = konanVersion + name = project.version desc = "Kotlin Native Gradle plugin $konanVersion" } - publish = true // project.hasProperty("publish") - override = project.hasProperty("override") + publish = project.hasProperty("bintrayPublish") + override = project.hasProperty("bintrayOverride") } publications = ['gradlePlugin'] }