File tree 5 files changed +78
-2
lines changed
5 files changed +78
-2
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,40 @@ configure(subprojects.findAll { !unpublished.contains(it.name) }) {
245
245
}
246
246
}
247
247
}
248
+
249
+ def project = it
250
+ if (project. name in sourceless) {
251
+ return
252
+ }
253
+
254
+ def versionFileTask = project. tasks. register(" versionFileTask" ) {
255
+ def name = project. name. replace(" -" , " _" )
256
+ def versionFile = project. layout. buildDirectory. file(" ${ name} .version" )
257
+ it. outputs. file(versionFile)
258
+
259
+ it. doLast {
260
+ versionFile. get(). asFile. text = " version=${ version} "
261
+ }
262
+ }
263
+
264
+ List<String > jarTasks
265
+ if (it. name == " kotlinx-coroutines-core" ) {
266
+ jarTasks = [" jvmJar" , " metadataJar" ]
267
+ } else if (it. name == " kotlinx-coroutines-debug" ) {
268
+ // We shadow debug module instead of just packaging it
269
+ jarTasks = [" shadowJar" ]
270
+ } else {
271
+ jarTasks = [" jar" ]
272
+ }
273
+
274
+ for (name in jarTasks) {
275
+ project. tasks. named(name, Jar ) {
276
+ it. dependsOn versionFileTask
277
+ it. from(versionFileTask) {
278
+ into(" META-INF" )
279
+ }
280
+ }
281
+ }
248
282
}
249
283
250
284
// Report Kotlin compiler version when building project
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ task npmTest(type: Test) {
58
58
}
59
59
60
60
task mavenTest (type : Test ) {
61
+ environment " version" , version
61
62
def sourceSet = sourceSets. mavenTest
62
63
dependsOn(project(' :' ). getTasksByName(" publishToMavenLocal" , true ))
63
64
testClassesDirs = sourceSet. output. classesDirs
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import org.junit.*
8
8
import org.junit.Assert.assertTrue
9
9
import java.util.jar.*
10
10
11
- class MavenPublicationValidator {
11
+ class MavenPublicationAtomicfuValidator {
12
12
private val ATOMIC_FU_REF = " Lkotlinx/atomicfu/" .toByteArray()
13
13
14
14
@Test
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3
+ */
4
+
5
+ package kotlinx.coroutines.validator
6
+
7
+ import org.junit.*
8
+ import org.junit.Test
9
+ import java.util.jar.*
10
+ import kotlin.test.*
11
+
12
+ class MavenPublicationVersionValidator {
13
+
14
+ @Test
15
+ fun testMppJar () {
16
+ val clazz = Class .forName(" kotlinx.coroutines.Job" )
17
+ JarFile (clazz.protectionDomain.codeSource.location.file).checkForVersion(" kotlinx_coroutines_core.version" )
18
+ }
19
+
20
+ @Test
21
+ fun testAndroidJar () {
22
+ val clazz = Class .forName(" kotlinx.coroutines.android.HandlerDispatcher" )
23
+ JarFile (clazz.protectionDomain.codeSource.location.file).checkForVersion(" kotlinx_coroutines_android.version" )
24
+ }
25
+
26
+ private fun JarFile.checkForVersion (file : String ) {
27
+ val actualFile = " META-INF/$file "
28
+ val version = System .getenv(" version" )
29
+ try {
30
+ for (e in entries()) {
31
+ if (e.name == actualFile) {
32
+ val string = getInputStream(e).readAllBytes().decodeToString()
33
+ assertEquals(" version=$version " , string)
34
+ return
35
+ }
36
+ }
37
+ error(" File $file not found" )
38
+ } finally {
39
+ close()
40
+ }
41
+ }
42
+ }
Original file line number Diff line number Diff line change @@ -219,7 +219,6 @@ def setupManifest(Jar jar) {
219
219
jar. manifest {
220
220
attributes " Premain-Class" : " kotlinx.coroutines.debug.AgentPremain"
221
221
attributes " Can-Retransform-Classes" : " true"
222
- attributes " Specification-Version" : rootProject. version
223
222
}
224
223
}
225
224
You can’t perform that action at this time.
0 commit comments