From 24eae3367d96ced067430956d83d74a1560237d4 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Mon, 3 Apr 2017 17:20:58 +0300 Subject: [PATCH] Kotlin Facet: Convert paths to OS-independent form #KT-17223 Fixed Original commit: 6bf23d5e02855be06d4d620a62f7af1274ac4e56 --- .../kotlin/config/facetSerialization.kt | 40 +++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) 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 eb2b094b2d8..1aab95c697b 100644 --- a/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -16,12 +16,12 @@ package org.jetbrains.kotlin.config +import com.intellij.util.PathUtil import com.intellij.util.xmlb.SkipDefaultsSerializationFilter import com.intellij.util.xmlb.XmlSerializer import org.jdom.DataConversionException import org.jdom.Element -import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments -import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.* fun Element.getOption(name: String) = getChildren("option").firstOrNull { it.getAttribute("name").value == name } @@ -116,6 +116,36 @@ fun deserializeFacetSettings(element: Element): KotlinFacetSettings { } } +fun CommonCompilerArguments.convertPathsToSystemIndependent() { + pluginClasspaths?.forEachIndexed { index, s -> pluginClasspaths[index] = PathUtil.toSystemIndependentName(s) } + + when (this) { + is K2JVMCompilerArguments -> { + destination = PathUtil.toSystemIndependentName(destination) + classpath = PathUtil.toSystemIndependentName(classpath) + jdkHome = PathUtil.toSystemIndependentName(jdkHome) + kotlinHome = PathUtil.toSystemIndependentName(kotlinHome) + friendPaths?.forEachIndexed { index, s -> friendPaths[index] = PathUtil.toSystemIndependentName(s) } + declarationsOutputPath = PathUtil.toSystemIndependentName(declarationsOutputPath) + } + + is K2JSCompilerArguments -> { + outputFile = PathUtil.toSystemIndependentName(outputFile) + libraries = PathUtil.toSystemIndependentName(libraries) + } + + is K2MetadataCompilerArguments -> { + destination = PathUtil.toSystemIndependentName(destination) + classpath = PathUtil.toSystemIndependentName(classpath) + } + } +} + +fun CompilerSettings.convertPathsToSystemIndependent() { + scriptTemplatesClasspath = PathUtil.toSystemIndependentName(scriptTemplatesClasspath) + outputDirectoryForJsLibraryFiles = PathUtil.toSystemIndependentName(outputDirectoryForJsLibraryFiles) +} + fun KotlinFacetSettings.serializeFacetSettings(element: Element) { val filter = SkipDefaultsSerializationFilter() @@ -126,13 +156,15 @@ fun KotlinFacetSettings.serializeFacetSettings(element: Element) { if (!useProjectSettings) { element.setAttribute("useProjectSettings", useProjectSettings.toString()) } - compilerSettings?.let { + compilerSettings?.let { copyBean(it) }?.let { + it.convertPathsToSystemIndependent() Element("compilerSettings").apply { XmlSerializer.serializeInto(it, this, filter) element.addContent(this) } } - compilerArguments?.let { + compilerArguments?.let { copyBean(it) }?.let { + it.convertPathsToSystemIndependent() Element("compilerArguments").apply { XmlSerializer.serializeInto(it, this, filter) element.addContent(this)