[Gradle] Move from constructor KotlinNativeLink task configuration
This should fix ConcurrentModificationException on getting task names while loading import models in parallel. ^KT-63554 Fixed
This commit is contained in:
committed by
Space Team
parent
df2dcccbf7
commit
71a0dacf81
+22
-10
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
|
|||||||
import org.jetbrains.kotlin.gradle.tasks.dependsOn
|
import org.jetbrains.kotlin.gradle.tasks.dependsOn
|
||||||
import org.jetbrains.kotlin.gradle.tasks.locateOrRegisterTask
|
import org.jetbrains.kotlin.gradle.tasks.locateOrRegisterTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||||
|
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||||
|
|
||||||
internal val KotlinNativeConfigureBinariesSideEffect = KotlinTargetSideEffect<KotlinNativeTarget> { target ->
|
internal val KotlinNativeConfigureBinariesSideEffect = KotlinTargetSideEffect<KotlinNativeTarget> { target ->
|
||||||
val project = target.project
|
val project = target.project
|
||||||
@@ -79,17 +80,28 @@ private fun Project.createLinkTask(binary: NativeBinary) {
|
|||||||
val xcodeVersionTask = XcodeVersionTask.locateOrRegister(project)
|
val xcodeVersionTask = XcodeVersionTask.locateOrRegister(project)
|
||||||
val linkTask = registerTask<KotlinNativeLink>(
|
val linkTask = registerTask<KotlinNativeLink>(
|
||||||
binary.linkTaskName, listOf(binary)
|
binary.linkTaskName, listOf(binary)
|
||||||
) {
|
) { task ->
|
||||||
val target = binary.target
|
val target = binary.target
|
||||||
it.group = BasePlugin.BUILD_GROUP
|
val compilation = binary.compilation
|
||||||
it.description = "Links ${binary.outputKind.description} '${binary.name}' for a target '${target.name}'."
|
task.group = BasePlugin.BUILD_GROUP
|
||||||
it.enabled = binary.konanTarget.enabledOnCurrentHost
|
task.description = "Links ${binary.outputKind.description} '${binary.name}' for a target '${target.name}'."
|
||||||
it.konanPropertiesService.set(konanPropertiesBuildService)
|
task.dependsOn(compilation.compileTaskProvider)
|
||||||
it.usesService(konanPropertiesBuildService)
|
|
||||||
it.toolOptions.freeCompilerArgs.value(compilationCompilerOptions.options.freeCompilerArgs)
|
task.enabled = binary.konanTarget.enabledOnCurrentHost
|
||||||
it.toolOptions.freeCompilerArgs.addAll(providers.provider { PropertiesProvider(project).nativeLinkArgs })
|
task.konanPropertiesService.set(konanPropertiesBuildService)
|
||||||
it.runViaBuildToolsApi.value(false).disallowChanges() // K/N is not yet supported
|
task.usesService(konanPropertiesBuildService)
|
||||||
it.xcodeVersion.set(xcodeVersionTask.version)
|
task.toolOptions.freeCompilerArgs.value(compilationCompilerOptions.options.freeCompilerArgs)
|
||||||
|
task.toolOptions.freeCompilerArgs.addAll(providers.provider { PropertiesProvider(project).nativeLinkArgs })
|
||||||
|
task.runViaBuildToolsApi.value(false).disallowChanges() // K/N is not yet supported
|
||||||
|
task.xcodeVersion.set(xcodeVersionTask.version)
|
||||||
|
|
||||||
|
// Frameworks actively uses symlinks.
|
||||||
|
// Gradle build cache transforms symlinks into regular files https://guides.gradle.org/using-build-cache/#symbolic_links
|
||||||
|
task.outputs.cacheIf { task.outputKind != CompilerOutputKind.FRAMEWORK }
|
||||||
|
|
||||||
|
task.setSource(compilation.compileTaskProvider.flatMap { it.outputFile })
|
||||||
|
task.includes.clear() // we need to include non '.kt' or '.kts' files
|
||||||
|
task.disallowSourceChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
-13
@@ -73,19 +73,6 @@ constructor(
|
|||||||
final override val toolOptions: KotlinCommonCompilerToolOptions = objectFactory
|
final override val toolOptions: KotlinCommonCompilerToolOptions = objectFactory
|
||||||
.newInstance<KotlinCommonCompilerToolOptionsDefault>()
|
.newInstance<KotlinCommonCompilerToolOptionsDefault>()
|
||||||
|
|
||||||
init {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
this.dependsOn(compilation.compileTaskProvider)
|
|
||||||
// Frameworks actively uses symlinks.
|
|
||||||
// Gradle build cache transforms symlinks into regular files https://guides.gradle.org/using-build-cache/#symbolic_links
|
|
||||||
outputs.cacheIf { outputKind != CompilerOutputKind.FRAMEWORK }
|
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
this.setSource(compilation.compileTaskProvider.map { it.outputFile })
|
|
||||||
includes.clear() // we need to include non '.kt' or '.kts' files
|
|
||||||
disallowSourceChanges()
|
|
||||||
}
|
|
||||||
|
|
||||||
override val destinationDirectory: DirectoryProperty = binary.outputDirectoryProperty
|
override val destinationDirectory: DirectoryProperty = binary.outputDirectoryProperty
|
||||||
|
|
||||||
@get:Classpath
|
@get:Classpath
|
||||||
|
|||||||
Reference in New Issue
Block a user