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 78ae53efb2f..303ac20aedc 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -153,6 +153,18 @@ enum class KotlinMultiplatformVersion(val version: Int) { get() = version >= 3 } +data class ExternalSystemTestTask(val testName: String, val externalSystemProjectId: String, val targetName: String?) { + + fun toStringRepresentation() = "$testName|$externalSystemProjectId|$targetName" + + companion object { + fun fromStringRepresentation(line: String) = + line.split("|").let { if (it.size == 3) ExternalSystemTestTask(it[0], it[1], it[2]) else null } + } + + override fun toString() = "$testName@$externalSystemProjectId [$targetName]" +} + class KotlinFacetSettings { companion object { // Increment this when making serialization-incompatible changes to configuration data @@ -219,6 +231,7 @@ class KotlinFacetSettings { return field } + var externalSystemTestTasks: List = emptyList() @Suppress("DEPRECATION_ERROR") @Deprecated( 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 436b626f6bd..0a533b69d7a 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -136,8 +136,11 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings { element.getAttributeValue("useProjectSettings")?.let { useProjectSettings = it.toBoolean() } val targetPlatform = element.getFacetPlatformByConfigurationElement() this.targetPlatform = targetPlatform - readModulesList(element, "implements", "implement")?.let { implementedModuleNames = it } - readModulesList(element, "dependsOnModuleNames", "dependsOn")?.let { dependsOnModuleNames = it } + readElementsList(element, "implements", "implement")?.let { implementedModuleNames = it } + readElementsList(element, "dependsOnModuleNames", "dependsOn")?.let { dependsOnModuleNames = it } + readElementsList(element, "externalSystemTestTasks", "externalSystemTestTask")?.let { + externalSystemTestTasks = it.mapNotNull { ExternalSystemTestTask.fromStringRepresentation(it) } + } element.getChild("sourceSets")?.let { val items = it.getChildren("sourceSet") @@ -178,7 +181,7 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings { } } -private fun readModulesList(element: Element, rootElementName: String, elementName: String): List? { +private fun readElementsList(element: Element, rootElementName: String, elementName: String): List? { element.getChild(rootElementName)?.let { val items = it.getChildren(elementName) return if (items.isNotEmpty()) { @@ -310,8 +313,8 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) { if (!useProjectSettings) { element.setAttribute("useProjectSettings", useProjectSettings.toString()) } - saveModulesList(element, implementedModuleNames, "implements", "implement") - saveModulesList(element, dependsOnModuleNames, "dependsOnModuleNames", "dependsOn") + saveElementsList(element, implementedModuleNames, "implements", "implement") + saveElementsList(element, dependsOnModuleNames, "dependsOnModuleNames", "dependsOn") if (sourceSetNames.isNotEmpty()) { element.addContent( @@ -330,6 +333,14 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) { if (isHmppEnabled) { element.setAttribute("isHmppProject", isHmppEnabled.toString()) } + if (externalSystemTestTasks.isNotEmpty()) { + saveElementsList( + element, + externalSystemTestTasks.map { it.toStringRepresentation() }, + "externalSystemTestTasks", + "externalSystemTestTask" + ) + } if (pureKotlinSourceFolders.isNotEmpty()) { element.setAttribute("pureKotlinSourceFolders", pureKotlinSourceFolders.joinToString(";")) } @@ -354,15 +365,15 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) { } } -private fun saveModulesList(element: Element, moduleList: List, rootElementName: String, elementName: String) { - if (moduleList.isNotEmpty()) { +private fun saveElementsList(element: Element, elementsList: List, rootElementName: String, elementName: String) { + if (elementsList.isNotEmpty()) { element.addContent( Element(rootElementName).apply { - val singleModule = moduleList.singleOrNull() + val singleModule = elementsList.singleOrNull() if (singleModule != null) { addContent(singleModule) } else { - moduleList.map { addContent(Element(elementName).apply { addContent(it) }) } + elementsList.map { addContent(Element(elementName).apply { addContent(it) }) } } } )