NoArg: Parse 'invokeInitializers' option in Maven importer (KT-19900)
This commit is contained in:
@@ -1476,6 +1476,77 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
fun testNoArgInvokeInitializers() {
|
||||
createProjectSubDirs("src/main/kotlin", "src/main/kotlin.jvm", "src/test/kotlin", "src/test/kotlin.jvm")
|
||||
|
||||
importProject("""
|
||||
<groupId>test</groupId>
|
||||
<artifactId>project</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>$kotlinVersion</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<goals>
|
||||
<goal>js</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-noarg</artifactId>
|
||||
<version>$kotlinVersion</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<configuration>
|
||||
<compilerPlugins>
|
||||
<plugin>no-arg</plugin>
|
||||
</compilerPlugins>
|
||||
|
||||
<pluginOptions>
|
||||
<option>no-arg:annotation=NoArg</option>
|
||||
<option>no-arg:invokeInitializers=true</option>
|
||||
</pluginOptions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
""")
|
||||
|
||||
assertModules("project")
|
||||
assertImporterStatePresent()
|
||||
|
||||
with(facetSettings) {
|
||||
Assert.assertEquals(
|
||||
"-version",
|
||||
compilerSettings!!.additionalArguments
|
||||
)
|
||||
Assert.assertEquals(
|
||||
listOf("plugin:org.jetbrains.kotlin.noarg:annotation=NoArg",
|
||||
"plugin:org.jetbrains.kotlin.noarg:invokeInitializers=true"),
|
||||
compilerArguments!!.pluginOptions!!.toList()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun testArgsOverridingInFacet() {
|
||||
createProjectSubDirs("src/main/kotlin", "src/main/kotlin.jvm", "src/test/kotlin", "src/test/kotlin.jvm")
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.utils.PathUtil
|
||||
class NoArgMavenProjectImportHandler : AbstractMavenImportHandler() {
|
||||
private companion object {
|
||||
val ANNOTATATION_PARAMETER_PREFIX = "no-arg:${NoArgCommandLineProcessor.ANNOTATION_OPTION.name}="
|
||||
val INVOKEINITIALIZERS_PARAMETER_PREFIX = "no-arg:${NoArgCommandLineProcessor.INVOKE_INITIALIZERS_OPTION.name}="
|
||||
}
|
||||
|
||||
override val compilerPluginId = NoArgCommandLineProcessor.PLUGIN_ID
|
||||
@@ -48,6 +49,16 @@ class NoArgMavenProjectImportHandler : AbstractMavenImportHandler() {
|
||||
text.substring(ANNOTATATION_PARAMETER_PREFIX.length)
|
||||
})
|
||||
|
||||
return annotations.mapTo(mutableListOf()) { PluginOption(NoArgCommandLineProcessor.ANNOTATION_OPTION.name, it) }
|
||||
val options = annotations.mapTo(mutableListOf()) { PluginOption(NoArgCommandLineProcessor.ANNOTATION_OPTION.name, it) }
|
||||
|
||||
val invokeInitializerOptionValue = compilerPluginOptions
|
||||
.firstOrNull { it.startsWith(INVOKEINITIALIZERS_PARAMETER_PREFIX) }
|
||||
?.drop(INVOKEINITIALIZERS_PARAMETER_PREFIX.length) == "true"
|
||||
|
||||
if (invokeInitializerOptionValue) {
|
||||
options.add(PluginOption(NoArgCommandLineProcessor.INVOKE_INITIALIZERS_OPTION.name, "true"))
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user