Remove unused KotlinSourceSetImpl.defaultIsTestModule; simplify logic of test modules detection

^KT-37127
This commit is contained in:
Dmitry Savvinov
2021-01-14 11:52:28 +03:00
parent 58b2064295
commit 9e58e3c3fd
2 changed files with 6 additions and 15 deletions
@@ -785,16 +785,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
}
}
// TODO DISCUSS AT REVIEW: can we simplify it to:
// sourceSet.isTestModule = importingContext.compilationsBySourceSet(sourceSet)?.all { it.isTestModule} ?: false
// ^
// |
// sic!
// The difference from the current behaviour would be in case if source set is not included into any compilation AND
// KotlinSourceSetImpl.defaultIsTestModule is set to 'true'. Though I don't know who and why would do that.
importingContext.compilationsBySourceSet(sourceSet)?.all { it.isTestModule }?.let { isTest ->
sourceSet.isTestModule = isTest
}
sourceSet.isTestModule = importingContext.compilationsBySourceSet(sourceSet)?.all { it.isTestModule } ?: false
importingContext.compilationsBySourceSet(sourceSet)?.let { compilations ->
val platforms = compilations.map { it.platform }
@@ -36,7 +36,6 @@ class KotlinSourceSetImpl(
override val dependencies: Array<KotlinDependencyId>,
override val dependsOnSourceSets: Set<String>,
val defaultPlatform: KotlinPlatformContainerImpl = KotlinPlatformContainerImpl(),
val defaultIsTestModule: Boolean = false
) : KotlinSourceSet {
constructor(kotlinSourceSet: KotlinSourceSet, cloningCache: MutableMap<Any, Any>) : this(
@@ -46,14 +45,15 @@ class KotlinSourceSetImpl(
HashSet(kotlinSourceSet.resourceDirs),
kotlinSourceSet.dependencies,
HashSet(kotlinSourceSet.dependsOnSourceSets),
KotlinPlatformContainerImpl(kotlinSourceSet.actualPlatforms),
kotlinSourceSet.isTestModule
)
KotlinPlatformContainerImpl(kotlinSourceSet.actualPlatforms)
) {
this.isTestModule = kotlinSourceSet.isTestModule
}
override var actualPlatforms: KotlinPlatformContainer = defaultPlatform
internal set
override var isTestModule: Boolean = defaultIsTestModule
override var isTestModule: Boolean = false
internal set
override fun toString() = name