aboutsummaryrefslogtreecommitdiff
path: root/build.gradle.kts
diff options
context:
space:
mode:
Diffstat (limited to 'build.gradle.kts')
-rw-r--r--build.gradle.kts32
1 files changed, 32 insertions, 0 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index c3bba96..b6214a3 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -20,6 +20,9 @@ repositories {
val testA by sourceSets.creating
val testB by sourceSets.creating
+kotlinVersion("1.5.21", isPrimaryVersion = true)
+kotlinVersion("1.6.20")
+
dependencies {
api("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.21")
implementation(kotlin("stdlib"))
@@ -49,3 +52,32 @@ publishing {
tasks.test {
useJUnitPlatform()
}
+
+fun kotlinVersion(version: String, isPrimaryVersion: Boolean = false) {
+ val name = version.replace(".", "")
+
+ val sourceSet = sourceSets.create("kotlin$name")
+
+ val testClasspath = configurations.create("kotlin${name}TestClasspath") {
+ extendsFrom(configurations.testRuntimeClasspath.get())
+ extendsFrom(configurations[sourceSet.compileOnlyConfigurationName])
+ }
+
+ dependencies {
+ implementation(sourceSet.output)
+ sourceSet.compileOnlyConfigurationName("org.jetbrains.kotlin:kotlin-compiler-embeddable:$version")
+ }
+
+ tasks.jar {
+ from(sourceSet.output)
+ }
+
+ if (!isPrimaryVersion) {
+ val testTask = tasks.register("testKotlin$name", Test::class) {
+ useJUnitPlatform()
+ testClassesDirs = sourceSets.test.get().output.classesDirs
+ classpath = testClasspath + sourceSets.test.get().output + sourceSets.main.get().output
+ }
+ tasks.check { dependsOn(testTask) }
+ }
+}