[Gradle] Don't convert free compiler arguments to set, avoid args duplication
#KT-55363 Fixed
This commit is contained in:
committed by
Space Team
parent
a5810d88a5
commit
0466fc536d
-3
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle
|
|||||||
import org.gradle.api.logging.LogLevel
|
import org.gradle.api.logging.LogLevel
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.Disabled
|
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import kotlin.io.path.appendText
|
import kotlin.io.path.appendText
|
||||||
|
|
||||||
@@ -62,7 +61,6 @@ internal class CompilerOptionsIT : KGPBaseTest() {
|
|||||||
@DisplayName("compiler plugin arguments set via kotlinOptions.freeCompilerArgs on task execution applied properly")
|
@DisplayName("compiler plugin arguments set via kotlinOptions.freeCompilerArgs on task execution applied properly")
|
||||||
@JvmGradlePluginTests
|
@JvmGradlePluginTests
|
||||||
@GradleTest
|
@GradleTest
|
||||||
@Disabled
|
|
||||||
internal fun freeArgsModifiedAtExecutionTimeCorrectly(gradleVersion: GradleVersion) {
|
internal fun freeArgsModifiedAtExecutionTimeCorrectly(gradleVersion: GradleVersion) {
|
||||||
project("simpleProject", gradleVersion) {
|
project("simpleProject", gradleVersion) {
|
||||||
buildGradle.appendText(
|
buildGradle.appendText(
|
||||||
@@ -95,7 +93,6 @@ internal class CompilerOptionsIT : KGPBaseTest() {
|
|||||||
@DisplayName("compiler plugin arguments set via kotlinOptions.freeCompilerArgs on task execution applied properly in MPP")
|
@DisplayName("compiler plugin arguments set via kotlinOptions.freeCompilerArgs on task execution applied properly in MPP")
|
||||||
@MppGradlePluginTests
|
@MppGradlePluginTests
|
||||||
@GradleTest
|
@GradleTest
|
||||||
@Disabled
|
|
||||||
internal fun freeArgsModifiedAtExecutionTimeCorrectlyMpp(gradleVersion: GradleVersion) {
|
internal fun freeArgsModifiedAtExecutionTimeCorrectlyMpp(gradleVersion: GradleVersion) {
|
||||||
project("new-mpp-lib-with-tests", gradleVersion) {
|
project("new-mpp-lib-with-tests", gradleVersion) {
|
||||||
buildGradle.appendText(
|
buildGradle.appendText(
|
||||||
|
|||||||
+4
-3
@@ -61,7 +61,7 @@ abstract class KotlinCompileCommon @Inject constructor(
|
|||||||
* this input will always be empty.
|
* this input will always be empty.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal var additionalFreeCompilerArgs: List<String> = listOf()
|
internal var executionTimeFreeCompilerArgs: List<String>? = null
|
||||||
|
|
||||||
override fun createCompilerArgs(): K2MetadataCompilerArguments =
|
override fun createCompilerArgs(): K2MetadataCompilerArguments =
|
||||||
K2MetadataCompilerArguments()
|
K2MetadataCompilerArguments()
|
||||||
@@ -90,8 +90,9 @@ abstract class KotlinCompileCommon @Inject constructor(
|
|||||||
|
|
||||||
(compilerOptions as KotlinMultiplatformCommonCompilerOptionsDefault).fillCompilerArguments(args)
|
(compilerOptions as KotlinMultiplatformCommonCompilerOptionsDefault).fillCompilerArguments(args)
|
||||||
|
|
||||||
if (additionalFreeCompilerArgs.isNotEmpty()) {
|
val localExecutionTimeFreeCompilerArgs = executionTimeFreeCompilerArgs
|
||||||
args.freeArgs = compilerOptions.freeCompilerArgs.get().union(additionalFreeCompilerArgs).toList()
|
if (localExecutionTimeFreeCompilerArgs != null) {
|
||||||
|
args.freeArgs = localExecutionTimeFreeCompilerArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-5
@@ -701,7 +701,7 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
* this input will always be empty.
|
* this input will always be empty.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal var additionalFreeCompilerArgs: List<String> = listOf()
|
internal var executionTimeFreeCompilerArgs: List<String>? = null
|
||||||
|
|
||||||
override fun setupCompilerArgs(args: K2JVMCompilerArguments, defaultsOnly: Boolean, ignoreClasspathResolutionErrors: Boolean) {
|
override fun setupCompilerArgs(args: K2JVMCompilerArguments, defaultsOnly: Boolean, ignoreClasspathResolutionErrors: Boolean) {
|
||||||
compilerArgumentsContributor.contributeArguments(
|
compilerArgumentsContributor.contributeArguments(
|
||||||
@@ -715,8 +715,9 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
args.reportPerf = true
|
args.reportPerf = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (additionalFreeCompilerArgs.isNotEmpty()) {
|
val localExecutionTimeFreeCompilerArgs = executionTimeFreeCompilerArgs
|
||||||
args.freeArgs = compilerOptions.freeCompilerArgs.get().union(additionalFreeCompilerArgs).toList()
|
if (localExecutionTimeFreeCompilerArgs != null) {
|
||||||
|
args.freeArgs = localExecutionTimeFreeCompilerArgs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1009,7 +1010,7 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
* this input will always be empty.
|
* this input will always be empty.
|
||||||
*/
|
*/
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal var additionalFreeCompilerArgs: List<String> = listOf()
|
internal var executionTimeFreeCompilerArgs: List<String>? = null
|
||||||
|
|
||||||
override fun createCompilerArgs(): K2JSCompilerArguments =
|
override fun createCompilerArgs(): K2JSCompilerArguments =
|
||||||
K2JSCompilerArguments()
|
K2JSCompilerArguments()
|
||||||
@@ -1039,7 +1040,8 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
|||||||
}
|
}
|
||||||
// Overriding freeArgs from compilerOptions with enhanced one + additional one set on execution phase
|
// Overriding freeArgs from compilerOptions with enhanced one + additional one set on execution phase
|
||||||
// containing additional arguments based on the js compilation configuration
|
// containing additional arguments based on the js compilation configuration
|
||||||
args.freeArgs = enhancedFreeCompilerArgs.get().union(additionalFreeCompilerArgs).toList()
|
val localExecutionTimeFreeCompilerArgs = executionTimeFreeCompilerArgs
|
||||||
|
args.freeArgs = if (localExecutionTimeFreeCompilerArgs != null) localExecutionTimeFreeCompilerArgs else enhancedFreeCompilerArgs.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
@get:InputFiles
|
@get:InputFiles
|
||||||
|
|||||||
+11
-7
@@ -18,17 +18,21 @@ class KotlinJsOptionsCompat(
|
|||||||
override val options: KotlinJsCompilerOptions
|
override val options: KotlinJsCompilerOptions
|
||||||
) : KotlinJsOptions {
|
) : KotlinJsOptions {
|
||||||
override var freeCompilerArgs: List<String>
|
override var freeCompilerArgs: List<String>
|
||||||
get() = if (isTaskExecuting) {
|
get() {
|
||||||
task().enhancedFreeCompilerArgs.get()
|
val executionTimeFreeCompilerArgs = task().executionTimeFreeCompilerArgs
|
||||||
.union(task().additionalFreeCompilerArgs)
|
return if (!isTaskExecuting) {
|
||||||
.toList()
|
options.freeCompilerArgs.get()
|
||||||
} else {
|
} else if (executionTimeFreeCompilerArgs != null) {
|
||||||
options.freeCompilerArgs.get()
|
executionTimeFreeCompilerArgs
|
||||||
|
} else {
|
||||||
|
// returned at execution time before freeCompilerArgs modification
|
||||||
|
task().enhancedFreeCompilerArgs.get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set(value) = if (isTaskExecuting) {
|
set(value) = if (isTaskExecuting) {
|
||||||
task().nagUserFreeArgsModifiedOnExecution(value)
|
task().nagUserFreeArgsModifiedOnExecution(value)
|
||||||
task().additionalFreeCompilerArgs = value
|
task().executionTimeFreeCompilerArgs = value
|
||||||
} else {
|
} else {
|
||||||
options.freeCompilerArgs.set(value)
|
options.freeCompilerArgs.set(value)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-5
@@ -18,15 +18,18 @@ class KotlinJvmOptionsCompat(
|
|||||||
override val options: KotlinJvmCompilerOptions
|
override val options: KotlinJvmCompilerOptions
|
||||||
) : KotlinJvmOptions {
|
) : KotlinJvmOptions {
|
||||||
override var freeCompilerArgs: List<String>
|
override var freeCompilerArgs: List<String>
|
||||||
get() = if (isTaskExecuting) {
|
get() {
|
||||||
options.freeCompilerArgs.get().union(task().additionalFreeCompilerArgs).toList()
|
val executionTimeFreeCompilerArgs = task().executionTimeFreeCompilerArgs
|
||||||
} else {
|
return if (isTaskExecuting && executionTimeFreeCompilerArgs != null) {
|
||||||
options.freeCompilerArgs.get()
|
executionTimeFreeCompilerArgs
|
||||||
|
} else {
|
||||||
|
options.freeCompilerArgs.get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set(value) = if (isTaskExecuting) {
|
set(value) = if (isTaskExecuting) {
|
||||||
task().nagUserFreeArgsModifiedOnExecution(value)
|
task().nagUserFreeArgsModifiedOnExecution(value)
|
||||||
task().additionalFreeCompilerArgs = value
|
task().executionTimeFreeCompilerArgs = value
|
||||||
} else {
|
} else {
|
||||||
options.freeCompilerArgs.set(value)
|
options.freeCompilerArgs.set(value)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-7
@@ -15,17 +15,18 @@ class KotlinMultiplatformCommonOptionsCompat(
|
|||||||
) : KotlinMultiplatformCommonOptions {
|
) : KotlinMultiplatformCommonOptions {
|
||||||
|
|
||||||
override var freeCompilerArgs: List<String>
|
override var freeCompilerArgs: List<String>
|
||||||
get() = if (isTaskExecuting) {
|
get() {
|
||||||
options.freeCompilerArgs.get()
|
val executionTimeFreeCompilerArgs = task().executionTimeFreeCompilerArgs
|
||||||
.union(task().additionalFreeCompilerArgs)
|
return if (isTaskExecuting && executionTimeFreeCompilerArgs != null) {
|
||||||
.toList()
|
executionTimeFreeCompilerArgs
|
||||||
} else {
|
} else {
|
||||||
options.freeCompilerArgs.get()
|
options.freeCompilerArgs.get()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set(value) = if (isTaskExecuting) {
|
set(value) = if (isTaskExecuting) {
|
||||||
task().nagUserFreeArgsModifiedOnExecution(value)
|
task().nagUserFreeArgsModifiedOnExecution(value)
|
||||||
task().additionalFreeCompilerArgs = value
|
task().executionTimeFreeCompilerArgs = value
|
||||||
} else {
|
} else {
|
||||||
options.freeCompilerArgs.set(value)
|
options.freeCompilerArgs.set(value)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user