Merge KT-MR-1260 from rr/gradle/igushkin/fix-kt-39304-unused-source-sets-failure
This commit is contained in:
+7
@@ -91,6 +91,13 @@ kotlin {
|
||||
linuxX64().compilations["test"].defaultSourceSet {
|
||||
dependsOn(linuxAndJsTest)
|
||||
}
|
||||
|
||||
// Test KT-39304
|
||||
val unusedSourceSet by creating {
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-7
@@ -18,6 +18,7 @@ import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.api.tasks.TaskState
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.fir.resolve.getOrPut
|
||||
import org.jetbrains.kotlin.gradle.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.internal.KotlinCompilationsModuleGroups
|
||||
@@ -326,13 +327,17 @@ internal object CompilationSourceSetUtil {
|
||||
|
||||
val compilations = targets.flatMap { it.compilations }
|
||||
|
||||
val result = compilations
|
||||
.flatMap { compilation -> compilation.allKotlinSourceSets.map { sourceSet -> compilation to sourceSet } }
|
||||
.groupBy(
|
||||
{ (_, sourceSet) -> sourceSet },
|
||||
valueTransform = { (compilation, _) -> compilation }
|
||||
)
|
||||
.mapValues { (_, compilations) -> compilations.toSet() }
|
||||
val result = mutableMapOf<KotlinSourceSet, MutableSet<KotlinCompilation<*>>>().apply {
|
||||
compilations.forEach { compilation ->
|
||||
compilation.allKotlinSourceSets.forEach { sourceSet ->
|
||||
getOrPut(sourceSet) { mutableSetOf() }.add(compilation)
|
||||
}
|
||||
}
|
||||
kotlinExtension.sourceSets.forEach { sourceSet ->
|
||||
// For source sets not taking part in any compilation, keep an empty set to avoid errors on access by key
|
||||
getOrPut(sourceSet) { mutableSetOf() }
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldFinalizeValue) {
|
||||
set(result)
|
||||
|
||||
Reference in New Issue
Block a user