Skip to content

Commit 4cfd88a

Browse files
authored
Update kotlinx-coroutines-core build file for IDE friendliness (#3795)
The build configuration modification was done to prevent unexpected "shared jvm" behavior in IDE due to the improper jvmCoreMain to jvmMain dependency. A conditional dependency inclusion is added, which will only engage in CLI builds and not in the IDE. This change addresses the issue KTIJ-25959 and avoids IDE confusion with multi-compilation scenarios.
1 parent 2bd0f29 commit 4cfd88a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

kotlinx-coroutines-core/build.gradle

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,22 @@ kotlin {
135135
def jvmMain = sourceSets.jvmMain
136136
def jvmCoreMain = sourceSets.create('jvmCoreMain')
137137
def jdk8Main = sourceSets.create('jdk8Main')
138-
jvmCoreMain.dependsOn(jvmMain)
139138
jdk8Main.dependsOn(jvmMain)
140139

140+
/**
141+
* See: https://youtrack.jetbrains.com/issue/KTIJ-25959
142+
* The dependency from jvmCore to jvmMain is only for CLI builds and not intended for the IDE.
143+
* In the current setup there are two tooling unfriendly configurations used:
144+
* 1: - jvmMain, despite being a platform source set, is not a leaf (jvmCoreMain and jdk8Main dependOn it)
145+
* 2: - jvmMain effectively becomes a 'shared jvm' source set
146+
*
147+
* Using this kludge here, will prevent issue 2 from being visible to the IDE.
148+
* Therefore jvmMain will resolve using the 'single' compilation it participates in (from the perspective of the IDE)
149+
*/
150+
if (!Idea.active) {
151+
jvmCoreMain.dependsOn(jvmMain)
152+
}
153+
141154
sourceSets.forEach {
142155
SourceSetsKt.configureMultiplatform(it)
143156
}

0 commit comments

Comments
 (0)