Skip to content

Commit

Permalink
Kotlin Facet: Do not concat "additional argument" string as configura…
Browse files Browse the repository at this point in the history
…tion gets duplicated

 KT-16548 Fixed

(cherry picked from commit 387c91f)
  • Loading branch information
asedunov committed Feb 28, 2017
1 parent 4d76cc1 commit 34aa29f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
?.configurationElement?.let { getCompilerArgumentsByConfigurationElement(it, configuredPlatform) }
parseCompilerArgumentsToFacet(sharedArguments, emptyList(), kotlinFacet)
if (executionArguments != null) {
parseCompilerArgumentsToFacet(executionArguments, emptyList(), kotlinFacet, true)
parseCompilerArgumentsToFacet(executionArguments, emptyList(), kotlinFacet)
}
MavenProjectImportHandler.getInstances(module.project).forEach { it(kotlinFacet, mavenProject) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertEquals("enable", compilerInfo.coroutineSupport.compilerArgument)
Assert.assertEquals("JVM 1.8", versionInfo.targetPlatformKind!!.description)
Assert.assertEquals("1.8", compilerInfo.k2jvmCompilerArguments!!.jvmTarget)
Assert.assertEquals("-version -cp foobar.jar -jdk-home JDK_HOME -Xmulti-platform",
Assert.assertEquals("-cp foobar.jar -jdk-home JDK_HOME -Xmulti-platform",
compilerInfo.compilerSettings!!.additionalArguments)
}
}
Expand Down
17 changes: 3 additions & 14 deletions idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,7 @@ private val CommonCompilerArguments.exposedFields: List<String>
else -> commonExposedFields
}

fun parseCompilerArgumentsToFacet(
arguments: List<String>,
defaultArguments: List<String>,
kotlinFacet: KotlinFacet,
appendAdditionalArguments: Boolean = false
) {
fun parseCompilerArgumentsToFacet(arguments: List<String>, defaultArguments: List<String>, kotlinFacet: KotlinFacet) {
val argumentArray = arguments.toTypedArray()

with(kotlinFacet.configuration.settings) {
Expand Down Expand Up @@ -216,14 +211,8 @@ fun parseCompilerArgumentsToFacet(
copyFieldsSatisfying(compilerArguments, this, ::exposeAsAdditionalArgument)
ArgumentUtils.convertArgumentsToStringList(this).joinToString(separator = " ")
}

val newAdditionalArguments = if (additionalArgumentsString.isNotEmpty()) additionalArgumentsString else CompilerSettings.DEFAULT_ADDITIONAL_ARGUMENTS
if (appendAdditionalArguments) {
compilerInfo.compilerSettings!!.additionalArguments += " $newAdditionalArguments"
}
else {
compilerInfo.compilerSettings!!.additionalArguments = newAdditionalArguments
}
compilerInfo.compilerSettings!!.additionalArguments =
if (additionalArgumentsString.isNotEmpty()) additionalArgumentsString else CompilerSettings.DEFAULT_ADDITIONAL_ARGUMENTS

with(compilerArguments.javaClass.newInstance()) {
copyFieldsSatisfying(this, compilerArguments, ::exposeAsAdditionalArgument)
Expand Down

0 comments on commit 34aa29f

Please sign in to comment.