From 4638988c2fd81bf5119f7ecbf0cf4caf9ecc0b3b Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Sun, 22 Nov 2020 18:36:30 +0300 Subject: [PATCH] Use project's kotlin compiler version and repo for the samples --- .../org/jetbrains/kotlin/CopySamples.kt | 21 ++++++++++++++++++- kotlin-native/samples/build.gradle.kts | 6 ++++++ kotlin-native/samples/gradle.properties | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CopySamples.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CopySamples.kt index 71a560c4f32..c7c8f8a7a57 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CopySamples.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/CopySamples.kt @@ -8,8 +8,9 @@ import java.io.File /** * A task that copies samples and replaces direct repository URLs with ones provided by the cache-redirector service. + * This task also adds kotlin compiler repository from the project's gradle.properties file. */ -open class CopySamples: Copy() { +open class CopySamples : Copy() { @InputDirectory var samplesDir: File = project.file("samples") @@ -17,6 +18,7 @@ open class CopySamples: Copy() { from(samplesDir) { it.exclude("**/*.gradle.kts") it.exclude("**/*.gradle") + it.exclude("**/gradle.properties") } from(samplesDir) { it.include("**/*.gradle") @@ -34,6 +36,23 @@ open class CopySamples: Copy() { replacements[repo]?.let { r -> line.replace(repo, r) } ?: line } } + from(samplesDir) { + it.include("**/gradle.properties") + + val kotlinVersion = project.property("kotlinVersion") as? String + ?: throw IllegalArgumentException("Property kotlinVersion should be specified in the root project") + val kotlinCompilerRepo = project.property("kotlinCompilerRepo") as? String + ?: throw IllegalArgumentException("Property kotlinCompilerRepo should be specified in the root project") + + it.filter { line -> + when { + line.startsWith("kotlin_version") -> "kotlin_version=$kotlinVersion" + line.startsWith("#kotlinCompilerRepo") || line.startsWith("kotlinCompilerRepo") -> + "kotlinCompilerRepo=$kotlinCompilerRepo" + else -> line + } + } + } } override fun configure(closure: Closure): Task { diff --git a/kotlin-native/samples/build.gradle.kts b/kotlin-native/samples/build.gradle.kts index 5dd47dbed61..8dad36331b5 100644 --- a/kotlin-native/samples/build.gradle.kts +++ b/kotlin-native/samples/build.gradle.kts @@ -3,6 +3,9 @@ buildscript { mavenCentral() maven("https://dl.bintray.com/kotlin/kotlin-dev") maven("https://dl.bintray.com/kotlin/kotlin-eap") + + val kotlinCompilerRepo: String? by rootProject + kotlinCompilerRepo?.let { maven(it) } } val kotlin_version: String by rootProject @@ -16,6 +19,9 @@ allprojects { mavenCentral() maven("https://dl.bintray.com/kotlin/kotlin-dev") maven("https://dl.bintray.com/kotlin/kotlin-eap") + + val kotlinCompilerRepo: String? by rootProject + kotlinCompilerRepo?.let { maven(it) } } } diff --git a/kotlin-native/samples/gradle.properties b/kotlin-native/samples/gradle.properties index 3782789d9b7..1c05119814e 100644 --- a/kotlin-native/samples/gradle.properties +++ b/kotlin-native/samples/gradle.properties @@ -8,6 +8,9 @@ org.gradle.workers.max=4 # CHANGE_VERSION_WITH_RELEASE kotlin_version=1.4.10 +# Sets maven path for the kotlin version other than release +#kotlinCompilerRepo= + # Use custom Kotlin/Native home: kotlin.native.home=../../dist