diff --git a/atomicfu/build.gradle b/atomicfu/build.gradle index 11d73cdc..ceb3f6c4 100644 --- a/atomicfu/build.gradle +++ b/atomicfu/build.gradle @@ -139,21 +139,6 @@ if (rootProject.ext.native_targets_enabled) { } } } - - // Hack for publishing as HMPP: pack the cinterop klib as a source set: - if (!project.ext.ideaActive) { - kotlin.sourceSets { - nativeInterop - nativeMain.dependsOn(nativeInterop) - } - - apply from: "$rootDir/gradle/interop-as-source-set-klib.gradle" - - registerInteropAsSourceSetOutput( - kotlin.linuxX64().compilations["main"].cinterops["interop"], - kotlin.sourceSets["nativeInterop"] - ) - } } configurations { diff --git a/gradle.properties b/gradle.properties index ae48789f..c4b8557f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,8 +27,8 @@ kotlin.native.ignoreDisabledTargets=true kotlin.js.compiler=both -kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.mpp.enableCompatibilityMetadataVariant=true +kotlin.mpp.enableCInteropCommonization=true # Workaround for Bintray treating .sha512 files as artifacts # https://github.com/gradle/gradle/issues/11412 diff --git a/gradle/interop-as-source-set-klib.gradle b/gradle/interop-as-source-set-klib.gradle deleted file mode 100644 index 25cb0c27..00000000 --- a/gradle/interop-as-source-set-klib.gradle +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ - -project.ext.registerInteropAsSourceSetOutput = { interop, sourceSet -> - afterEvaluate { - def cinteropTask = tasks.named(interop.interopProcessingTaskName) - def cinteropKlib = cinteropTask.map { it.outputFile } - def fakeCinteropCompilation = kotlin.targets["metadata"].compilations[sourceSet.name] - def destination = fakeCinteropCompilation.compileKotlinTask.destinationDirectory - - def tempDir = "$buildDir/tmp/${sourceSet.name}UnpackedInteropKlib" - - def prepareKlibTaskProvider = tasks.register("prepare${sourceSet.name.capitalize()}InteropKlib", Sync) { - from(files(zipTree(cinteropKlib).matching { - exclude("targets/**", "default/targets/**") - }).builtBy(cinteropTask)) - - into(tempDir) - - doLast { - def manifest140 = file("$tempDir/default/manifest") - def manifest1371 = file("$tempDir/manifest") - def manifest = manifest140.exists() ? manifest140 : manifest1371 - - def lines = manifest.readLines() - def modifiedLines = lines.collect { line -> - line.startsWith("depends=") ? "depends=stdlib ${manifest == manifest140 ? 'org.jetbrains.kotlin.native.platform.posix' : 'posix'}" : - line.startsWith("native_targets=") ? "native_targets=" : - line - } - manifest.text = modifiedLines.join("\n") - } - } - - def copyCinteropTaskProvider = tasks.register("copy${sourceSet.name.capitalize()}CinteropKlib", Zip) { - from(fileTree(tempDir).builtBy(prepareKlibTaskProvider)) - destinationDirectory.set(destination) - archiveFileName.set("${project.name}_${fakeCinteropCompilation.name}.klib") - dependsOn cinteropTask - } - - fakeCinteropCompilation.output.classesDirs.from(files().builtBy(copyCinteropTaskProvider)) - - kotlin.sourceSets.matching { - def visited = new HashSet() - def visit - visit = { s -> if (visited.add(s)) s.dependsOn.each { visit(it) } } - visit(it) - sourceSet in visited - }.all { - project.dependencies.add(implementationMetadataConfigurationName, files(cinteropKlib)) - } - } -}