blob: 985a40ed969720fa9608153d395750b82e6a97ce [file] [log] [blame]
dkhalanskyjb02b403d2020-04-06 16:33:22 +03001/*
Vsevolod Tolstopyatov0e926e72021-01-18 08:47:09 -08002 * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
dkhalanskyjb02b403d2020-04-06 16:33:22 +03003 */
4
Vsevolod Tolstopyatov0e926e72021-01-18 08:47:09 -08005import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
6
7plugins {
Steve Elliottca095be2022-07-25 14:26:10 +00008 id "org.jetbrains.kotlin.jvm"
Vsevolod Tolstopyatov0e926e72021-01-18 08:47:09 -08009}
dkhalanskyjb02b403d2020-04-06 16:33:22 +030010
11repositories {
12 mavenLocal()
13 mavenCentral()
14}
15
Steve Elliottca095be2022-07-25 14:26:10 +000016java {
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
dkhalanskyjb02b403d2020-04-06 16:33:22 +030025sourceSets {
Steve Elliottca095be2022-07-25 14:26:10 +000026 // Test that relies on Guava to reflectively check all Throwable subclasses in coroutines
27 withGuavaTest {
dkhalanskyjb02b403d2020-04-06 16:33:22 +030028 kotlin
29 compileClasspath += sourceSets.test.runtimeClasspath
30 runtimeClasspath += sourceSets.test.runtimeClasspath
Steve Elliottca095be2022-07-25 14:26:10 +000031
32 dependencies {
33 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
34 implementation 'com.google.guava:guava:31.1-jre'
35 }
dkhalanskyjb02b403d2020-04-06 16:33:22 +030036 }
Steve Elliottca095be2022-07-25 14:26:10 +000037 // Checks correctness of Maven publication (JAR resources) and absence of atomicfu symbols
dkhalanskyjb02b403d2020-04-06 16:33:22 +030038 mavenTest {
39 kotlin
40 compileClasspath += sourceSets.test.runtimeClasspath
41 runtimeClasspath += sourceSets.test.runtimeClasspath
Steve Elliottca095be2022-07-25 14:26:10 +000042
43 dependencies {
44 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
45 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
46 }
dkhalanskyjb02b403d2020-04-06 16:33:22 +030047 }
Steve Elliottca095be2022-07-25 14:26:10 +000048 // Checks that kotlinx-coroutines-debug can be used as -javaagent parameter
dkhalanskyjb02b403d2020-04-06 16:33:22 +030049 debugAgentTest {
50 kotlin
51 compileClasspath += sourceSets.test.runtimeClasspath
52 runtimeClasspath += sourceSets.test.runtimeClasspath
Steve Elliottca095be2022-07-25 14:26:10 +000053
54 dependencies {
55 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
56 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version"
57 }
dkhalanskyjb02b403d2020-04-06 16:33:22 +030058 }
Vsevolod Tolstopyatov70a74872020-04-24 14:59:28 +030059
Steve Elliottca095be2022-07-25 14:26:10 +000060 // 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 Tolstopyatov70a74872020-04-24 14:59:28 +030073 coreAgentTest {
74 kotlin
75 compileClasspath += sourceSets.test.runtimeClasspath
76 runtimeClasspath += sourceSets.test.runtimeClasspath
Steve Elliottca095be2022-07-25 14:26:10 +000077
78 dependencies {
79 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
80 }
Vsevolod Tolstopyatov70a74872020-04-24 14:59:28 +030081 }
82}
83
84compileDebugAgentTestKotlin {
85 kotlinOptions {
86 freeCompilerArgs += ["-Xallow-kotlin-package"]
87 }
dkhalanskyjb02b403d2020-04-06 16:33:22 +030088}
89
Steve Elliottca095be2022-07-25 14:26:10 +000090task withGuavaTest(type: Test) {
91 environment "version", coroutines_version
92 def sourceSet = sourceSets.withGuavaTest
dkhalanskyjb02b403d2020-04-06 16:33:22 +030093 testClassesDirs = sourceSet.output.classesDirs
94 classpath = sourceSet.runtimeClasspath
95}
96
97task mavenTest(type: Test) {
Steve Elliottca095be2022-07-25 14:26:10 +000098 environment "version", coroutines_version
dkhalanskyjb02b403d2020-04-06 16:33:22 +030099 def sourceSet = sourceSets.mavenTest
dkhalanskyjb02b403d2020-04-06 16:33:22 +0300100 testClassesDirs = sourceSet.output.classesDirs
101 classpath = sourceSet.runtimeClasspath
dkhalanskyjb02b403d2020-04-06 16:33:22 +0300102}
103
104task debugAgentTest(type: Test) {
105 def sourceSet = sourceSets.debugAgentTest
Steve Elliottca095be2022-07-25 14:26:10 +0000106 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
dkhalanskyjb02b403d2020-04-06 16:33:22 +0300115 testClassesDirs = sourceSet.output.classesDirs
116 classpath = sourceSet.runtimeClasspath
117}
118
Vsevolod Tolstopyatov70a74872020-04-24 14:59:28 +0300119task coreAgentTest(type: Test) {
120 def sourceSet = sourceSets.coreAgentTest
Steve Elliottca095be2022-07-25 14:26:10 +0000121 def coroutinesCoreJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-core-jvm-${coroutines_version}.jar" }.singleFile
122 jvmArgs ('-javaagent:' + coroutinesCoreJar)
Vsevolod Tolstopyatov70a74872020-04-24 14:59:28 +0300123 testClassesDirs = sourceSet.output.classesDirs
124 classpath = sourceSet.runtimeClasspath
125}
126
dkhalanskyjb02b403d2020-04-06 16:33:22 +0300127compileTestKotlin {
128 kotlinOptions.jvmTarget = "1.8"
129}
130
Vsevolod Tolstopyatov70a74872020-04-24 14:59:28 +0300131check {
Steve Elliottca095be2022-07-25 14:26:10 +0000132 dependsOn([withGuavaTest, debugDynamicAgentTest, mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build'])
dkhalanskyjb02b403d2020-04-06 16:33:22 +0300133}