Skip to content

Commit 387c91f

Browse files
committed
Kotlin Facet: Do not concat "additional argument" string as configuration gets duplicated
KT-16548 Fixed
1 parent 6608e97 commit 387c91f

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

idea/idea-maven/src/org/jetbrains/kotlin/idea/maven/KotlinMavenImporter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
158158
?.configurationElement?.let { getCompilerArgumentsByConfigurationElement(it, configuredPlatform) }
159159
parseCompilerArgumentsToFacet(sharedArguments, emptyList(), kotlinFacet)
160160
if (executionArguments != null) {
161-
parseCompilerArgumentsToFacet(executionArguments, emptyList(), kotlinFacet, true)
161+
parseCompilerArgumentsToFacet(executionArguments, emptyList(), kotlinFacet)
162162
}
163163
MavenProjectImportHandler.getInstances(module.project).forEach { it(kotlinFacet, mavenProject) }
164164
}

idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
588588
Assert.assertEquals("enable", compilerInfo.coroutineSupport.compilerArgument)
589589
Assert.assertEquals("JVM 1.8", versionInfo.targetPlatformKind!!.description)
590590
Assert.assertEquals("1.8", compilerInfo.k2jvmCompilerArguments!!.jvmTarget)
591-
Assert.assertEquals("-version -cp foobar.jar -jdk-home JDK_HOME -Xmulti-platform",
591+
Assert.assertEquals("-cp foobar.jar -jdk-home JDK_HOME -Xmulti-platform",
592592
compilerInfo.compilerSettings!!.additionalArguments)
593593
}
594594
}

idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,7 @@ private val CommonCompilerArguments.exposedFields: List<String>
156156
else -> commonExposedFields
157157
}
158158

159-
fun parseCompilerArgumentsToFacet(
160-
arguments: List<String>,
161-
defaultArguments: List<String>,
162-
kotlinFacet: KotlinFacet,
163-
appendAdditionalArguments: Boolean = false
164-
) {
159+
fun parseCompilerArgumentsToFacet(arguments: List<String>, defaultArguments: List<String>, kotlinFacet: KotlinFacet) {
165160
val argumentArray = arguments.toTypedArray()
166161

167162
with(kotlinFacet.configuration.settings) {
@@ -216,14 +211,8 @@ fun parseCompilerArgumentsToFacet(
216211
copyFieldsSatisfying(compilerArguments, this, ::exposeAsAdditionalArgument)
217212
ArgumentUtils.convertArgumentsToStringList(this).joinToString(separator = " ")
218213
}
219-
220-
val newAdditionalArguments = if (additionalArgumentsString.isNotEmpty()) additionalArgumentsString else CompilerSettings.DEFAULT_ADDITIONAL_ARGUMENTS
221-
if (appendAdditionalArguments) {
222-
compilerInfo.compilerSettings!!.additionalArguments += " $newAdditionalArguments"
223-
}
224-
else {
225-
compilerInfo.compilerSettings!!.additionalArguments = newAdditionalArguments
226-
}
214+
compilerInfo.compilerSettings!!.additionalArguments =
215+
if (additionalArgumentsString.isNotEmpty()) additionalArgumentsString else CompilerSettings.DEFAULT_ADDITIONAL_ARGUMENTS
227216

228217
with(compilerArguments.javaClass.newInstance()) {
229218
copyFieldsSatisfying(this, compilerArguments, ::exposeAsAdditionalArgument)

0 commit comments

Comments
 (0)