KotlinFacetSettings: Serialize and deserialize additionalVisibleModuleNames
^KT-55145 Verification Pending
This commit is contained in:
committed by
Space Team
parent
8ffabddf75
commit
0f4e4ac20e
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm")
|
kotlin("jvm")
|
||||||
id("jps-compatible")
|
id("jps-compatible")
|
||||||
@@ -30,6 +29,7 @@ dependencies {
|
|||||||
testImplementation(project(":compiler:cli-common"))
|
testImplementation(project(":compiler:cli-common"))
|
||||||
testImplementation(jpsModelSerialization())
|
testImplementation(jpsModelSerialization())
|
||||||
testImplementation(commonDependency("junit:junit"))
|
testImplementation(commonDependency("junit:junit"))
|
||||||
|
testImplementation(kotlin("test-junit"))
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.load.java.JvmAbi
|
|||||||
import org.jetbrains.kotlin.platform.*
|
import org.jetbrains.kotlin.platform.*
|
||||||
import org.jetbrains.kotlin.platform.impl.FakeK2NativeCompilerArguments
|
import org.jetbrains.kotlin.platform.impl.FakeK2NativeCompilerArguments
|
||||||
import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind
|
import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind
|
||||||
import org.jetbrains.kotlin.platform.isJs
|
|
||||||
import org.jetbrains.kotlin.platform.jvm.JdkPlatform
|
import org.jetbrains.kotlin.platform.jvm.JdkPlatform
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||||
import org.jetbrains.kotlin.platform.jvm.isJvm
|
import org.jetbrains.kotlin.platform.jvm.isJvm
|
||||||
@@ -138,6 +137,7 @@ private fun readV2AndLaterConfig(
|
|||||||
this.targetPlatform = targetPlatform
|
this.targetPlatform = targetPlatform
|
||||||
readElementsList(element, "implements", "implement")?.let { implementedModuleNames = it }
|
readElementsList(element, "implements", "implement")?.let { implementedModuleNames = it }
|
||||||
readElementsList(element, "dependsOnModuleNames", "dependsOn")?.let { dependsOnModuleNames = it }
|
readElementsList(element, "dependsOnModuleNames", "dependsOn")?.let { dependsOnModuleNames = it }
|
||||||
|
readElementsList(element, "additionalVisibleModuleNames", "friend")?.let { additionalVisibleModuleNames = it.toSet() }
|
||||||
element.getChild("externalSystemTestTasks")?.let {
|
element.getChild("externalSystemTestTasks")?.let {
|
||||||
val testRunTasks = it.getChildren("externalSystemTestTask")
|
val testRunTasks = it.getChildren("externalSystemTestTask")
|
||||||
.mapNotNull { (it.content.firstOrNull() as? Text)?.textTrim }
|
.mapNotNull { (it.content.firstOrNull() as? Text)?.textTrim }
|
||||||
@@ -312,6 +312,7 @@ private fun KotlinFacetSettings.writeConfig(element: Element) {
|
|||||||
}
|
}
|
||||||
saveElementsList(element, implementedModuleNames, "implements", "implement")
|
saveElementsList(element, implementedModuleNames, "implements", "implement")
|
||||||
saveElementsList(element, dependsOnModuleNames, "dependsOnModuleNames", "dependsOn")
|
saveElementsList(element, dependsOnModuleNames, "dependsOnModuleNames", "dependsOn")
|
||||||
|
saveElementsList(element, additionalVisibleModuleNames.toList(), "additionalVisibleModuleNames", "friend")
|
||||||
|
|
||||||
if (sourceSetNames.isNotEmpty()) {
|
if (sourceSetNames.isNotEmpty()) {
|
||||||
element.addContent(
|
element.addContent(
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.arguments
|
||||||
|
|
||||||
|
import org.jdom.Element
|
||||||
|
import org.jetbrains.kotlin.config.KotlinFacetSettings
|
||||||
|
import org.jetbrains.kotlin.config.deserializeFacetSettings
|
||||||
|
import org.jetbrains.kotlin.config.serializeFacetSettings
|
||||||
|
import org.junit.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
class FacetSettingsSerializationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - module dependencies`() {
|
||||||
|
val source = KotlinFacetSettings().apply {
|
||||||
|
implementedModuleNames = listOf("implementedModule1", "implementedModule2")
|
||||||
|
dependsOnModuleNames = listOf("dependsOnModule1", "dependsOnModule2")
|
||||||
|
additionalVisibleModuleNames = setOf("friend1", "friend2")
|
||||||
|
}
|
||||||
|
|
||||||
|
val deserialized = serializeAndDeserialize(source)
|
||||||
|
assertEquals(source.implementedModuleNames, deserialized.implementedModuleNames)
|
||||||
|
assertEquals(source.dependsOnModuleNames, deserialized.dependsOnModuleNames)
|
||||||
|
assertEquals(source.additionalVisibleModuleNames, deserialized.additionalVisibleModuleNames)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun serializeAndDeserialize(settings: KotlinFacetSettings): KotlinFacetSettings {
|
||||||
|
val element = Element("settings")
|
||||||
|
settings.serializeFacetSettings(element)
|
||||||
|
return deserializeFacetSettings(element)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user