1buildscript { 2 3 /* 4 * These property group is used to build kotlinx.coroutines against Kotlin compiler snapshot. 5 * How does it work: 6 * When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version, 7 * atomicfu_version is overwritten by TeamCity environment (AFU is built with snapshot and published to mavenLocal 8 * as previous step or the snapshot build). 9 * Additionally, mavenLocal and Sonatype snapshots are added to repository list and stress tests are disabled. 10 * DO NOT change the name of these properties without adapting kotlinx.train build chain. 11 */ 12 def prop = rootProject.properties['build_snapshot_train'] 13 ext.build_snapshot_train = prop != null && prop != "" 14 if (build_snapshot_train) { 15 ext.kotlin_version = rootProject.properties['kotlin_snapshot_version'] 16 if (kotlin_version == null) { 17 throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler") 18 } 19 } 20 ext.native_targets_enabled = rootProject.properties['disable_native_targets'] == null 21 22 // Determine if any project dependency is using a snapshot version 23 ext.using_snapshot_version = build_snapshot_train 24 rootProject.properties.each { key, value -> 25 if (key.endsWith("_version") && value instanceof String && value.endsWith("-SNAPSHOT")) { 26 println("NOTE: USING SNAPSHOT VERSION: $key=$value") 27 ext.using_snapshot_version = true 28 } 29 } 30 31 if (using_snapshot_version) { 32 repositories { 33 mavenLocal() 34 maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" } 35 } 36 } 37 38} 39 40plugins { 41 id "org.jetbrains.kotlin.jvm" version "$kotlin_version" 42} 43 44repositories { 45 if (build_snapshot_train) { 46 maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev" } 47 } 48 mavenLocal() 49 mavenCentral() 50} 51 52java { 53 sourceCompatibility = JavaVersion.VERSION_1_8 54 targetCompatibility = JavaVersion.VERSION_1_8 55} 56 57dependencies { 58 testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" 59 testImplementation "org.ow2.asm:asm:$asm_version" 60 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 61} 62 63sourceSets { 64 // An assortment of tests for behavior of the core coroutines module on JVM 65 jvmCoreTest { 66 kotlin 67 compileClasspath += sourceSets.test.runtimeClasspath 68 runtimeClasspath += sourceSets.test.runtimeClasspath 69 70 dependencies { 71 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 72 implementation 'com.google.guava:guava:31.1-jre' 73 } 74 } 75 // Checks correctness of Maven publication (JAR resources) and absence of atomicfu symbols 76 mavenTest { 77 kotlin 78 compileClasspath += sourceSets.test.runtimeClasspath 79 runtimeClasspath += sourceSets.test.runtimeClasspath 80 81 dependencies { 82 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 83 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" 84 } 85 } 86 // Checks that kotlinx-coroutines-debug can be used as -javaagent parameter 87 debugAgentTest { 88 kotlin 89 compileClasspath += sourceSets.test.runtimeClasspath 90 runtimeClasspath += sourceSets.test.runtimeClasspath 91 92 dependencies { 93 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 94 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version" 95 } 96 } 97 98 // Checks that kotlinx-coroutines-debug agent can self-attach dynamically to JVM as a standalone dependency 99 debugDynamicAgentTest { 100 kotlin 101 compileClasspath += sourceSets.test.runtimeClasspath 102 runtimeClasspath += sourceSets.test.runtimeClasspath 103 104 dependencies { 105 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 106 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version" 107 } 108 } 109 110 // Checks that kotlinx-coroutines-core can be used as -javaagent parameter 111 coreAgentTest { 112 kotlin 113 compileClasspath += sourceSets.test.runtimeClasspath 114 runtimeClasspath += sourceSets.test.runtimeClasspath 115 116 dependencies { 117 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 118 } 119 } 120} 121 122compileDebugAgentTestKotlin { 123 kotlinOptions { 124 freeCompilerArgs += ["-Xallow-kotlin-package"] 125 jvmTarget = "1.8" 126 } 127} 128 129task jvmCoreTest(type: Test) { 130 environment "version", coroutines_version 131 def sourceSet = sourceSets.jvmCoreTest 132 testClassesDirs = sourceSet.output.classesDirs 133 classpath = sourceSet.runtimeClasspath 134} 135 136task mavenTest(type: Test) { 137 environment "version", coroutines_version 138 def sourceSet = sourceSets.mavenTest 139 testClassesDirs = sourceSet.output.classesDirs 140 classpath = sourceSet.runtimeClasspath 141} 142 143task debugAgentTest(type: Test) { 144 def sourceSet = sourceSets.debugAgentTest 145 def coroutinesDebugJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-debug-${coroutines_version}.jar" }.singleFile 146 jvmArgs ('-javaagent:' + coroutinesDebugJar) 147 testClassesDirs = sourceSet.output.classesDirs 148 classpath = sourceSet.runtimeClasspath 149 systemProperties project.properties.subMap(["overwrite.probes"]) 150} 151 152task debugDynamicAgentTest(type: Test) { 153 def sourceSet = sourceSets.debugDynamicAgentTest 154 testClassesDirs = sourceSet.output.classesDirs 155 classpath = sourceSet.runtimeClasspath 156} 157 158task coreAgentTest(type: Test) { 159 def sourceSet = sourceSets.coreAgentTest 160 def coroutinesCoreJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-core-jvm-${coroutines_version}.jar" }.singleFile 161 jvmArgs ('-javaagent:' + coroutinesCoreJar) 162 testClassesDirs = sourceSet.output.classesDirs 163 classpath = sourceSet.runtimeClasspath 164} 165 166compileTestKotlin { 167 kotlinOptions.jvmTarget = "17" 168} 169 170check { 171 dependsOn([jvmCoreTest, debugDynamicAgentTest, mavenTest, debugAgentTest, coreAgentTest, ":jpmsTest:check", 'smokeTest:build', "java8Test:check"]) 172} 173 174compileKotlin { 175 kotlinOptions { 176 jvmTarget = "17" 177 } 178} 179 180kotlin.jvmToolchain(17) 181 182// Drop this when node js version become stable 183tasks.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask.class).configureEach { 184 it.args.add("--ignore-engines") 185} 186 187tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile.class).configureEach { 188 jvmTargetValidationMode = org.jetbrains.kotlin.gradle.dsl.jvm.JvmTargetValidationMode.WARNING 189} 190