diff --git a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt
index 2421e2ceeef..540c54048c8 100644
--- a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt
+++ b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt
@@ -1218,6 +1218,74 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
Assert.assertEquals(TargetPlatformKind.Common, facetSettings.targetPlatformKind)
}
+ fun testNoPluginsInAdditionalArgs() {
+ createProjectSubDirs("src/main/kotlin", "src/main/kotlin.jvm", "src/test/kotlin", "src/test/kotlin.jvm")
+
+ importProject("""
+ test
+ project
+ 1.0.0
+
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ 1.1.0
+
+
+
+
+ src/main/kotlin
+
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+
+
+ compile
+
+ js
+
+
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-allopen
+ 1.1.0
+
+
+
+
+
+ spring
+
+
+
+
+
+ """)
+
+ assertModules("project")
+ assertImporterStatePresent()
+
+ with(facetSettings) {
+ Assert.assertEquals(
+ "-version",
+ compilerSettings!!.additionalArguments
+ )
+ Assert.assertEquals(
+ listOf("plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.stereotype.Component",
+ "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.transaction.annotation.Transactional",
+ "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.scheduling.annotation.Async",
+ "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.cache.annotation.Cacheable"),
+ compilerArguments!!.pluginOptions.toList()
+ )
+ }
+ }
+
private fun assertImporterStatePresent() {
assertNotNull("Kotlin importer component is not present", myTestFixture.module.getComponent(KotlinImporterComponent::class.java))
}
diff --git a/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt b/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt
index bf9cdeb4636..da72959364c 100644
--- a/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/facet/facetUtils.kt
@@ -131,26 +131,29 @@ fun KotlinFacet.configureFacet(
}
}
+// "Primary" fields are written to argument beans directly and thus not presented in the "additional arguments" string
// Update these lists when facet/project settings UI changes
-private val commonExposedFields = listOf("languageVersion",
+private val commonPrimaryFields = listOf("languageVersion",
"apiVersion",
"suppressWarnings",
"coroutinesEnable",
"coroutinesWarn",
- "coroutinesError")
-private val jvmExposedFields = commonExposedFields +
+ "coroutinesError",
+ "pluginClasspaths",
+ "pluginOptions")
+private val jvmPrimaryFields = commonPrimaryFields +
listOf("jvmTarget")
-private val jsExposedFields = commonExposedFields +
+private val jsPrimaryFields = commonPrimaryFields +
listOf("sourceMap",
"outputPrefix",
"outputPostfix",
"moduleKind")
-private val CommonCompilerArguments.exposedFields: List
+private val CommonCompilerArguments.primaryFields: List
get() = when (this) {
- is K2JVMCompilerArguments -> jvmExposedFields
- is K2JSCompilerArguments -> jsExposedFields
- else -> commonExposedFields
+ is K2JVMCompilerArguments -> jvmPrimaryFields
+ is K2JSCompilerArguments -> jsPrimaryFields
+ else -> commonPrimaryFields
}
fun parseCompilerArgumentsToFacet(arguments: List, defaultArguments: List, kotlinFacet: KotlinFacet) {
@@ -175,9 +178,9 @@ fun parseCompilerArgumentsToFacet(arguments: List, defaultArguments: Lis
// Retain only fields exposed in facet configuration editor.
// The rest is combined into string and stored in CompilerSettings.additionalArguments
- val exposedFields = compilerArguments.exposedFields
+ val primaryFields = compilerArguments.primaryFields
- fun exposeAsAdditionalArgument(field: Field) = field.name !in exposedFields && field.get(compilerArguments) != field.get(defaultCompilerArguments)
+ fun exposeAsAdditionalArgument(field: Field) = field.name !in primaryFields && field.get(compilerArguments) != field.get(defaultCompilerArguments)
val additionalArgumentsString = with(compilerArguments.javaClass.newInstance()) {
copyFieldsSatisfying(compilerArguments, this, ::exposeAsAdditionalArgument)
diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt
index a2b5524f9d8..a15f668d5a7 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt
+++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt
@@ -603,4 +603,44 @@ class GradleFacetImportTest : GradleImportingTestCase() {
)
}
}
+
+ @Test
+ fun testNoPluginsInAdditionalArgs() {
+ createProjectSubFile("build.gradle", """
+ group 'Again'
+ version '1.0-SNAPSHOT'
+
+ buildscript {
+ repositories {
+ mavenCentral()
+ maven {
+ url 'http://dl.bintray.com/kotlin/kotlin-eap-1.1'
+ }
+ }
+
+ dependencies {
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.0")
+ classpath("org.jetbrains.kotlin:kotlin-allopen:1.1.0")
+ }
+ }
+
+ apply plugin: 'kotlin'
+ apply plugin: "kotlin-spring"
+ """)
+ importProject()
+
+ with (facetSettings) {
+ Assert.assertEquals(
+ "-version",
+ compilerSettings!!.additionalArguments
+ )
+ Assert.assertEquals(
+ listOf("plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.stereotype.Component",
+ "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.transaction.annotation.Transactional",
+ "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.scheduling.annotation.Async",
+ "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.cache.annotation.Cacheable"),
+ compilerArguments!!.pluginOptions.toList()
+ )
+ }
+ }
}