Skip to content

Commit 53061c5

Browse files
committed
Make publication validator part of the project
Before, publication validator was just lying nearby, in these files, and built and run separately. Now, it is compiled alongside the main project (in the `test` gradle configuration), so its breakage will be detected during normal usage. Still, it is only run when a special gradle property, `DeployVersion`, is defined.
1 parent 6d1a6e3 commit 53061c5

File tree

11 files changed

+29
-301
lines changed

11 files changed

+29
-301
lines changed

build.gradle

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ apply from: rootProject.file("gradle/experimental.gradle")
88
def rootModule = "kotlinx.coroutines"
99
def coreModule = "kotlinx-coroutines-core"
1010
// Not applicable for Kotlin plugin
11-
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom']
12-
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs']
11+
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'publication-validator']
12+
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs', 'publication-validator']
1313
// Not published
1414
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']
1515

@@ -133,8 +133,7 @@ allprojects {
133133

134134
apply plugin: "binary-compatibility-validator"
135135
apiValidation {
136-
ignoredProjects += ["stdlib-stubs", "benchmarks", "site",
137-
"kotlinx-coroutines-bom", "android-unit-tests", "js-stub"]
136+
ignoredProjects += unpublished + ["kotlinx-coroutines-bom"]
138137
ignoredPackages += "kotlinx.coroutines.internal"
139138
}
140139

publication-validator/README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Publication validator
22

3-
This is a supplementary subproject of kotlinx.coroutines to test its publication correctness.
3+
This is a supplementary subproject of kotlinx.coroutines that provides a new
4+
task, `testPublishing`, to test its publication correctness.
45

5-
It is used as part of "Dependency validation" build chain on TeamCity:
6-
* kotlinx.corotoutines are built with `publishToMavenLocal`
7-
* kotlinx.coroutines are built with `npmPublish -PdryRun=true` to have a packed publication
6+
The tests are the following:
87
* `NpmPublicationValidator` tests that version of NPM artifact is correct and that it has neither source nor package dependencies on atomicfu
98
* `MavenPublicationValidator` depends on the published artifacts and tests artifacts binary content and absence of atomicfu in the classpath
9+
10+
To test publication, one can run gradle with `-PdryRun=true testPublishing`.
11+
Here, `-PdryRun` affects `npmPublish` so that it only provides a packed
12+
publication and does not in fact attempt to send the build for publication.

publication-validator/build.gradle

+15-16
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,33 @@
22
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
plugins {
6-
id 'org.jetbrains.kotlin.jvm' version '1.3.30'
7-
}
8-
9-
def deployVersion = properties['DeployVersion']
10-
ext.coroutines_version = deployVersion
11-
println "Checking coroutines version $coroutines_version"
12-
13-
group 'org.jetbrains.kotlinx'
14-
version '1.0-SNAPSHOT'
5+
apply from: rootProject.file("gradle/compile-jvm.gradle")
156

167
repositories {
178
mavenLocal()
189
mavenCentral()
1910
}
2011

2112
dependencies {
22-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
13+
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
2314
testCompile 'junit:junit:4.12'
2415
testCompile 'org.apache.commons:commons-compress:1.18'
2516
testCompile 'com.google.code.gson:gson:2.8.5'
26-
testCompile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
27-
testCompile "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
17+
testCompile project(':kotlinx-coroutines-core')
18+
testCompile project(':kotlinx-coroutines-android')
2819
}
2920

30-
compileKotlin {
31-
kotlinOptions.jvmTarget = "1.8"
32-
}
3321
compileTestKotlin {
3422
kotlinOptions.jvmTarget = "1.8"
3523
}
24+
25+
task testPublishing(type: Test) {
26+
doFirst { println "Verifying publishing version $version" } // all modules share the same version
27+
environment "projectRoot", project.rootDir
28+
environment "deployVersion", version
29+
dependsOn(project(':').getTasksByName("publishNpm", true) +
30+
project(':').getTasksByName("publishToMavenLocal", true))
31+
dependsOn.remove(project(':').getTasksByName("dokka", true))
32+
}
33+
34+
test { enabled = false }

publication-validator/gradle.properties

-5
This file was deleted.
Binary file not shown.

publication-validator/gradle/wrapper/gradle-wrapper.properties

-6
This file was deleted.

publication-validator/gradlew

-172
This file was deleted.

publication-validator/gradlew.bat

-84
This file was deleted.

publication-validator/settings.gradle

-8
This file was deleted.

publication-validator/src/test/kotlin/kotlinx/coroutines/tools/NpmPublicationValidator.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import java.util.zip.*
1212
import org.junit.Assert.*
1313

1414
class NpmPublicationValidator {
15-
private val VERSION = System.getenv("DeployVersion")
16-
private val BUILD_DIR = System.getenv("teamcity.build.checkoutDir")
15+
private val VERSION = System.getenv("deployVersion")!!
16+
private val BUILD_DIR = System.getenv("projectRoot")!!
1717
private val NPM_ARTIFACT = "$BUILD_DIR/kotlinx-coroutines-core/build/npm/kotlinx-coroutines-core-$VERSION.tgz"
1818

1919
@Test

settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ module('ui/kotlinx-coroutines-swing')
4040

4141
module('js/js-stub')
4242
module('js/example-frontend-js')
43+
44+
module('publication-validator')

0 commit comments

Comments
 (0)