Skip to content

Fixes for 1.4-M2 & HMPP #2031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
import org.jetbrains.kotlin.konan.target.HostManager
import org.gradle.util.VersionNumber

apply plugin: 'jdk-convention'
apply from: rootProject.file("gradle/experimental.gradle")
Expand Down Expand Up @@ -79,6 +80,11 @@ buildscript {

import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType

// Hierarchical project structures are not fully supported in 1.3.7x MPP, enable conditionally for 1.4.x
if (VersionNumber.parse(kotlin_version) > VersionNumber.parse("1.3.79")) {
ext.set("kotlin.mpp.enableGranularSourceSetsMetadata", "true")
}

// todo:KLUDGE: This is needed to workaround dependency resolution between Java and MPP modules
def configureKotlinJvmPlatform(configuration) {
configuration.attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
Expand Down Expand Up @@ -192,6 +198,8 @@ if (build_snapshot_train) {
exclude '**/*definitely/not/kotlinx*'
// Disable because of KT-11567 in 1.4
exclude '**/*CasesPublicAPITest*'
// Kotlin
exclude '**/*PrecompiledDebugProbesTest*'
}
}

Expand Down
9 changes: 9 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ jekyll_version=4.0
# JS IR baceknd sometimes crashes with out-of-memory
# TODO: Remove once KT-37187 is fixed
org.gradle.jvmargs=-Xmx2g

# Workaround for Bintray treating .sha512 files as artifacts
# https://github.com/gradle/gradle/issues/11412
systemProp.org.gradle.internal.publish.checksums.insecure=true

# This is commented out, and the property is set conditionally in build.gradle, because 1.3.71 doesn't work with it.
# Once this property is set by default in new versions or 1.3.71 is dropped, either uncomment or remove this line.
#kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.mpp.enableCompatibilityMetadataVariant=true
36 changes: 27 additions & 9 deletions gradle/publish-bintray.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.util.VersionNumber

/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
Expand All @@ -11,6 +13,7 @@ apply plugin: 'maven-publish'

def isMultiplatform = project.name == "kotlinx-coroutines-core"
def isBom = project.name == "kotlinx-coroutines-bom"
def isKotlin137x = VersionNumber.parse(kotlin_version) <= VersionNumber.parse("1.3.79")

if (!isBom) {
apply plugin: "com.github.johnrengelman.shadow"
Expand Down Expand Up @@ -64,36 +67,51 @@ publishing {
publications.all {
MavenCentralKt.configureMavenCentralMetadata(pom, project)

// add empty javadocs (no need for MPP root publication which publishes only pom file)
if (it.name != 'kotlinMultiplatform' && !isBom) {
// add empty javadocs
if (!isBom && it.name != "kotlinMultiplatform") {
it.artifact(javadocJar)
}

// Rename MPP artifacts for backward compatibility
def type = it.name
switch (type) {
case 'kotlinMultiplatform':
it.artifactId = "$project.name-native"
// With Kotlin 1.4 & HMPP, the root module should have no suffix in the ID, but for compatibility with
// the consumers who can't read Gradle module metadata, we publish the JVM artifacts in it, too
it.artifactId = isKotlin137x ? "$project.name-native" : project.name
if (!isKotlin137x) {
apply from: "$rootDir/gradle/publish-mpp-root-module-in-platform.gradle"
publishPlatformArtifactsInRootModule(publications["jvm"])
}
break
case 'metadata':
it.artifactId = "$project.name-common"
// As the old -common dependencies will fail to resolve with Gradle module metadata, rename the module
// to '*-metadata' so that the resolution failure are more clear
it.artifactId = isKotlin137x ? "$project.name-common" : "$project.name-metadata"
break
case 'jvm':
it.artifactId = "$project.name"
it.artifactId = isKotlin137x ? project.name : "$project.name-jvm"
break
case 'js':
case 'native':
it.artifactId = "$project.name-$type"
break
}

// disable metadata everywhere, but in native and js modules
if (type == 'maven' || type == 'metadata' || type == 'jvm') {
moduleDescriptorGenerator = null
// Hierarchical project structures are not fully supported in 1.3.7x MPP
if (isKotlin137x) {
// disable metadata everywhere, but in native and js modules
if (type == 'maven' || type == 'metadata' || type == 'jvm') {
moduleDescriptorGenerator = null
}
}

}
}

tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication"}.configureEach {
dependsOn(tasks["generatePomFileForJvmPublication"])
}

task publishDevelopSnapshot() {
def branch = System.getenv('currentBranch')
if (branch == "develop") {
Expand Down
39 changes: 39 additions & 0 deletions gradle/publish-mpp-root-module-in-platform.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2014-2020 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/


/*
* Publish the platform JAR and POM so that consumers who depend on this module and can't read Gradle module metadata
* can still get the platform artifact and transitive dependencies from the POM.
*
* See the full rationale here https://youtrack.jetbrains.com/issue/KMM-237#focus=streamItem-27-4115233.0-0
*/
project.ext.publishPlatformArtifactsInRootModule = { platformPublication ->
def platformPomBuilder = null

platformPublication.pom.withXml { platformPomBuilder = asString() }

publishing.publications.kotlinMultiplatform {
platformPublication.artifacts.forEach {
artifact(it)
}

pom.withXml {
def pomStringBuilder = asString()
pomStringBuilder.setLength(0)
// The platform POM needs its artifact ID replaced with the artifact ID of the root module:
def platformPomString = platformPomBuilder.toString()
platformPomString.eachLine { line ->
if (!line.contains("<!--")) { // Remove the Gradle module metadata marker as it will be added anew
pomStringBuilder.append(line.replace(platformPublication.artifactId, artifactId))
pomStringBuilder.append("\n")
}
}
}
}

tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication"}.configureEach {
dependsOn(tasks["generatePomFileFor${platformPublication.name.capitalize()}Publication"])
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
11 changes: 9 additions & 2 deletions integration-testing/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType

/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
Expand Down Expand Up @@ -56,14 +58,19 @@ task npmTest(type: Test) {
task mavenTest(type: Test) {
def sourceSet = sourceSets.mavenTest
dependsOn(project(':').getTasksByName("publishToMavenLocal", true))
dependsOn.remove(project(':').getTasksByName("dokka", true))
testClassesDirs = sourceSet.output.classesDirs
classpath = sourceSet.runtimeClasspath
// we can't depend on the subprojects because we need to test the classfiles that are published in the end.
// also, we can't put this in the `dependencies` block because the resolution would happen before publication.
classpath += project.configurations.detachedConfiguration(
def mavenTestClasspathConfiguration = project.configurations.detachedConfiguration(
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"),
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"))

mavenTestClasspathConfiguration.attributes {
attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
}

classpath += mavenTestClasspathConfiguration
}

task debugAgentTest(type: Test) {
Expand Down
11 changes: 9 additions & 2 deletions kotlinx-coroutines-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,17 @@ kotlin.sourceSets {
}

jvmTest.dependencies {
api "org.jetbrains.kotlinx:lincheck:$lincheck_version"
// This is a workaround for https://youtrack.jetbrains.com/issue/KT-39037
def excludingCurrentProject = { dependency ->
def result = project.dependencies.create(dependency)
result.exclude(module: project.name)
return result
}

api(excludingCurrentProject("org.jetbrains.kotlinx:lincheck:$lincheck_version"))
api "org.jetbrains.kotlinx:kotlinx-knit-test:$knit_version"
api "com.esotericsoftware:kryo:4.0.0"
implementation project (":android-unit-tests")
implementation(excludingCurrentProject(project(":android-unit-tests")))
}
}

Expand Down