From 4b8f8604f28be7f6fbc2f81a2a2dde9387cd68ef Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Tue, 6 Nov 2018 13:54:36 +0000 Subject: [PATCH] Change kotlinSourceSets -> allKotlinSourceSets This ensures that transitive SourceSets are also merged and included in the model. --- .../kotlin/gradle/model/builder/KotlinModelBuilder.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilder.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilder.kt index fe38e90878a..62766b8fa2f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilder.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/model/builder/KotlinModelBuilder.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.gradle.plugin.KOTLIN_JS_DSL_NAME import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import org.jetbrains.kotlin.gradle.plugin.getConvention import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget +import org.jetbrains.kotlin.gradle.plugin.mpp.allKotlinSourceSets import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile /** @@ -102,18 +103,16 @@ class KotlinModelBuilder(private val kotlinPluginVersion: String, private val an } /** - * The [SourceSet] returned by this method is not intended to be complete, most of the information here is exposed by the - * Android Gradle plugin and as such is not populated here. The important information here that is required by - * Android Studio are the [CompilerArguments]. + * Constructs the Android [SourceSet] that should be returned to the IDE for each compile task/variant. */ private fun AbstractKotlinCompile<*>.createAndroidSourceSet(androidTarget: KotlinAndroidTarget): SourceSet { val variantName = sourceSetName val compilation = androidTarget.compilations.getByName(variantName) // Merge all sources and resource dirs from the different Source Sets that make up this variant. - val sources = compilation.kotlinSourceSets.flatMap { + val sources = compilation.allKotlinSourceSets.flatMap { it.kotlin.srcDirs }.distinctBy { it.absolutePath } - val resources = compilation.kotlinSourceSets.flatMap { + val resources = compilation.allKotlinSourceSets.flatMap { it.resources.srcDirs }.distinctBy { it.absolutePath } return SourceSetImpl(