diff --git a/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt b/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt index f23f027ad76..154819f541f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt @@ -281,8 +281,12 @@ fun applyCompilerArgumentsToFacet( val defaultCompilerArguments = defaultArguments?.let { copyBean(it) } ?: compilerArguments::class.java.newInstance() defaultCompilerArguments.convertPathsToSystemIndependent() + val oldPluginOptions = compilerArguments.pluginOptions + val emptyArgs = compilerArguments::class.java.newInstance() copyBeanTo(arguments, compilerArguments) { property, value -> value != property.get(emptyArgs) } + compilerArguments.pluginOptions = joinPluginOptions(oldPluginOptions, arguments.pluginOptions) + compilerArguments.convertPathsToSystemIndependent() // Retain only fields exposed (and not explicitly ignored) in facet configuration editor. @@ -321,3 +325,15 @@ fun applyCompilerArgumentsToFacet( updateMergedArguments() } } + +private fun joinPluginOptions(old: Array?, new: Array?): Array? { + if (old == null && new == null) { + return old + } else if (new == null) { + return old + } else if (old == null) { + return new + } + + return (old + new).distinct().toTypedArray() +}