Fix -Xmulti-platform dropped from args when freeCompilerArgs is assigned

in user build script

Issue #KT-15371 Fixed
This commit is contained in:
Sergey Igushkin
2018-02-16 15:11:40 +03:00
parent 37b34cff25
commit 3836dcab85
4 changed files with 21 additions and 4 deletions
@@ -465,6 +465,9 @@ abstract class BaseGradleIT {
private fun Project.createBuildCommand(wrapperDir: File, params: Array<out String>, options: BuildOptions): List<String> =
createGradleCommand(wrapperDir, createGradleTailParameters(options, params))
fun Project.gradleBuildScript(subproject: String? = null): File =
File(projectDir, subproject?.plus("/").orEmpty() + "build.gradle")
private fun Project.createGradleTailParameters(options: BuildOptions, params: Array<out String> = arrayOf()): List<String> =
params.toMutableList().apply {
add("--stacktrace")
@@ -185,4 +185,20 @@ class MultiplatformGradleIT : BaseGradleIT() {
}
}
}
@Test
fun testFreeCompilerArgsAssignment(): Unit = with(Project("multiplatformProject")) {
setupWorkingDir()
val overrideCompilerArgs = "kotlinOptions.freeCompilerArgs = ['-verbose']"
gradleBuildScript("lib").appendText("\ncompileKotlinCommon.$overrideCompilerArgs")
gradleBuildScript("libJvm").appendText("\ncompileKotlin.$overrideCompilerArgs")
gradleBuildScript("libJs").appendText("\ncompileKotlin2Js.$overrideCompilerArgs")
build("build") {
assertSuccessful()
assertTasksExecuted(listOf(":lib:compileKotlinCommon", ":libJvm:compileKotlin", ":libJs:compileKotlin2Js"))
}
}
}
@@ -54,10 +54,6 @@ open class KotlinPlatformImplementationPluginBase(platformName: String) : Kotlin
private val platformKotlinTasksBySourceSetName = hashMapOf<String, AbstractKotlinCompile<*>>()
override fun apply(project: Project) {
project.tasks.withType(AbstractKotlinCompile::class.java).all {
(it as KotlinCompile<*>).kotlinOptions.freeCompilerArgs += listOf("-Xmulti-platform")
}
project.tasks.filterIsInstance<AbstractKotlinCompile<*>>().associateByTo(platformKotlinTasksBySourceSetName) { it.sourceSetName }
val implementConfig = project.configurations.create(IMPLEMENT_CONFIG_NAME)
@@ -233,6 +233,8 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
args.verbose = true
}
args.multiPlatform = project.plugins.any { it is KotlinPlatformPluginBase }
setupPlugins(args)
}