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 21d5586a4fe..44dd61b6607 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -112,6 +112,12 @@ var CommonCompilerArguments.apiVersionView: VersionView autoAdvanceApiVersion = value == VersionView.LatestStable } +enum class KotlinModuleKind { + DEFAULT, + SOURCE_SET_HOLDER, + COMPILATION_AND_SOURCE_SET_HOLDER +} + class KotlinFacetSettings { companion object { // Increment this when making serialization-incompatible changes to configuration data @@ -196,6 +202,9 @@ class KotlinFacetSettings { var productionOutputPath: String? = null var testOutputPath: String? = null + + var kind: KotlinModuleKind = KotlinModuleKind.DEFAULT + var sourceSetNames: List = emptyList() } fun TargetPlatformKind<*>.createCompilerArguments(init: CommonCompilerArguments.() -> Unit = {}): CommonCompilerArguments { 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 21ecb8fd1c3..c4a7e07407a 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -111,6 +111,20 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings { listOfNotNull((it.content.firstOrNull() as? Text)?.textTrim) } } + element.getChild("sourceSets")?.let { + val items = it.getChildren("sourceSet") + sourceSetNames = items.mapNotNull { (it.content.firstOrNull() as? Text)?.textTrim } + } + kind = element.getChild("newMppModelJpsModuleKind")?.let { + val kindName = (it.content.firstOrNull() as? Text)?.textTrim + if (kindName != null) { + try { + KotlinModuleKind.valueOf(kindName) + } catch (e: Exception) { + null + } + } else null + } ?: KotlinModuleKind.DEFAULT element.getChild("compilerSettings")?.let { compilerSettings = CompilerSettings() XmlSerializer.deserializeInto(compilerSettings!!, it) @@ -259,6 +273,16 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) { } ) } + if (sourceSetNames.isNotEmpty()) { + element.addContent( + Element("sourceSets").apply { + sourceSetNames.map { addContent(Element("sourceSet").apply { addContent(it) }) } + } + ) + } + if (kind != KotlinModuleKind.DEFAULT) { + element.addContent(Element("newMppModelJpsModuleKind").apply { addContent(kind.name) }) + } productionOutputPath?.let { if (it != (compilerArguments as? K2JSCompilerArguments)?.outputFile) { element.addContent(Element("productionOutputPath").apply { addContent(PathUtil.toSystemIndependentName(it)) })