Facet serialization changed in order to keep compatibility with previous

versions of Kotlin plugin
This commit is contained in:
Andrey Uskov
2019-06-27 19:43:03 +03:00
parent 87e75bd4cc
commit 404ce1a8c1
4 changed files with 7 additions and 4 deletions
@@ -25,10 +25,12 @@ fun <T> TargetPlatform?.has(klass: Class<T>): Boolean = this != null && subplatf
* also provides better description for multiplatforms.
*/
val TargetPlatform.oldFashionedDescription: String
get() = if (this.isCommon()) "Common (experimental) " else this.single().oldFashionedDescription
// the invocation if isCommon is not preferable as it could be governed by separate flag and may
// to appear independently on count of target platforms
get() = this.singleOrNull()?.oldFashionedDescription ?: "Common (experimental) "
/**
/**
* Renders multiplatform in form
* '$PLATFORM_1 / $PLATFORM_2 / ...'
* e.g.
@@ -296,6 +296,7 @@ private fun KotlinFacetSettings.writeLatestConfig(element: Element) {
val filter = SkipDefaultsSerializationFilter()
targetPlatform?.let {
element.setAttribute("platform", it.oldFashionedDescription)
element.setAttribute("allPlatforms", it.componentPlatforms.map { it.serializeToString() }.joinToString(separator = "/"))
}
if (!useProjectSettings) {
@@ -2,7 +2,7 @@
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="2" allPlatforms="JVM [1.8]" useProjectSettings="false">
<configuration version="2" platform="JVM 1.8" allPlatforms="JVM [1.8]" useProjectSettings="false">
<compilerSettings>
<option name="additionalArguments" value="-version -Xallow-kotlin-package -Xskip-metadata-version-check" />
</compilerSettings>
@@ -103,7 +103,7 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest()
application.isSaveAllowed = true
application.saveAll()
val moduleFileContentAfter = String(module.moduleFile!!.contentsToByteArray())
Assert.assertEquals(moduleFileContentBefore.replace("platform=\"JVM 1.8\"", "allPlatforms=\"JVM [1.8]\""), moduleFileContentAfter)
Assert.assertEquals(moduleFileContentBefore.replace("platform=\"JVM 1.8\"", "platform=\"JVM 1.8\" allPlatforms=\"JVM [1.8]\""), moduleFileContentAfter)
}
fun testApiVersionWithoutLanguageVersion() {