MPP: Force COMMON platform for commonMain/commonTest source sets

Also set isTestModule flag for them according to source set name alone

 #KT-26356 Fixed
This commit is contained in:
Alexey Sedunov
2018-09-06 17:50:16 +03:00
parent ad4a3c0b7c
commit ff105cb059
3 changed files with 29 additions and 0 deletions
@@ -23,6 +23,11 @@ interface KotlinSourceSet : KotlinModule {
val sourceDirs: Set<File>
val resourceDirs: Set<File>
val dependsOnSourceSets: Set<String>
companion object {
const val COMMON_MAIN_SOURCE_SET_NAME = "commonMain"
const val COMMON_TEST_SOURCE_SET_NAME = "commonTest"
}
}
interface KotlinLanguageSettings : Serializable {
@@ -308,6 +308,18 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
}
}
for (sourceSet in sourceSets) {
val name = sourceSet.name
if (name == KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME) {
sourceSet.platform = KotlinPlatform.COMMON
sourceSet.isTestModule = false
continue
}
if (name == KotlinSourceSet.COMMON_TEST_SOURCE_SET_NAME) {
sourceSet.platform = KotlinPlatform.COMMON
sourceSet.isTestModule = true
continue
}
val compilations = sourceSetToCompilations[sourceSet]
if (compilations != null) {
sourceSet.platform = compilations.map { it.platform }.distinct().singleOrNull() ?: KotlinPlatform.COMMON
@@ -308,6 +308,18 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
}
}
for (sourceSet in sourceSets) {
val name = sourceSet.name
if (name == KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME) {
sourceSet.platform = KotlinPlatform.COMMON
sourceSet.isTestModule = false
continue
}
if (name == KotlinSourceSet.COMMON_TEST_SOURCE_SET_NAME) {
sourceSet.platform = KotlinPlatform.COMMON
sourceSet.isTestModule = true
continue
}
val compilations = sourceSetToCompilations[sourceSet]
if (compilations != null) {
sourceSet.platform = compilations.map { it.platform }.distinct().singleOrNull() ?: KotlinPlatform.COMMON