Minor: inline addDependsOnSourceSets in buildCompilation
This commit is contained in:
committed by
Yaroslav Chernyshev
parent
4927777ffb
commit
96a4d19365
@@ -331,12 +331,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
|
|
||||||
val gradleCompilations = gradleTarget.compilations ?: return null
|
val gradleCompilations = gradleTarget.compilations ?: return null
|
||||||
val compilations = gradleCompilations.mapNotNull {
|
val compilations = gradleCompilations.mapNotNull {
|
||||||
val compilation = buildCompilation(importingContext, it, disambiguationClassifier, dependencyResolver, dependencyMapper)
|
buildCompilation(importingContext, it, platform, disambiguationClassifier, dependencyResolver, dependencyMapper)
|
||||||
if (compilation == null || platform != KotlinPlatform.ANDROID) {
|
|
||||||
compilation
|
|
||||||
} else {
|
|
||||||
compilation.addDependsOnSourceSetsToCompilation(importingContext)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val jar = buildTargetJar(gradleTarget, importingContext.project)
|
val jar = buildTargetJar(gradleTarget, importingContext.project)
|
||||||
val testRunTasks = buildTestRunTasks(importingContext.project, gradleTarget)
|
val testRunTasks = buildTestRunTasks(importingContext.project, gradleTarget)
|
||||||
@@ -362,24 +357,6 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
return target
|
return target
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KotlinCompilationImpl.addDependsOnSourceSetsToCompilation(
|
|
||||||
importingContext: MultiplatformModelImportingContext
|
|
||||||
): KotlinCompilationImpl {
|
|
||||||
val dependsOnSourceSets = this.allSourceSets.flatMap { it.dependsOnSourceSets }.mapNotNull { importingContext.sourceSetByName(it) }
|
|
||||||
|
|
||||||
return KotlinCompilationImpl(
|
|
||||||
this.name,
|
|
||||||
this.allSourceSets.union(dependsOnSourceSets),
|
|
||||||
this.allSourceSets,
|
|
||||||
this.dependencies,
|
|
||||||
this.output,
|
|
||||||
this.arguments,
|
|
||||||
this.dependencyClasspath,
|
|
||||||
this.kotlinTaskProperties,
|
|
||||||
this.nativeExtensions
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun buildNativeMainRunTasks(gradleTarget: Named): Collection<KotlinNativeMainRunTask> {
|
private fun buildNativeMainRunTasks(gradleTarget: Named): Collection<KotlinNativeMainRunTask> {
|
||||||
val executableBinaries = (gradleTarget::class.java.getMethodOrNull("getBinaries")?.invoke(gradleTarget) as? Collection<Any>)
|
val executableBinaries = (gradleTarget::class.java.getMethodOrNull("getBinaries")?.invoke(gradleTarget) as? Collection<Any>)
|
||||||
?.filter { it.javaClass.name == "org.jetbrains.kotlin.gradle.plugin.mpp.Executable" } ?: return emptyList()
|
?.filter { it.javaClass.name == "org.jetbrains.kotlin.gradle.plugin.mpp.Executable" } ?: return emptyList()
|
||||||
@@ -489,6 +466,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
private fun buildCompilation(
|
private fun buildCompilation(
|
||||||
importingContext: MultiplatformModelImportingContext,
|
importingContext: MultiplatformModelImportingContext,
|
||||||
gradleCompilation: Named,
|
gradleCompilation: Named,
|
||||||
|
platform: KotlinPlatform,
|
||||||
classifier: String?,
|
classifier: String?,
|
||||||
dependencyResolver: DependencyResolver,
|
dependencyResolver: DependencyResolver,
|
||||||
dependencyMapper: KotlinDependencyMapper
|
dependencyMapper: KotlinDependencyMapper
|
||||||
@@ -516,9 +494,16 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
}
|
}
|
||||||
val nativeExtensions = konanTarget?.let(::KotlinNativeCompilationExtensionsImpl)
|
val nativeExtensions = konanTarget?.let(::KotlinNativeCompilationExtensionsImpl)
|
||||||
|
|
||||||
|
val allSourceSets = if (platform != KotlinPlatform.ANDROID) {
|
||||||
|
kotlinSourceSets
|
||||||
|
} else {
|
||||||
|
kotlinSourceSets.flatMap { it.dependsOnSourceSets }.mapNotNull { importingContext.sourceSetByName(it) }
|
||||||
|
.union(kotlinSourceSets)
|
||||||
|
}
|
||||||
|
|
||||||
return KotlinCompilationImpl(
|
return KotlinCompilationImpl(
|
||||||
gradleCompilation.name,
|
gradleCompilation.name,
|
||||||
kotlinSourceSets, // In fact, it's only default source-sets. It will be corrected later, see [addDependsOnSourceSetsToCompilation]
|
allSourceSets,
|
||||||
kotlinSourceSets,
|
kotlinSourceSets,
|
||||||
dependencies.map { dependencyMapper.getId(it) }.distinct().toTypedArray(),
|
dependencies.map { dependencyMapper.getId(it) }.distinct().toTypedArray(),
|
||||||
output,
|
output,
|
||||||
|
|||||||
Reference in New Issue
Block a user