Use project's kotlin compiler version and repo for the samples

This commit is contained in:
Pavel Punegov
2020-11-22 18:36:30 +03:00
committed by Stanislav Erokhin
parent f3a0debaf8
commit 4638988c2f
3 changed files with 29 additions and 1 deletions
@@ -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<Any>): Task {
+6
View File
@@ -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) }
}
}
+3
View File
@@ -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