blob: b1cbc08f7679198a2fea719c354f5ab5de67fa80 [file] [log] [blame]
Vsevolod Tolstopyatov0e926e72021-01-18 08:47:09 -08001import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
2
Aurimas Liutikase64dad72021-05-12 21:56:16 +00003/*
4 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
5 */
6
7apply from: rootProject.file("gradle/compile-jvm.gradle")
dkhalanskyjb02b403d2020-04-06 16:33:22 +03008
9repositories {
10 mavenLocal()
11 mavenCentral()
12}
13
14sourceSets {
15 npmTest {
16 kotlin
17 compileClasspath += sourceSets.test.runtimeClasspath
18 runtimeClasspath += sourceSets.test.runtimeClasspath
19 }
20 mavenTest {
21 kotlin
22 compileClasspath += sourceSets.test.runtimeClasspath
23 runtimeClasspath += sourceSets.test.runtimeClasspath
24 }
25 debugAgentTest {
26 kotlin
27 compileClasspath += sourceSets.test.runtimeClasspath
28 runtimeClasspath += sourceSets.test.runtimeClasspath
29 }
Vsevolod Tolstopyatov70a74872020-04-24 14:59:28 +030030
31 coreAgentTest {
32 kotlin
33 compileClasspath += sourceSets.test.runtimeClasspath
34 runtimeClasspath += sourceSets.test.runtimeClasspath
35 }
36}
37
38compileDebugAgentTestKotlin {
39 kotlinOptions {
40 freeCompilerArgs += ["-Xallow-kotlin-package"]
41 }
dkhalanskyjb02b403d2020-04-06 16:33:22 +030042}
43
44task npmTest(type: Test) {
45 def sourceSet = sourceSets.npmTest
46 environment "projectRoot", project.rootDir
47 environment "deployVersion", version
48 def dryRunNpm = project.properties['dryRun']
49 def doRun = dryRunNpm == "true" // so that we don't accidentally publish anything, especially before the test
50 onlyIf { doRun }
51 if (doRun) { // `onlyIf` only affects execution of the task, not the dependency subtree
52 dependsOn(project(':').getTasksByName("publishNpm", true))
53 }
54 testClassesDirs = sourceSet.output.classesDirs
55 classpath = sourceSet.runtimeClasspath
56}
57
58task mavenTest(type: Test) {
59 def sourceSet = sourceSets.mavenTest
60 dependsOn(project(':').getTasksByName("publishToMavenLocal", true))
dkhalanskyjb02b403d2020-04-06 16:33:22 +030061 testClassesDirs = sourceSet.output.classesDirs
62 classpath = sourceSet.runtimeClasspath
63 // we can't depend on the subprojects because we need to test the classfiles that are published in the end.
64 // also, we can't put this in the `dependencies` block because the resolution would happen before publication.
Sergey Igushkin17248c82020-05-22 12:28:25 +030065 def mavenTestClasspathConfiguration = project.configurations.detachedConfiguration(
dkhalanskyjb02b403d2020-04-06 16:33:22 +030066 project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"),
67 project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"))
Sergey Igushkin17248c82020-05-22 12:28:25 +030068
69 mavenTestClasspathConfiguration.attributes {
70 attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
71 }
72
73 classpath += mavenTestClasspathConfiguration
dkhalanskyjb02b403d2020-04-06 16:33:22 +030074}
75
76task debugAgentTest(type: Test) {
77 def sourceSet = sourceSets.debugAgentTest
78 dependsOn(project(':kotlinx-coroutines-debug').shadowJar)
79 jvmArgs ('-javaagent:' + project(':kotlinx-coroutines-debug').shadowJar.outputs.files.getFiles()[0])
80 testClassesDirs = sourceSet.output.classesDirs
81 classpath = sourceSet.runtimeClasspath
82}
83
Vsevolod Tolstopyatov70a74872020-04-24 14:59:28 +030084task coreAgentTest(type: Test) {
85 def sourceSet = sourceSets.coreAgentTest
86 dependsOn(project(':kotlinx-coroutines-core').jvmJar)
87 jvmArgs ('-javaagent:' + project(':kotlinx-coroutines-core').jvmJar.outputs.files.getFiles()[0])
88 testClassesDirs = sourceSet.output.classesDirs
89 classpath = sourceSet.runtimeClasspath
90}
91
dkhalanskyjb02b403d2020-04-06 16:33:22 +030092dependencies {
93 testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
94 testCompile 'junit:junit:4.12'
95 npmTestCompile 'org.apache.commons:commons-compress:1.18'
96 npmTestCompile 'com.google.code.gson:gson:2.8.5'
97 debugAgentTestCompile project(':kotlinx-coroutines-core')
98 debugAgentTestCompile project(':kotlinx-coroutines-debug')
Vsevolod Tolstopyatov70a74872020-04-24 14:59:28 +030099 coreAgentTestCompile project(':kotlinx-coroutines-core')
dkhalanskyjb02b403d2020-04-06 16:33:22 +0300100}
101
102compileTestKotlin {
103 kotlinOptions.jvmTarget = "1.8"
104}
105
Vsevolod Tolstopyatov70a74872020-04-24 14:59:28 +0300106check {
107 dependsOn([npmTest, mavenTest, debugAgentTest, coreAgentTest])
dkhalanskyjb02b403d2020-04-06 16:33:22 +0300108}