MPP: Add production module dependencies to the test one (new MPP import)

#KT-25985 In Progress
This commit is contained in:
Alexey Sedunov
2018-08-15 13:00:13 +03:00
parent 443f8b6f02
commit d194893012
2 changed files with 18 additions and 7 deletions
@@ -337,13 +337,14 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
}
}
}
val sourceSetGraph = GraphBuilder.directed().build<KotlinSourceSet>()
val sourceSetGraph = GraphBuilder.directed().build<KotlinModule>()
processSourceSets(gradleModule, mppModel, ideModule, resolverCtx) { dataNode, sourceSet ->
dataNode.data.productionModuleId?.let {
val productionModuleDataNode = ideModule.findChildModuleByInternalName(it)
if (productionModuleDataNode != null) {
addDependency(dataNode, productionModuleDataNode)
}
val productionSourceSet = dataNode.data.productionModuleId
?.let { ideModule.findChildModuleByInternalName(it) }
?.kotlinSourceSet
?.kotlinModule
if (productionSourceSet != null) {
sourceSetGraph.putEdge(sourceSet, productionSourceSet!!)
}
for (targetSourceSetName in sourceSet.dependsOnSourceSets) {
val targetSourceSet = mppModel.sourceSets[targetSourceSetName] ?: continue
@@ -358,6 +359,16 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
preprocessDependencies(sourceSet, ideProject),
ideProject
)
if (productionSourceSet != null) {
buildDependencies(
resolverCtx,
sourceSetMap,
artifactsMap,
dataNode,
preprocessDependencies(productionSourceSet, ideProject),
ideProject
)
}
}
}
for (edge in Graphs.transitiveClosure(sourceSetGraph).edges()) {
@@ -14,4 +14,4 @@ fun DataNode<*>.findChildModuleById(id: String) =
@Suppress("UNCHECKED_CAST")
fun DataNode<*>.findChildModuleByInternalName(name: String) =
children.firstOrNull { (it.data as? ModuleData)?.internalName == name }
children.firstOrNull { (it.data as? ModuleData)?.internalName == name } as? DataNode<out ModuleData>