diff --git a/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelBuilder.kt b/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelBuilder.kt index 4fdac0f63a0..5bad7035c12 100644 --- a/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelBuilder.kt +++ b/idea/kotlin-gradle-tooling/src/KotlinMPPGradleModelBuilder.kt @@ -57,7 +57,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService { reportUnresolvedDependencies(targets) val kotlinNativeHome = KotlinNativeHomeEvaluator.getKotlinNativeHome(project) ?: NO_KOTLIN_NATIVE_HOME return KotlinMPPGradleModelImpl( - filterOrphanSourceSets(sourceSetMap, targets, project), + filterOrphanSourceSets(sourceSetMap, targets), targets, ExtraFeaturesImpl(coroutinesState, isHMPPEnabled(project)), kotlinNativeHome, @@ -65,21 +65,8 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService { ) } - private fun filterOrphanSourceSets( - sourceSets: Map, - targets: Collection, - project: Project - ): Map { - if (project.properties["import_orphan_source_sets"]?.toString()?.toBoolean() ?: DEFAULT_IMPORT_ORPHAN_SOURCE_SETS) return sourceSets - val compiledSourceSets: Collection = targets.flatMap { it.compilations }.flatMap { it.sourceSets }.flatMap { it.dependsOnSourceSets.union(listOf(it.name)) }.distinct() - sourceSets.filter { !compiledSourceSets.contains(it.key) }.forEach { - logger.warn("[sync warning] Source set \"${it.key}\" is not compiled with any compilation. This source set is not imported in the IDE.") - } - return sourceSets.filter { compiledSourceSets.contains(it.key) } - } - private fun isHMPPEnabled(project: Project): Boolean { - //TODO(auskov): replace with Project.isKotlinGranularMetadataEnabled after merging with gradle branch + //TODO(auskov): replace with Project.isKotlinGranularMetadataEnabled after merging with gradle pranch return (project.findProperty("kotlin.mpp.enableGranularSourceSetsMetadata") as? String)?.toBoolean() ?: false } @@ -595,6 +582,16 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService { } for (sourceSet in sourceSets.values) { + val name = sourceSet.name + if (name == KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME) { + sourceSet.isTestModule = false + continue + } + if (name == KotlinSourceSet.COMMON_TEST_SOURCE_SET_NAME) { + sourceSet.isTestModule = true + continue + } + val compilations = sourceSetToCompilations[sourceSet] if (compilations != null) { val platforms = compilations.map { it.platform } @@ -608,16 +605,8 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService { sourceSet.isTestModule = compilations.all { it.isTestModule } } else { - //TODO(auskov): remove this branch as far as import of orphan source sets is dropped - val name = sourceSet.name - if (name == KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME) { - sourceSet.isTestModule = false - continue - } - if (name == KotlinSourceSet.COMMON_TEST_SOURCE_SET_NAME) { - sourceSet.isTestModule = true - continue - } + // TODO: change me after design about it + sourceSet.isTestModule = "Test" in sourceSet.name } } }