Pass freeCompilerArgs unchanged to the compiler, without parsing them

with the compiler loaded along the Gradle plugin.

Issues: #KT-17618 Fixed

(cherry picked from commit 44f7428)
This commit is contained in:
Sergey Igushkin
2017-05-19 14:16:47 +03:00
committed by Sergey Igushkin
parent 88968807b2
commit ae47c59dc9
4 changed files with 9 additions and 14 deletions
@@ -405,9 +405,9 @@ class KotlinGradleIT: BaseGradleIT() {
val project = Project("kotlinProject", GRADLE_VERSION)
project.setupWorkingDir()
val customModuleName = "custom_module_name"
File(project.projectDir, "build.gradle").modify {
// lazy eval is important
val customModuleName = "\${project.name}"
it + """
compileKotlin {
kotlinOptions.freeCompilerArgs = [ "-module-name", "$customModuleName" ]
@@ -416,6 +416,7 @@ class KotlinGradleIT: BaseGradleIT() {
project.build("build") {
assertSuccessful()
assertFileExists("build/classes/main/META-INF/$customModuleName.kotlin_module")
}
}
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.gradle.dsl
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.js.K2JSCompiler
internal class KotlinJsOptionsImpl : KotlinJsOptionsBase() {
override var freeCompilerArgs: List<String> = listOf()
@@ -25,7 +24,7 @@ internal class KotlinJsOptionsImpl : KotlinJsOptionsBase() {
override fun updateArguments(args: K2JSCompilerArguments) {
super.updateArguments(args)
// cast to List<Any> is important because in Groovy a GString can be inside of a list
val freeArgsArray = (freeCompilerArgs as List<Any>).map(Any::toString).toTypedArray()
K2JSCompiler().parseArguments(freeArgsArray, args)
val freeArgs = (freeCompilerArgs as List<Any>).map(Any::toString)
args.freeArgs.addAll(freeArgs)
}
}
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.gradle.dsl
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
internal class KotlinJvmOptionsImpl : KotlinJvmOptionsBase() {
override var freeCompilerArgs: List<String> = listOf()
@@ -25,7 +24,7 @@ internal class KotlinJvmOptionsImpl : KotlinJvmOptionsBase() {
override fun updateArguments(args: K2JVMCompilerArguments) {
super.updateArguments(args)
// cast to List<Any> is important because in Groovy a GString can be inside of a list
val freeArgsArray = (freeCompilerArgs as List<Any>).map(Any::toString).toTypedArray()
K2JVMCompiler().parseArguments(freeArgsArray, args)
val freeArgs = (freeCompilerArgs as List<Any>).map(Any::toString)
args.freeArgs.addAll(freeArgs)
}
}
@@ -1,7 +1,7 @@
package org.jetbrains.kotlin.gradle.dsl
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.junit.Assert.*
import org.junit.Assert.assertEquals
import org.junit.Test
class KotlinJvmOptionsTest {
@@ -17,10 +17,6 @@ class KotlinJvmOptionsTest {
val arguments = K2JVMCompilerArguments()
options.updateArguments(arguments)
assertEquals("reportPerf", true, arguments.reportPerf)
assertEquals("allowKotlinPackage", true, arguments.allowKotlinPackage)
assertEquals("inheritMultifileParts", true, arguments.inheritMultifileParts)
assertEquals("declarationsOutputPath", "declarationsPath", arguments.declarationsOutputPath)
assertArrayEquals("scriptTemplates", arrayOf("a", "b", "c"), arguments.scriptTemplates)
assertEquals(options.freeCompilerArgs, arguments.freeArgs)
}
}