dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 1 | /* |
Vsevolod Tolstopyatov | 0e926e7 | 2021-01-18 08:47:09 -0800 | [diff] [blame] | 2 | * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 3 | */ |
| 4 | |
Vsevolod Tolstopyatov | 0e926e7 | 2021-01-18 08:47:09 -0800 | [diff] [blame] | 5 | import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType |
| 6 | |
| 7 | plugins { |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 8 | id "org.jetbrains.kotlin.jvm" |
Vsevolod Tolstopyatov | 0e926e7 | 2021-01-18 08:47:09 -0800 | [diff] [blame] | 9 | } |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 10 | |
| 11 | repositories { |
| 12 | mavenLocal() |
| 13 | mavenCentral() |
| 14 | } |
| 15 | |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 16 | java { |
| 17 | sourceCompatibility = JavaVersion.VERSION_1_8 |
| 18 | targetCompatibility = JavaVersion.VERSION_1_8 |
| 19 | } |
| 20 | |
| 21 | dependencies { |
| 22 | testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" |
| 23 | } |
| 24 | |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 25 | sourceSets { |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 26 | // Test that relies on Guava to reflectively check all Throwable subclasses in coroutines |
| 27 | withGuavaTest { |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 28 | kotlin |
| 29 | compileClasspath += sourceSets.test.runtimeClasspath |
| 30 | runtimeClasspath += sourceSets.test.runtimeClasspath |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 31 | |
| 32 | dependencies { |
| 33 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" |
| 34 | implementation 'com.google.guava:guava:31.1-jre' |
| 35 | } |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 36 | } |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 37 | // Checks correctness of Maven publication (JAR resources) and absence of atomicfu symbols |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 38 | mavenTest { |
| 39 | kotlin |
| 40 | compileClasspath += sourceSets.test.runtimeClasspath |
| 41 | runtimeClasspath += sourceSets.test.runtimeClasspath |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 42 | |
| 43 | dependencies { |
| 44 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" |
| 45 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" |
| 46 | } |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 47 | } |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 48 | // Checks that kotlinx-coroutines-debug can be used as -javaagent parameter |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 49 | debugAgentTest { |
| 50 | kotlin |
| 51 | compileClasspath += sourceSets.test.runtimeClasspath |
| 52 | runtimeClasspath += sourceSets.test.runtimeClasspath |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 53 | |
| 54 | dependencies { |
| 55 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" |
| 56 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version" |
| 57 | } |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 58 | } |
Vsevolod Tolstopyatov | 70a7487 | 2020-04-24 14:59:28 +0300 | [diff] [blame] | 59 | |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 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 |
Vsevolod Tolstopyatov | 70a7487 | 2020-04-24 14:59:28 +0300 | [diff] [blame] | 73 | coreAgentTest { |
| 74 | kotlin |
| 75 | compileClasspath += sourceSets.test.runtimeClasspath |
| 76 | runtimeClasspath += sourceSets.test.runtimeClasspath |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 77 | |
| 78 | dependencies { |
| 79 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" |
| 80 | } |
Vsevolod Tolstopyatov | 70a7487 | 2020-04-24 14:59:28 +0300 | [diff] [blame] | 81 | } |
| 82 | } |
| 83 | |
| 84 | compileDebugAgentTestKotlin { |
| 85 | kotlinOptions { |
| 86 | freeCompilerArgs += ["-Xallow-kotlin-package"] |
| 87 | } |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 88 | } |
| 89 | |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 90 | task withGuavaTest(type: Test) { |
| 91 | environment "version", coroutines_version |
| 92 | def sourceSet = sourceSets.withGuavaTest |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 93 | testClassesDirs = sourceSet.output.classesDirs |
| 94 | classpath = sourceSet.runtimeClasspath |
| 95 | } |
| 96 | |
| 97 | task mavenTest(type: Test) { |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 98 | environment "version", coroutines_version |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 99 | def sourceSet = sourceSets.mavenTest |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 100 | testClassesDirs = sourceSet.output.classesDirs |
| 101 | classpath = sourceSet.runtimeClasspath |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | task debugAgentTest(type: Test) { |
| 105 | def sourceSet = sourceSets.debugAgentTest |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 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 | |
| 113 | task debugDynamicAgentTest(type: Test) { |
| 114 | def sourceSet = sourceSets.debugDynamicAgentTest |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 115 | testClassesDirs = sourceSet.output.classesDirs |
| 116 | classpath = sourceSet.runtimeClasspath |
| 117 | } |
| 118 | |
Vsevolod Tolstopyatov | 70a7487 | 2020-04-24 14:59:28 +0300 | [diff] [blame] | 119 | task coreAgentTest(type: Test) { |
| 120 | def sourceSet = sourceSets.coreAgentTest |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 121 | def coroutinesCoreJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-core-jvm-${coroutines_version}.jar" }.singleFile |
| 122 | jvmArgs ('-javaagent:' + coroutinesCoreJar) |
Vsevolod Tolstopyatov | 70a7487 | 2020-04-24 14:59:28 +0300 | [diff] [blame] | 123 | testClassesDirs = sourceSet.output.classesDirs |
| 124 | classpath = sourceSet.runtimeClasspath |
| 125 | } |
| 126 | |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 127 | compileTestKotlin { |
| 128 | kotlinOptions.jvmTarget = "1.8" |
| 129 | } |
| 130 | |
Vsevolod Tolstopyatov | 70a7487 | 2020-04-24 14:59:28 +0300 | [diff] [blame] | 131 | check { |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 132 | dependsOn([withGuavaTest, debugDynamicAgentTest, mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build']) |
dkhalanskyjb | 02b403d | 2020-04-06 16:33:22 +0300 | [diff] [blame] | 133 | } |