Skip to content

Commit 585b766

Browse files
committed
Infrastructure to build kotlinx.coroutines against Kotlin snapshots
1 parent b550afa commit 585b766

6 files changed

+54
-17
lines changed

build.gradle

+49-12
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,24 @@ static def platformOf(project) {
2323
}
2424

2525
buildscript {
26-
ext.useKotlinSnapshot = rootProject.properties['kotlinSnapshot'] != null
27-
if (useKotlinSnapshot) {
28-
ext.kotlin_version = '1.2-SNAPSHOT'
26+
/*
27+
* These property group is used to build kotlinx.coroutines against Kotlin compiler snapshot.
28+
* How does it work:
29+
* When build_snapshot_train is set to true, kotlin_version property is overridden with kotlin_snapshot_version,
30+
* atomicfu_version is overwritten by TeamCity environment (AFU is built with snapshot and published to mavenLocal
31+
* as previous step or the snapshot build).
32+
* Additionally, mavenLocal and Sonatype snapshots are added to repository list and stress tests are disabled.
33+
* DO NOT change the name of these properties without adapting kotlinx.train build chain.
34+
*/
35+
def prop = rootProject.properties['build_snapshot_train']
36+
ext.build_snapshot_train = prop != null && prop != ""
37+
if (build_snapshot_train) {
38+
ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
39+
if (kotlin_version == null) {
40+
throw new IllegalArgumentException("'kotlin_snapshot_version' should be defined when building with snapshot compiler")
41+
}
2942
repositories {
43+
mavenLocal()
3044
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
3145
}
3246
}
@@ -43,7 +57,7 @@ buildscript {
4357
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$artifactory_plugin_version"
4458
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
4559
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
46-
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicFU_version"
60+
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfu_version"
4761
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version"
4862
classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
4963

@@ -57,17 +71,27 @@ buildscript {
5771
allprojects {
5872
// the only place where HostManager could be instantiated
5973
project.ext.hostManager = new HostManager()
60-
}
61-
62-
allprojects {
63-
apply plugin: 'kotlinx-atomicfu'
64-
6574
def deployVersion = properties['DeployVersion']
6675
if (deployVersion != null) version = deployVersion
67-
if (useKotlinSnapshot) {
68-
kotlin_version = '1.2-SNAPSHOT'
76+
77+
if (build_snapshot_train) {
78+
ext.kotlin_version = rootProject.properties['kotlin_snapshot_version']
79+
println "Using Kotlin $kotlin_version for project $it"
80+
81+
if (version != atomicfu_version) {
82+
throw new IllegalStateException("Current deploy version is $version, but atomicfu version is not overridden ($atomicfu_version) for $it")
83+
}
84+
85+
kotlin_version = rootProject.properties['kotlin_snapshot_version']
86+
repositories {
87+
mavenLocal()
88+
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
89+
}
6990
}
91+
}
7092

93+
allprojects {
94+
apply plugin: 'kotlinx-atomicfu'
7195
def projectName = it.name
7296
repositories {
7397
/*
@@ -96,7 +120,7 @@ allprojects {
96120
dependencies {
97121
// See comment below for rationale, it will be replaced with "project" dependency
98122
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
99-
compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
123+
compileOnly "org.jetbrains.kotlinx:atomicfu:$atomicfu_version"
100124

101125
// the only way IDEA can resolve test classes
102126
testCompile project(":$coreModule").kotlin.targets.jvm.compilations.test.output.allOutputs
@@ -110,6 +134,19 @@ allprojects {
110134
}
111135
}
112136

137+
if (build_snapshot_train) {
138+
println "Hacking test tasks, removing stress and flaky tests"
139+
allprojects {
140+
tasks.withType(Test).all {
141+
exclude '**/*LinearizabilityTest*.*'
142+
exclude '**/*LFTest.*'
143+
exclude '**/*StressTest.*'
144+
exclude '**/*scheduler.*'
145+
exclude '**/*Timeout.*'
146+
}
147+
}
148+
}
149+
113150
/*
114151
* Hack to trick nmpp plugin: we are renaming artifacts in order to provide backward compatibility for dependencies,
115152
* but publishing plugin does not re-read artifact names for kotlin-jvm projects, so renaming is not applied in pom files

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kotlin_version=1.3.30
55

66
# Dependencies
77
junit_version=4.12
8-
atomicFU_version=0.12.3
8+
atomicfu_version=0.12.3
99
html_version=0.6.8
1010
lincheck_version=2.0
1111
dokka_version=0.9.16-rdev-2-mpp-hacks

gradle/compile-common.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
kotlin.sourceSets {
66
commonMain.dependencies {
77
api "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
8-
api "org.jetbrains.kotlinx:atomicfu-common:$atomicFU_version"
8+
api "org.jetbrains.kotlinx:atomicfu-common:$atomicfu_version"
99
}
1010

1111
commonTest.dependencies {

gradle/compile-js-multiplatform.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ kotlin {
1212
sourceSets {
1313
jsMain.dependencies {
1414
api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-js', version: kotlin_version
15-
api "org.jetbrains.kotlinx:atomicfu-js:$atomicFU_version"
15+
api "org.jetbrains.kotlinx:atomicfu-js:$atomicfu_version"
1616
}
1717

1818
jsTest.dependencies {

gradle/compile-jvm-multiplatform.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ kotlin {
1616
sourceSets {
1717
jvmMain.dependencies {
1818
api 'org.jetbrains.kotlin:kotlin-stdlib'
19-
api "org.jetbrains.kotlinx:atomicfu:$atomicFU_version"
19+
api "org.jetbrains.kotlinx:atomicfu:$atomicfu_version"
2020
}
2121

2222
jvmTest.dependencies {

gradle/compile-native-multiplatform.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kotlin {
1414

1515
sourceSets {
1616
nativeMain.dependencies {
17-
api "org.jetbrains.kotlinx:atomicfu-native:$atomicFU_version"
17+
api "org.jetbrains.kotlinx:atomicfu-native:$atomicfu_version"
1818
}
1919

2020
nativeMain { dependsOn commonMain }

0 commit comments

Comments
 (0)