Skip to content

Commit d40cac6

Browse files
authored
Merge pull request #148 from Kotlin/version-0.14.4
Version 0.14.4
2 parents cffe6ee + 6f2a521 commit d40cac6

File tree

12 files changed

+192
-183
lines changed

12 files changed

+192
-183
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change log for kotlinx.atomicfu
22

3+
# Version 0.14.4
4+
5+
* Fixed bug when Maven plugin wasn't published
6+
* Migrate to new Kotlin HMPP metadata for multiplatform projects
7+
* Update Kotlin to 1.4.0
8+
39
# Version 0.14.3
410

511
* Update to Kotlin 1.3.71.

atomicfu-gradle-plugin/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ dependencies {
3333
evaluationDependsOn(':atomicfu')
3434
def atomicfu = project(':atomicfu')
3535
def atomicfuJvmJarTask = atomicfu.tasks.getByName(atomicfu.kotlin.targets.jvm.artifactsTaskName)
36-
def atomicfuJsJarTask = atomicfu.tasks.getByName(atomicfu.kotlin.targets.js.artifactsTaskName)
36+
37+
def jsLegacy = atomicfu.kotlin.targets.hasProperty("jsLegacy")
38+
? atomicfu.kotlin.targets.jsLegacy
39+
: atomicfu.kotlin.targets.js
40+
def atomicfuJsJarTask = atomicfu.tasks.getByName(jsLegacy.artifactsTaskName)
41+
3742
def atomicfuMetadataJarTask = atomicfu.tasks.getByName(atomicfu.kotlin.targets.metadata.artifactsTaskName)
3843

3944
// Write the plugin's classpath to a file to share with the tests

atomicfu-gradle-plugin/src/main/kotlin/kotlinx/atomicfu/plugin/gradle/AtomicFUGradlePlugin.kt

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ private fun Project.configureDependencies() {
5050
)
5151
dependencies.add(TEST_IMPLEMENTATION_CONFIGURATION, getAtomicfuDependencyNotation(Platform.JS, version))
5252
}
53-
withPluginWhenEvaluatedDependencies("kotlin-native") { version ->
54-
dependencies.add(IMPLEMENTATION_CONFIGURATION, getAtomicfuDependencyNotation(Platform.NATIVE, version))
55-
dependencies.add(TEST_IMPLEMENTATION_CONFIGURATION, getAtomicfuDependencyNotation(Platform.NATIVE, version))
56-
}
57-
withPluginWhenEvaluatedDependencies("kotlin-platform-common") { version ->
58-
dependencies.add(COMPILE_ONLY_CONFIGURATION, getAtomicfuDependencyNotation(Platform.COMMON, version))
59-
dependencies.add(TEST_IMPLEMENTATION_CONFIGURATION, getAtomicfuDependencyNotation(Platform.COMMON, version))
60-
}
6153
withPluginWhenEvaluatedDependencies("kotlin-multiplatform") { version ->
6254
configureMultiplatformPluginDependencies(version)
6355
}
@@ -96,10 +88,10 @@ private fun Project.configureTasks() {
9688
}
9789

9890
private enum class Platform(val suffix: String) {
99-
JVM(""),
91+
JVM("-jvm"),
10092
JS("-js"),
101-
NATIVE("-native"),
102-
COMMON("-common")
93+
NATIVE(""),
94+
MULTIPLATFORM("")
10395
}
10496

10597
private enum class CompilationType { MAIN, TEST }
@@ -119,15 +111,8 @@ private fun String.sourceSetNameToType(): CompilationType? = when (this) {
119111
private val Project.config: AtomicFUPluginExtension
120112
get() = extensions.findByName(EXTENSION_NAME) as? AtomicFUPluginExtension ?: AtomicFUPluginExtension(null)
121113

122-
private fun getAtomicfuDependencyNotation(platform: Platform, version: String): String {
123-
val suffix = when (platform) {
124-
// in common source sets, use a dependency on the MPP root module:
125-
Platform.COMMON -> atomicfuRootMppModulePlatform.suffix
126-
else -> platform.suffix
127-
}
128-
return "org.jetbrains.kotlinx:atomicfu$suffix:$version"
129-
}
130-
114+
private fun getAtomicfuDependencyNotation(platform: Platform, version: String): String =
115+
"org.jetbrains.kotlinx:atomicfu${platform.suffix}:$version"
131116

132117
// Note "afterEvaluate" does nothing when the project is already in executed state, so we need
133118
// a special check for this case
@@ -248,14 +233,29 @@ fun Project.sourceSetsByCompilation(): Map<KotlinSourceSet, List<KotlinCompilati
248233
return sourceSetsByCompilation
249234
}
250235

251-
private val atomicfuRootMppModulePlatform = Platform.NATIVE
252-
253236
fun Project.configureMultiplatformPluginDependencies(version: String) {
254237
if (rootProject.findProperty("kotlin.mpp.enableGranularSourceSetsMetadata").toString().toBoolean()) {
255-
val configurationName = project.extensions.getByType(KotlinMultiplatformExtension::class.java).sourceSets
238+
val mainConfigurationName = project.extensions.getByType(KotlinMultiplatformExtension::class.java).sourceSets
256239
.getByName(KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME)
257240
.compileOnlyConfigurationName
258-
dependencies.add(configurationName, getAtomicfuDependencyNotation(atomicfuRootMppModulePlatform, version))
241+
dependencies.add(mainConfigurationName, getAtomicfuDependencyNotation(Platform.MULTIPLATFORM, version))
242+
243+
val testConfigurationName = project.extensions.getByType(KotlinMultiplatformExtension::class.java).sourceSets
244+
.getByName(KotlinSourceSet.COMMON_TEST_SOURCE_SET_NAME)
245+
.implementationConfigurationName
246+
dependencies.add(testConfigurationName, getAtomicfuDependencyNotation(Platform.MULTIPLATFORM, version))
247+
248+
// For each source set that is only used in Native compilations, add an implementation dependency so that it
249+
// gets published and is properly consumed as a transitive dependency:
250+
sourceSetsByCompilation().forEach { (sourceSet, compilations) ->
251+
val isSharedNativeSourceSet = compilations.all {
252+
it.platformType == KotlinPlatformType.common || it.platformType == KotlinPlatformType.native
253+
}
254+
if (isSharedNativeSourceSet) {
255+
val configuration = sourceSet.implementationConfigurationName
256+
dependencies.add(configuration, getAtomicfuDependencyNotation(Platform.MULTIPLATFORM, version))
257+
}
258+
}
259259
} else {
260260
sourceSetsByCompilation().forEach { (sourceSet, compilations) ->
261261
val platformTypes = compilations.map { it.platformType }.toSet()
@@ -265,9 +265,9 @@ fun Project.configureMultiplatformPluginDependencies(version: String) {
265265
val compilationType = compilationNames.single().compilationNameToType()
266266
?: return@forEach // skip unknown compilations
267267
val platform =
268-
if (platformTypes.size > 1) Platform.COMMON else // mix of platform types -> "common"
268+
if (platformTypes.size > 1) Platform.MULTIPLATFORM else // mix of platform types -> "common"
269269
when (platformTypes.single()) {
270-
KotlinPlatformType.common -> Platform.COMMON
270+
KotlinPlatformType.common -> Platform.MULTIPLATFORM
271271
KotlinPlatformType.jvm, KotlinPlatformType.androidJvm -> Platform.JVM
272272
KotlinPlatformType.js -> Platform.JS
273273
KotlinPlatformType.native -> Platform.NATIVE
@@ -401,12 +401,17 @@ class AtomicFUPluginExtension(pluginVersion: String?) {
401401

402402
@CacheableTask
403403
open class AtomicFUTransformTask : ConventionTask() {
404+
@PathSensitive(PathSensitivity.RELATIVE)
404405
@InputFiles
405406
lateinit var inputFiles: FileCollection
407+
406408
@OutputDirectory
407409
lateinit var outputDir: File
410+
411+
@Classpath
408412
@InputFiles
409413
lateinit var classPath: FileCollection
414+
410415
@Input
411416
var variant = "FU"
412417
@Input
@@ -427,8 +432,10 @@ open class AtomicFUTransformTask : ConventionTask() {
427432

428433
@CacheableTask
429434
open class AtomicFUTransformJsTask : ConventionTask() {
435+
@PathSensitive(PathSensitivity.RELATIVE)
430436
@InputFiles
431437
lateinit var inputFiles: FileCollection
438+
432439
@OutputDirectory
433440
lateinit var outputDir: File
434441
@Input

atomicfu/build.gradle

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ kotlin {
2222
addNative(delegate.fromPreset(preset, preset.name))
2323
}
2424

25+
// JS -- always
26+
js {
27+
// TODO: Commented out because browser tests do not work on TeamCity
28+
// browser()
29+
nodejs()
30+
}
31+
2532
targets {
26-
// JVM & JS -- always
33+
// JVM -- always
2734
fromPreset(presets.jvm, 'jvm')
28-
fromPreset(presets.js, 'js') {
29-
// TODO: Commented out because browser tests do not work on TeamCity
30-
// browser()
31-
nodejs()
32-
}
3335

3436
if (project.ext.ideaActive) {
3537
addNative(fromPreset(project.ext.ideaPreset, 'native'))
@@ -113,25 +115,12 @@ if (!project.ext.ideaActive) {
113115
nativeMain.dependsOn(nativeInterop)
114116
}
115117

116-
afterEvaluate {
117-
def nativeTarget = kotlin.targets.findByName("linuxX64")
118-
def cinteropTask = tasks.named(kotlin.linuxX64().compilations["main"].cinterops[0].interopProcessingTaskName)
119-
def cinteropKlib = cinteropTask.map { it.outputFile }
120-
def fakeCinteropCompilation = kotlin.targets["metadata"].compilations[kotlin.sourceSets.nativeInterop.name]
121-
def destination = fakeCinteropCompilation.compileKotlinTask.destinationDir
122-
123-
task copyCinteropKlib(type: Zip) {
124-
from(zipTree(cinteropKlib).matching {
125-
exclude("targets/**") // with Kotlin pre-1.4
126-
exclude("default/targets/**") // with Kotlin 1.4
127-
})
128-
destinationDirectory.set(destination)
129-
archiveFileName.set("${project.name}_${fakeCinteropCompilation.name}.klib")
130-
dependsOn cinteropTask
131-
}
118+
apply from: "$rootDir/gradle/interop-as-source-set-klib.gradle"
132119

133-
fakeCinteropCompilation.output.classesDirs.from(files().builtBy(copyCinteropKlib))
134-
}
120+
registerInteropAsSourceSetOutput(
121+
kotlin.linuxX64().compilations["main"].cinterops["interop"],
122+
kotlin.sourceSets["nativeInterop"]
123+
)
135124
}
136125

137126
configurations {
@@ -148,15 +137,19 @@ dependencies {
148137

149138
// ==== CONFIGURE JS =====
150139

151-
tasks.withType(compileKotlinJs.getClass()) {
140+
def compileJsLegacy = tasks.hasProperty("compileKotlinJsLegacy")
141+
? compileKotlinJsLegacy
142+
: compileKotlinJs
143+
144+
tasks.withType(compileJsLegacy.getClass()) {
152145
kotlinOptions {
153146
moduleKind = "umd"
154147
sourceMap = true
155148
metaInfo = true
156149
}
157150
}
158151

159-
compileKotlinJs {
152+
compileJsLegacy.configure {
160153
kotlinOptions {
161154
// NOTE: Module base-name must be equal to the package name declared in package.json
162155
def baseName = "kotlinx-atomicfu"
@@ -165,7 +158,6 @@ compileKotlinJs {
165158
}
166159

167160
apply from: file("$rootProject.projectDir/gradle/node-js.gradle")
168-
apply from: file("$rootProject.projectDir/gradle/test-mocha-js.gradle")
169161
apply from: file("$rootProject.projectDir/gradle/publish-npm-js.gradle")
170162

171163
// Workaround the problem with Node downloading
@@ -177,26 +169,30 @@ repositories.whenObjectAdded {
177169
}
178170
}
179171

180-
def transformedJsFile = compileTestKotlinJs.kotlinOptions.outputFile
181-
compileTestKotlinJs {
172+
def compileTestJsLegacy = tasks.hasProperty("compileTestKotlinJsLegacy")
173+
? compileTestKotlinJsLegacy
174+
: compileTestKotlinJs
175+
176+
def transformedJsFile = compileTestJsLegacy.kotlinOptions.outputFile
177+
compileTestJsLegacy.configure {
182178
kotlinOptions {
183179
// NOTE: Module base-name must be equal to the package name declared in package.json
184180
def baseName = "kotlinx-atomicfu"
185181
outputFile = new File(outputFile.parent, baseName + ".js")
186182
}
187183
}
188-
def originalJsFile = compileTestKotlinJs.kotlinOptions.outputFile
184+
def originalJsFile = compileTestJsLegacy.kotlinOptions.outputFile
189185

190-
task transformJS(type: JavaExec, dependsOn: [compileTestKotlinJs]) {
186+
task transformJS(type: JavaExec, dependsOn: [compileTestJsLegacy]) {
191187
main = "kotlinx.atomicfu.transformer.AtomicFUTransformerJSKt"
192188
args = [originalJsFile, transformedJsFile]
193189
classpath = configurations.transformer
194190
inputs.file(originalJsFile)
195191
outputs.file(transformedJsFile)
196192
}
197193

198-
if (project.tasks.findByName('legacyjsNodeTest')) {
199-
legacyjsNodeTest.dependsOn transformJS
194+
if (project.tasks.findByName('jsLegacyNodeTest')) {
195+
jsLegacyNodeTest.dependsOn transformJS
200196
} else {
201197
jsNodeTest.dependsOn transformJS
202198
}
@@ -301,9 +297,15 @@ jvmTest.dependsOn jvmTestAll
301297

302298
afterEvaluate {
303299
publishing.publications {
304-
jvm.artifactId = 'atomicfu'
305-
js.artifactId = 'atomicfu-js'
306300
metadata.artifactId = 'atomicfu-common'
307-
kotlinMultiplatform.artifactId = 'atomicfu-native'
301+
302+
kotlinMultiplatform {
303+
apply from: "$rootDir/gradle/publish-mpp-root-module-in-platform.gradle"
304+
publishPlatformArtifactsInRootModule(jvm)
305+
}
308306
}
309307
}
308+
309+
tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication"}.configureEach {
310+
dependsOn(tasks["generatePomFileForJvmPublication"])
311+
}

gradle.properties

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
#
44

5-
version=0.14.3-SNAPSHOT
5+
version=0.14.4-SNAPSHOT
66
group=org.jetbrains.kotlinx
77

8-
kotlin_version=1.3.71
8+
kotlin_version=1.4.0
99
asm_version=7.2
1010
slf4j_version=1.8.0-alpha2
1111
junit_version=4.12
@@ -26,4 +26,8 @@ kotlin.native.ignoreDisabledTargets=true
2626
kotlin.js.compiler=both
2727

2828
kotlin.mpp.enableGranularSourceSetsMetadata=true
29-
kotlin.mpp.enableCompatibilityMetadataVariant=true
29+
kotlin.mpp.enableCompatibilityMetadataVariant=true
30+
31+
# Workaround for Bintray treating .sha512 files as artifacts
32+
# https://github.com/gradle/gradle/issues/11412
33+
systemProp.org.gradle.internal.publish.checksums.insecure=true
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
project.ext.registerInteropAsSourceSetOutput = { interop, sourceSet ->
6+
afterEvaluate {
7+
def cinteropTask = tasks.named(interop.interopProcessingTaskName)
8+
def cinteropKlib = cinteropTask.map { it.outputFile }
9+
def fakeCinteropCompilation = kotlin.targets["metadata"].compilations[sourceSet.name]
10+
def destination = fakeCinteropCompilation.compileKotlinTask.destinationDir
11+
12+
def tempDir = "$buildDir/tmp/${sourceSet.name}UnpackedInteropKlib"
13+
14+
def prepareKlibTaskProvider = tasks.register("prepare${sourceSet.name.capitalize()}InteropKlib", Sync) {
15+
from(files(zipTree(cinteropKlib).matching {
16+
exclude("targets/**", "default/targets/**")
17+
}).builtBy(cinteropTask))
18+
19+
into(tempDir)
20+
21+
doLast {
22+
def manifest140 = file("$tempDir/default/manifest")
23+
def manifest1371 = file("$tempDir/manifest")
24+
def manifest = manifest140.exists() ? manifest140 : manifest1371
25+
26+
def lines = manifest.readLines()
27+
def modifiedLines = lines.collect { line ->
28+
line.startsWith("depends=") ? "depends=stdlib ${manifest == manifest140 ? 'org.jetbrains.kotlin.native.platform.posix' : 'posix'}" :
29+
line.startsWith("native_targets=") ? "native_targets=" :
30+
line
31+
}
32+
manifest.text = modifiedLines.join("\n")
33+
}
34+
}
35+
36+
def copyCinteropTaskProvider = tasks.register("copy${sourceSet.name.capitalize()}CinteropKlib", Zip) {
37+
from(fileTree(tempDir).builtBy(prepareKlibTaskProvider))
38+
destinationDirectory.set(destination)
39+
archiveFileName.set("${project.name}_${fakeCinteropCompilation.name}.klib")
40+
dependsOn cinteropTask
41+
}
42+
43+
fakeCinteropCompilation.output.classesDirs.from(files().builtBy(copyCinteropTaskProvider))
44+
45+
kotlin.sourceSets.matching {
46+
def visited = new HashSet()
47+
def visit
48+
visit = { s -> if (visited.add(s)) s.dependsOn.each { visit(it) } }
49+
visit(it)
50+
sourceSet in visited
51+
}.all {
52+
project.dependencies.add(implementationMetadataConfigurationName, files(cinteropKlib))
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)