1/* 2 * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType 6 7plugins { 8 id "org.jetbrains.kotlin.jvm" 9} 10 11repositories { 12 mavenLocal() 13 mavenCentral() 14} 15 16java { 17 sourceCompatibility = JavaVersion.VERSION_1_8 18 targetCompatibility = JavaVersion.VERSION_1_8 19} 20 21dependencies { 22 testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" 23} 24 25sourceSets { 26 // Test that relies on Guava to reflectively check all Throwable subclasses in coroutines 27 withGuavaTest { 28 kotlin 29 compileClasspath += sourceSets.test.runtimeClasspath 30 runtimeClasspath += sourceSets.test.runtimeClasspath 31 32 dependencies { 33 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 34 implementation 'com.google.guava:guava:31.1-jre' 35 } 36 } 37 // Checks correctness of Maven publication (JAR resources) and absence of atomicfu symbols 38 mavenTest { 39 kotlin 40 compileClasspath += sourceSets.test.runtimeClasspath 41 runtimeClasspath += sourceSets.test.runtimeClasspath 42 43 dependencies { 44 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 45 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" 46 } 47 } 48 // Checks that kotlinx-coroutines-debug can be used as -javaagent parameter 49 debugAgentTest { 50 kotlin 51 compileClasspath += sourceSets.test.runtimeClasspath 52 runtimeClasspath += sourceSets.test.runtimeClasspath 53 54 dependencies { 55 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 56 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version" 57 } 58 } 59 60 // Checks that kotlinx-coroutines-debug agent can self-attach dynamically to JVM as standalone dependency 61 debugDynamicAgentTest { 62 kotlin 63 compileClasspath += sourceSets.test.runtimeClasspath 64 runtimeClasspath += sourceSets.test.runtimeClasspath 65 66 dependencies { 67 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 68 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version" 69 } 70 } 71 72 // Checks that kotlinx-coroutines-core can be used as -javaagent parameter 73 coreAgentTest { 74 kotlin 75 compileClasspath += sourceSets.test.runtimeClasspath 76 runtimeClasspath += sourceSets.test.runtimeClasspath 77 78 dependencies { 79 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" 80 } 81 } 82} 83 84compileDebugAgentTestKotlin { 85 kotlinOptions { 86 freeCompilerArgs += ["-Xallow-kotlin-package"] 87 } 88} 89 90task withGuavaTest(type: Test) { 91 environment "version", coroutines_version 92 def sourceSet = sourceSets.withGuavaTest 93 testClassesDirs = sourceSet.output.classesDirs 94 classpath = sourceSet.runtimeClasspath 95} 96 97task mavenTest(type: Test) { 98 environment "version", coroutines_version 99 def sourceSet = sourceSets.mavenTest 100 testClassesDirs = sourceSet.output.classesDirs 101 classpath = sourceSet.runtimeClasspath 102} 103 104task debugAgentTest(type: Test) { 105 def sourceSet = sourceSets.debugAgentTest 106 def coroutinesDebugJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-debug-${coroutines_version}.jar" }.singleFile 107 jvmArgs ('-javaagent:' + coroutinesDebugJar) 108 testClassesDirs = sourceSet.output.classesDirs 109 classpath = sourceSet.runtimeClasspath 110 systemProperties project.properties.subMap(["overwrite.probes"]) 111} 112 113task debugDynamicAgentTest(type: Test) { 114 def sourceSet = sourceSets.debugDynamicAgentTest 115 testClassesDirs = sourceSet.output.classesDirs 116 classpath = sourceSet.runtimeClasspath 117} 118 119task coreAgentTest(type: Test) { 120 def sourceSet = sourceSets.coreAgentTest 121 def coroutinesCoreJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-core-jvm-${coroutines_version}.jar" }.singleFile 122 jvmArgs ('-javaagent:' + coroutinesCoreJar) 123 testClassesDirs = sourceSet.output.classesDirs 124 classpath = sourceSet.runtimeClasspath 125} 126 127compileTestKotlin { 128 kotlinOptions.jvmTarget = "1.8" 129} 130 131check { 132 dependsOn([withGuavaTest, debugDynamicAgentTest, mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build']) 133} 134