-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathAuxBuildConfiguration.kt
53 lines (48 loc) · 2.04 KB
/
AuxBuildConfiguration.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import CacheRedirector.configure
import org.gradle.api.Project
import org.gradle.api.tasks.*
import org.gradle.kotlin.dsl.*
/**
* Auxiliary build configuration that is grouped in a single place for convenience:
* - Workarounds for Gradle/KGP issues
* - Cache redirector
*/
object AuxBuildConfiguration {
@JvmStatic
fun configure(rootProject: Project) {
rootProject.allprojects {
CacheRedirector.configure(this)
workaroundForCoroutinesLeakageToClassPath()
}
CacheRedirector.configureJsPackageManagers(rootProject)
// Sigh, there is no BuildScanExtension in classpath when there is no --scan
rootProject.extensions.findByName("buildScan")?.withGroovyBuilder {
setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service")
setProperty("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.
* TODO figure out if it's still the problem
*/
private fun Project.workaroundForCoroutinesLeakageToClassPath() {
configurations
.matching {
// Excluding substituted project itself because of circular dependencies, but still do it
// for "*Test*" configurations
name != coreModule || it.name.contains("Test")
}
.configureEach {
resolutionStrategy.dependencySubstitution {
substitute(module("org.jetbrains.kotlinx:$coreModule"))
.using(project(":$coreModule"))
.because(
"Because Kotlin compiler embeddable leaks coroutines into the runtime classpath, " +
"triggering all sort of incompatible class changes errors"
)
}
}
}
}