Skip to content

Commit 1392686

Browse files
qwwdfsadTapchicoma
andauthored
Improve ':kotlinx-coroutines-core' substitution for all modules. (#2748)
* Improve ':kotlinx-coroutines-core' substitution for all modules. Ensure "org.jetbrains.kotlinx:kotlinx-coroutines-core" transitive dependencies are substituted with project itself to avoid test errors. Co-authored-by: Yahor Berdnikau <[email protected]>
1 parent a8ae077 commit 1392686

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

build.gradle

+33-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/*
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
4+
5+
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
46
import org.jetbrains.kotlin.konan.target.HostManager
5-
import org.gradle.util.VersionNumber
67

78
apply plugin: 'jdk-convention'
89
apply from: rootProject.file("gradle/experimental.gradle")
@@ -74,9 +75,6 @@ buildscript {
7475

7576
CacheRedirector.configureBuildScript(buildscript, rootProject)
7677
}
77-
78-
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
79-
8078
// todo:KLUDGE: Hierarchical project structures are not fully supported in IDEA, enable only for a regular built
8179
if (!Idea.active) {
8280
ext.set("kotlin.mpp.enableGranularSourceSetsMetadata", "true")
@@ -288,3 +286,34 @@ if (jvm_ir_enabled) {
288286
}
289287
}
290288
}
289+
290+
// Opt-in for build scan in order to troubleshoot Gradle on TC
291+
if (hasProperty('buildScan')) {
292+
buildScan {
293+
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
294+
termsOfServiceAgree = 'yes'
295+
}
296+
}
297+
298+
/*
299+
* kotlinx-coroutines-core dependency leaks into test runtime classpath via kotlin-compiler-embeddable
300+
* and conflicts with our own test/runtime incompatibilities (e.g. when class is moved from a main to test),
301+
* so we do substitution here
302+
*/
303+
allprojects { subProject ->
304+
subProject
305+
.configurations
306+
.matching {
307+
// Excluding substituted project itself because of circular dependencies, but still do it
308+
// for "*Test*" configurations
309+
subProject.name != "kotlinx-coroutines-core" || it.name.contains("Test")
310+
}
311+
.configureEach { conf ->
312+
conf.resolutionStrategy.dependencySubstitution {
313+
substitute(module("org.jetbrains.kotlinx:kotlinx-coroutines-core"))
314+
.using(project(":kotlinx-coroutines-core"))
315+
.because("Because Kotlin compiler embeddable leaks coroutines into the runtime classpath, " +
316+
"triggering all sort of incompatible class changes errors")
317+
}
318+
}
319+
}

0 commit comments

Comments
 (0)