Kotlin Facet: Do not concat "additional argument" string as configuration gets duplicated

KT-16548 Fixed
This commit is contained in:
Alexey Sedunov
2017-02-28 16:05:59 +03:00
parent 6608e97d35
commit 387c91f957
3 changed files with 5 additions and 16 deletions
@@ -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) }
}
@@ -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)
}
}
@@ -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) {
@@ -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)