Fix -Xmulti-platform dropped from args when freeCompilerArgs is assigned
in user build script Issue #KT-15371 Fixed
This commit is contained in:
+3
@@ -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")
|
||||
|
||||
+16
@@ -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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
-4
@@ -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)
|
||||
|
||||
+2
@@ -233,6 +233,8 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
||||
args.verbose = true
|
||||
}
|
||||
|
||||
args.multiPlatform = project.plugins.any { it is KotlinPlatformPluginBase }
|
||||
|
||||
setupPlugins(args)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user