55import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
66
77plugins {
8- id( " kotlin- jvm-conventions " )
8+ id " org.jetbrains. kotlin. jvm"
99}
1010
1111repositories {
1212 mavenLocal()
1313 mavenCentral()
1414}
1515
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+
1625sourceSets {
17- npmTest {
26+ withGuavaTest {
1827 kotlin
1928 compileClasspath + = sourceSets. test. runtimeClasspath
2029 runtimeClasspath + = sourceSets. test. runtimeClasspath
30+
31+ dependencies {
32+ implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version "
33+ implementation ' com.google.guava:guava:31.1-jre'
34+ }
2135 }
2236 mavenTest {
2337 kotlin
2438 compileClasspath + = sourceSets. test. runtimeClasspath
2539 runtimeClasspath + = sourceSets. test. runtimeClasspath
40+
41+ dependencies {
42+ implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version "
43+ implementation " org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version "
44+ }
2645 }
2746 debugAgentTest {
2847 kotlin
2948 compileClasspath + = sourceSets. test. runtimeClasspath
3049 runtimeClasspath + = sourceSets. test. runtimeClasspath
31- }
3250
51+ dependencies {
52+ implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version "
53+ implementation " org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version "
54+ }
55+ }
3356 coreAgentTest {
3457 kotlin
3558 compileClasspath + = sourceSets. test. runtimeClasspath
3659 runtimeClasspath + = sourceSets. test. runtimeClasspath
60+
61+ dependencies {
62+ implementation " org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version "
63+ }
3764 }
3865}
3966
@@ -43,70 +70,41 @@ compileDebugAgentTestKotlin {
4370 }
4471}
4572
46- task npmTest (type : Test ) {
47- def sourceSet = sourceSets. npmTest
48- environment " projectRoot" , project. rootDir
49- environment " deployVersion" , version
50- def dryRunNpm = project. properties[' dryRun' ]
51- def doRun = dryRunNpm == " true" // so that we don't accidentally publish anything, especially before the test
52- onlyIf { doRun }
53- if (doRun) { // `onlyIf` only affects execution of the task, not the dependency subtree
54- dependsOn(project(' :' ). getTasksByName(" publishNpm" , true ))
55- }
73+ task withGuavaTest (type : Test ) {
74+ environment " version" , coroutines_version
75+ def sourceSet = sourceSets. withGuavaTest
5676 testClassesDirs = sourceSet. output. classesDirs
5777 classpath = sourceSet. runtimeClasspath
5878}
5979
6080task mavenTest (type : Test ) {
61- environment " version" , version
81+ environment " version" , coroutines_version
6282 def sourceSet = sourceSets. mavenTest
63- dependsOn(project(' :' ). getTasksByName(" publishToMavenLocal" , true ))
6483 testClassesDirs = sourceSet. output. classesDirs
6584 classpath = sourceSet. runtimeClasspath
66- // we can't depend on the subprojects because we need to test the classfiles that are published in the end.
67- // also, we can't put this in the `dependencies` block because the resolution would happen before publication.
68- def mavenTestClasspathConfiguration = project. configurations. detachedConfiguration(
69- project. dependencies. create(" org.jetbrains.kotlinx:kotlinx-coroutines-core:$version " ),
70- project. dependencies. create(" org.jetbrains.kotlinx:kotlinx-coroutines-android:$version " ))
71-
72- mavenTestClasspathConfiguration. attributes {
73- attribute(KotlinPlatformType . attribute, KotlinPlatformType . jvm)
74- }
75-
76- classpath + = mavenTestClasspathConfiguration
7785}
7886
7987task debugAgentTest (type : Test ) {
8088 def sourceSet = sourceSets. debugAgentTest
81- dependsOn(project( ' : kotlinx-coroutines-debug' ) . shadowJar)
82- jvmArgs (' -javaagent:' + project( ' :kotlinx-coroutines-debug ' ) . shadowJar . outputs . files . getFiles()[ 0 ] )
89+ def coroutinesDebugJar = sourceSet . runtimeClasspath . filter {it . name == " kotlinx-coroutines-debug- ${ coroutines_version } .jar " } . singleFile
90+ jvmArgs (' -javaagent:' + coroutinesDebugJar )
8391 testClassesDirs = sourceSet. output. classesDirs
8492 classpath = sourceSet. runtimeClasspath
8593 systemProperties project. properties. subMap([" overwrite.probes" ])
8694}
8795
8896task coreAgentTest (type : Test ) {
8997 def sourceSet = sourceSets. coreAgentTest
90- dependsOn(project( ' : kotlinx-coroutines-core' ) . jvmJar)
91- jvmArgs (' -javaagent:' + project( ' :kotlinx-coroutines-core ' ) . jvmJar . outputs . files . getFiles()[ 0 ] )
98+ def coroutinesCoreJar = sourceSet . runtimeClasspath . filter {it . name == " kotlinx-coroutines-core-jvm- ${ coroutines_version } .jar " } . singleFile
99+ jvmArgs (' -javaagent:' + coroutinesCoreJar )
92100 testClassesDirs = sourceSet. output. classesDirs
93101 classpath = sourceSet. runtimeClasspath
94102}
95103
96- dependencies {
97- testImplementation " org.jetbrains.kotlin:kotlin-stdlib-jdk8"
98- testImplementation ' junit:junit:4.12'
99- npmTestImplementation ' org.apache.commons:commons-compress:1.18'
100- npmTestImplementation ' com.google.code.gson:gson:2.8.5'
101- debugAgentTestImplementation project(' :kotlinx-coroutines-core' )
102- debugAgentTestImplementation project(' :kotlinx-coroutines-debug' )
103- coreAgentTestImplementation project(' :kotlinx-coroutines-core' )
104- }
105-
106104compileTestKotlin {
107105 kotlinOptions. jvmTarget = " 1.8"
108106}
109107
110108check {
111- dependsOn([npmTest , mavenTest, debugAgentTest, coreAgentTest])
109+ dependsOn([withGuavaTest , mavenTest, debugAgentTest, coreAgentTest, ' smokeTest:build ' ])
112110}
0 commit comments