Skip to content

Improve ':kotlinx-coroutines-core' substitution for all modules. #2748

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 2 commits into from
Jun 7, 2021
Merged
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
37 changes: 33 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
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 @@ -74,9 +75,6 @@ buildscript {

CacheRedirector.configureBuildScript(buildscript, rootProject)
}

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

// todo:KLUDGE: Hierarchical project structures are not fully supported in IDEA, enable only for a regular built
if (!Idea.active) {
ext.set("kotlin.mpp.enableGranularSourceSetsMetadata", "true")
Expand Down Expand Up @@ -288,3 +286,34 @@ if (jvm_ir_enabled) {
}
}
}

// Opt-in for build scan in order to troubleshoot Gradle on TC
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}

/*
* kotlinx-coroutines-core dependency leaks into test runtime classpath via kotlin-compiler-embeddable
* and conflicts with our own test/runtime incompatibilities (e.g. when class is moved from a main to test),
* so we do substitution here
*/
allprojects { subProject ->
subProject
.configurations
.matching {
// Excluding substituted project itself because of circular dependencies, but still do it
// for "*Test*" configurations
subProject.name != "kotlinx-coroutines-core" || it.name.contains("Test")
}
.configureEach { conf ->
conf.resolutionStrategy.dependencySubstitution {
substitute(module("org.jetbrains.kotlinx:kotlinx-coroutines-core"))
.using(project(":kotlinx-coroutines-core"))
.because("Because Kotlin compiler embeddable leaks coroutines into the runtime classpath, " +
"triggering all sort of incompatible class changes errors")
}
}
}