blob: c329497f95e783f7b74d7c495d76cafb6c7bacbf [file] [log] [blame]
Vsevolod Tolstopyatove50a0fa2019-01-28 11:34:24 +03001/*
2 * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3 */
4
5apply plugin: 'kotlin-multiplatform'
6apply from: rootProject.file("gradle/targets.gradle")
7apply from: rootProject.file("gradle/compile-jvm-multiplatform.gradle")
8apply from: rootProject.file("gradle/compile-common.gradle")
9apply from: rootProject.file("gradle/compile-js-multiplatform.gradle")
10apply from: rootProject.file("gradle/compile-native-multiplatform.gradle")
11apply from: rootProject.file('gradle/publish-npm-js.gradle')
12
13/*
14 * All platform plugins and configuration magic happens here instead of build.gradle
15 * because JMV-only projects depend on core, thus core should always be initialized before configuration.
16 */
17kotlin {
18 configure(sourceSets) {
19 def srcDir = name.endsWith('Main') ? 'src' : 'test'
20 def platform = name[0..-5]
21 kotlin.srcDir "$platform/$srcDir"
Vsevolod Tolstopyatov8273a752019-03-15 19:24:41 +030022 if (name == "jvmMain") {
23 resources.srcDirs = ["$platform/resources"]
24 } else if (name == "jvmTest") {
25 resources.srcDirs = ["$platform/test-resources"]
26 }
Vsevolod Tolstopyatove50a0fa2019-01-28 11:34:24 +030027 languageSettings {
28 progressiveMode = true
29 experimentalAnnotations.each { useExperimentalAnnotation(it) }
30 }
31 }
32
33 configure(targets) {
34 def targetName = it.name
35 compilations.all { compilation ->
36 def compileTask = tasks.getByName(compilation.compileKotlinTaskName)
37 // binary compatibility support
38 if (targetName.contains("jvm") && compilation.compilationName == "main") {
39 compileTask.kotlinOptions.freeCompilerArgs += ["-Xdump-declarations-to=${buildDir}/visibilities.json"]
40 }
41 }
42 }
43}
44
Roman Elizarovd2f4b2b2019-09-02 17:22:39 +030045configurations {
46 configureKotlinJvmPlatform(kotlinCompilerPluginClasspath)
47}
48
Vsevolod Tolstopyatove50a0fa2019-01-28 11:34:24 +030049kotlin.sourceSets {
50 jvmTest.dependencies {
51 api "com.devexperts.lincheck:lincheck:$lincheck_version"
52 api "com.esotericsoftware:kryo:4.0.0"
sokolova15b63452019-01-28 11:43:44 +030053 implementation project (":android-unit-tests")
Vsevolod Tolstopyatove50a0fa2019-01-28 11:34:24 +030054 }
55}
56
57task checkJdk16() {
58 // only fail w/o JDK_16 when actually trying to compile, not during project setup phase
59 doLast {
60 if (!System.env.JDK_16) {
61 throw new GradleException("JDK_16 environment variable is not defined. " +
62 "Can't build against JDK 1.6 runtime and run JDK 1.6 compatibility tests. " +
63 "Please ensure JDK 1.6 is installed and that JDK_16 points to it.")
64 }
65 }
66}
67
68tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
69 kotlinOptions.jdkHome = System.env.JDK_16
70 // only fail when actually trying to compile, not during project setup phase
71 dependsOn(checkJdk16)
72}
73
74jvmTest {
75 minHeapSize = '1g'
76 maxHeapSize = '1g'
77 enableAssertions = true
78 systemProperty 'java.security.manager', 'kotlinx.coroutines.TestSecurityManager'
Roman Elizarov7672c522019-08-28 12:04:59 +030079 exclude '**/*LFStressTest.*'
Vsevolod Tolstopyatove50a0fa2019-01-28 11:34:24 +030080 systemProperty 'kotlinx.coroutines.scheduler.keep.alive.sec', '100000' // any unpark problem hangs test
81}
82
83task lockFreedomTest(type: Test, dependsOn: compileTestKotlinJvm) {
84 classpath = files { jvmTest.classpath }
85 testClassesDirs = files { jvmTest.testClassesDirs }
Roman Elizarov7672c522019-08-28 12:04:59 +030086 include '**/*LFStressTest.*'
Roman Elizarov0b16abf2019-09-03 11:07:11 +030087 enableAssertions = true
88 testLogging.showStandardStreams = true
Vsevolod Tolstopyatove50a0fa2019-01-28 11:34:24 +030089}
90
91task jdk16Test(type: Test, dependsOn: [compileTestKotlinJvm, checkJdk16]) {
92 classpath = files { jvmTest.classpath }
93 testClassesDirs = files { jvmTest.testClassesDirs }
94 executable = "$System.env.JDK_16/bin/java"
Roman Elizarov7672c522019-08-28 12:04:59 +030095 exclude '**/*LFStressTest.*' // lock-freedom tests use LockFreedomTestEnvironment which needs JDK8
96 exclude '**/*LCStressTest.*' // lic-check tests use LinChecker which needs JDK8
97 exclude '**/exceptions/**' // exceptions tests check suppressed exception which needs JDK8
Vsevolod Tolstopyatove50a0fa2019-01-28 11:34:24 +030098 exclude '**/ExceptionsGuideTest.*'
99}
100
101// Run these tests only during nightly stress test
102jdk16Test.onlyIf { project.properties['stressTest'] != null }
103
104// Always run those tests
105task moreTest(dependsOn: [lockFreedomTest, jdk16Test])
106build.dependsOn moreTest
107
108task testsJar(type: Jar, dependsOn: jvmTestClasses) {
109 classifier = 'tests'
110 from compileTestKotlinJvm.destinationDir
111}
112
113artifacts {
114 archives testsJar
115}