-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathbuild.gradle
132 lines (117 loc) · 4.93 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
apply plugin: 'kotlin-multiplatform'
apply from: rootProject.file("gradle/targets.gradle")
apply from: rootProject.file("gradle/compile-jvm-multiplatform.gradle")
apply from: rootProject.file("gradle/compile-common.gradle")
apply from: rootProject.file("gradle/compile-js-multiplatform.gradle")
apply from: rootProject.file("gradle/compile-native-multiplatform.gradle")
apply from: rootProject.file('gradle/publish-npm-js.gradle')
/*
* All platform plugins and configuration magic happens here instead of build.gradle
* because JMV-only projects depend on core, thus core should always be initialized before configuration.
*/
kotlin {
configure(sourceSets) {
def srcDir = name.endsWith('Main') ? 'src' : 'test'
def platform = name[0..-5]
kotlin.srcDir "$platform/$srcDir"
if (name == "jvmMain") {
resources.srcDirs = ["$platform/resources"]
} else if (name == "jvmTest") {
resources.srcDirs = ["$platform/test-resources"]
}
languageSettings {
progressiveMode = true
experimentalAnnotations.each { useExperimentalAnnotation(it) }
}
}
configure(targets) {
def targetName = it.name
compilations.all { compilation ->
def compileTask = tasks.getByName(compilation.compileKotlinTaskName)
// binary compatibility support
if (targetName.contains("jvm") && compilation.compilationName == "main") {
compileTask.kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"]
}
}
}
}
configurations {
configureKotlinJvmPlatform(kotlinCompilerPluginClasspath)
}
// Update module name for metadata artifact to avoid conflicts
// see https://github.com/Kotlin/kotlinx.coroutines/issues/1797
compileKotlinMetadata {
kotlinOptions {
freeCompilerArgs += ["-module-name", "kotlinx-coroutines-core-common"]
}
}
kotlin.sourceSets {
jvmTest.dependencies {
api "org.jetbrains.kotlinx:lincheck:$lincheck_version"
api "org.jetbrains.kotlinx:kotlinx-knit-test:$knit_version"
api "com.esotericsoftware:kryo:4.0.0"
implementation project (":android-unit-tests")
}
}
task checkJdk16() {
// only fail w/o JDK_16 when actually trying to compile, not during project setup phase
doLast {
if (!System.env.JDK_16) {
throw new GradleException("JDK_16 environment variable is not defined. " +
"Can't build against JDK 1.6 runtime and run JDK 1.6 compatibility tests. " +
"Please ensure JDK 1.6 is installed and that JDK_16 points to it.")
}
}
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions.jdkHome = System.env.JDK_16
// only fail when actually trying to compile, not during project setup phase
dependsOn(checkJdk16)
}
jvmTest {
minHeapSize = '1g'
maxHeapSize = '1g'
enableAssertions = true
systemProperty 'java.security.manager', 'kotlinx.coroutines.TestSecurityManager'
// 'stress' is required to be able to run all subpackage tests like ":jvmTests --tests "*channels*" -Pstress=true"
if (!project.ext.ideaActive && rootProject.properties['stress'] == null) {
exclude '**/*StressTest.*'
}
systemProperty 'kotlinx.coroutines.scheduler.keep.alive.sec', '100000' // any unpark problem hangs test
}
task jvmStressTest(type: Test, dependsOn: compileTestKotlinJvm) {
classpath = files { jvmTest.classpath }
testClassesDirs = files { jvmTest.testClassesDirs }
minHeapSize = '1g'
maxHeapSize = '1g'
include '**/*StressTest.*'
enableAssertions = true
testLogging.showStandardStreams = true
systemProperty 'kotlinx.coroutines.scheduler.keep.alive.sec', '100000' // any unpark problem hangs test
systemProperty 'kotlinx.coroutines.semaphore.segmentSize', '2'
systemProperty 'kotlinx.coroutines.semaphore.maxSpinCycles', '10'
}
task jdk16Test(type: Test, dependsOn: [compileTestKotlinJvm, checkJdk16]) {
classpath = files { jvmTest.classpath }
testClassesDirs = files { jvmTest.testClassesDirs }
executable = "$System.env.JDK_16/bin/java"
exclude '**/*LFStressTest.*' // lock-freedom tests use LockFreedomTestEnvironment which needs JDK8
exclude '**/*LCStressTest.*' // lin-check tests use LinChecker which needs JDK8
exclude '**/exceptions/**' // exceptions tests check suppressed exception which needs JDK8
exclude '**/ExceptionsGuideTest.*'
}
// Run these tests only during nightly stress test
jdk16Test.onlyIf { project.properties['stressTest'] != null }
// Always run those tests
task moreTest(dependsOn: [jvmStressTest, jdk16Test])
build.dependsOn moreTest
task testsJar(type: Jar, dependsOn: jvmTestClasses) {
classifier = 'tests'
from compileTestKotlinJvm.destinationDir
}
artifacts {
archives testsJar
}