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:
@@ -23,6 +23,11 @@ interface KotlinSourceSet : KotlinModule {
|
|||||||
val sourceDirs: Set<File>
|
val sourceDirs: Set<File>
|
||||||
val resourceDirs: Set<File>
|
val resourceDirs: Set<File>
|
||||||
val dependsOnSourceSets: Set<String>
|
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 {
|
interface KotlinLanguageSettings : Serializable {
|
||||||
|
|||||||
@@ -308,6 +308,18 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (sourceSet in sourceSets) {
|
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]
|
val compilations = sourceSetToCompilations[sourceSet]
|
||||||
if (compilations != null) {
|
if (compilations != null) {
|
||||||
sourceSet.platform = compilations.map { it.platform }.distinct().singleOrNull() ?: KotlinPlatform.COMMON
|
sourceSet.platform = compilations.map { it.platform }.distinct().singleOrNull() ?: KotlinPlatform.COMMON
|
||||||
|
|||||||
@@ -308,6 +308,18 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (sourceSet in sourceSets) {
|
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]
|
val compilations = sourceSetToCompilations[sourceSet]
|
||||||
if (compilations != null) {
|
if (compilations != null) {
|
||||||
sourceSet.platform = compilations.map { it.platform }.distinct().singleOrNull() ?: KotlinPlatform.COMMON
|
sourceSet.platform = compilations.map { it.platform }.distinct().singleOrNull() ?: KotlinPlatform.COMMON
|
||||||
|
|||||||
Reference in New Issue
Block a user