|
| 1 | +/* |
| 2 | + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 3 | + */ |
| 4 | + |
| 5 | +apply from: rootProject.file("gradle/compile-jvm.gradle") |
| 6 | + |
| 7 | +repositories { |
| 8 | + mavenLocal() |
| 9 | + mavenCentral() |
| 10 | +} |
| 11 | + |
| 12 | +sourceSets { |
| 13 | + npmTest { |
| 14 | + kotlin |
| 15 | + compileClasspath += sourceSets.test.runtimeClasspath |
| 16 | + runtimeClasspath += sourceSets.test.runtimeClasspath |
| 17 | + } |
| 18 | + mavenTest { |
| 19 | + kotlin |
| 20 | + compileClasspath += sourceSets.test.runtimeClasspath |
| 21 | + runtimeClasspath += sourceSets.test.runtimeClasspath |
| 22 | + } |
| 23 | + debugAgentTest { |
| 24 | + kotlin |
| 25 | + compileClasspath += sourceSets.test.runtimeClasspath |
| 26 | + runtimeClasspath += sourceSets.test.runtimeClasspath |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +task npmTest(type: Test) { |
| 31 | + def sourceSet = sourceSets.npmTest |
| 32 | + environment "projectRoot", project.rootDir |
| 33 | + environment "deployVersion", version |
| 34 | + def dryRunNpm = project.properties['dryRun'] |
| 35 | + def doRun = dryRunNpm == "true" // so that we don't accidentally publish anything, especially before the test |
| 36 | + onlyIf { doRun } |
| 37 | + if (doRun) { // `onlyIf` only affects execution of the task, not the dependency subtree |
| 38 | + dependsOn(project(':').getTasksByName("publishNpm", true)) |
| 39 | + } |
| 40 | + testClassesDirs = sourceSet.output.classesDirs |
| 41 | + classpath = sourceSet.runtimeClasspath |
| 42 | +} |
| 43 | + |
| 44 | +task mavenTest(type: Test) { |
| 45 | + def sourceSet = sourceSets.mavenTest |
| 46 | + dependsOn(project(':').getTasksByName("publishToMavenLocal", true)) |
| 47 | + dependsOn.remove(project(':').getTasksByName("dokka", true)) |
| 48 | + testClassesDirs = sourceSet.output.classesDirs |
| 49 | + classpath = sourceSet.runtimeClasspath |
| 50 | +} |
| 51 | + |
| 52 | +task debugAgentTest(type: Test) { |
| 53 | + def sourceSet = sourceSets.debugAgentTest |
| 54 | + dependsOn(project(':kotlinx-coroutines-debug').shadowJar) |
| 55 | + jvmArgs ('-javaagent:' + project(':kotlinx-coroutines-debug').shadowJar.outputs.files.getFiles()[0]) |
| 56 | + testClassesDirs = sourceSet.output.classesDirs |
| 57 | + classpath = sourceSet.runtimeClasspath |
| 58 | +} |
| 59 | + |
| 60 | +dependencies { |
| 61 | + testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8" |
| 62 | + testCompile 'junit:junit:4.12' |
| 63 | + npmTestCompile 'org.apache.commons:commons-compress:1.18' |
| 64 | + npmTestCompile 'com.google.code.gson:gson:2.8.5' |
| 65 | + mavenTestRuntimeOnly project(':kotlinx-coroutines-core') |
| 66 | + mavenTestRuntimeOnly project(':kotlinx-coroutines-android') |
| 67 | + debugAgentTestCompile project(':kotlinx-coroutines-core') |
| 68 | + debugAgentTestCompile project(':kotlinx-coroutines-debug') |
| 69 | +} |
| 70 | + |
| 71 | +compileTestKotlin { |
| 72 | + kotlinOptions.jvmTarget = "1.8" |
| 73 | +} |
| 74 | + |
| 75 | +test { |
| 76 | + dependsOn([npmTest, mavenTest, debugAgentTest]) |
| 77 | +} |
0 commit comments