From 0a3b3056d8537ec6db3830eb04038e7735fb59f6 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Tue, 20 Feb 2018 19:26:24 +0300 Subject: [PATCH] MPP: Support multiple 'expectedBy' dependencies for single module #KT-22865 Fixed Original commit: d9aa1796cdbc5f799dc464b3915d7d29f8fbb996 --- .../kotlin/config/KotlinFacetSettings.kt | 2 +- .../kotlin/config/facetSerialization.kt | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt index 48c89ae5881..21d5586a4fe 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -192,7 +192,7 @@ class KotlinFacetSettings { } } - var implementedModuleName: String? = null + var implementedModuleNames: List = emptyList() var productionOutputPath: String? = null var testOutputPath: String? = null diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt index c37eab577f0..82374598345 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -99,7 +99,12 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings { val platformName = element.getAttributeValue("platform") val platformKind = TargetPlatformKind.ALL_PLATFORMS.firstOrNull { it.description == platformName } ?: TargetPlatformKind.DEFAULT_PLATFORM element.getChild("implements")?.let { - implementedModuleName = (it.content.firstOrNull() as? Text)?.textTrim + val items = it.getChildren("implement") + implementedModuleNames = if (items.isNotEmpty()) { + items.mapNotNull { (it.content.firstOrNull() as? Text)?.textTrim } + } else { + listOfNotNull((it.content.firstOrNull() as? Text)?.textTrim) + } } element.getChild("compilerSettings")?.let { compilerSettings = CompilerSettings() @@ -237,8 +242,17 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) { if (!useProjectSettings) { element.setAttribute("useProjectSettings", useProjectSettings.toString()) } - implementedModuleName?.let { - element.addContent(Element("implements").apply { addContent(it) }) + if (implementedModuleNames.isNotEmpty()) { + element.addContent( + Element("implements").apply { + val singleModule = implementedModuleNames.singleOrNull() + if (singleModule != null) { + addContent(singleModule) + } else { + implementedModuleNames.map { addContent(Element("implement").apply { addContent(it) }) } + } + } + ) } productionOutputPath?.let { if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) {