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