Fix KT-36804 by eagerly instantiating the Kotlin/Native tasks
This commit partially reverts 970ee4539b.
The Kotlin/Native klib compilation task configuration logic involved
adding dependencies for the compiler plugin artifacts. However, the
compiler plugins classpath, shared across all of the K/N tasks, was
tracked as the tasks' input. This made the following scenario possible:
1. Configuration of some of the Kotlin/Native tasks is avoided at the
evaluation phase;
2. During task graph construction, one of the tasks are evaluated, and
to determine their dependencies, Gradle resolves their inputs,
including the compiler plugins classpath mentioned above;
3. Another K/N task is evaluated afterwards, and the configuration logic
attempts to add a dependency into the compiler plugin classpath
configuration, which has already been resolved in (2).
The build fails.
Fix this by cancelling task configuration avoidance for the K/N tasks.
Issue #KT-36804 Fixed
This commit is contained in:
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.gradle.plugin.*
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.*
|
import org.jetbrains.kotlin.gradle.plugin.sources.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService
|
import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
import org.jetbrains.kotlin.gradle.tasks.*
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider
|
import org.jetbrains.kotlin.gradle.tasks.KotlinTasksProvider
|
||||||
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
||||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||||
@@ -127,7 +127,7 @@ class KotlinMetadataTargetConfigurator(kotlinPluginVersion: String) :
|
|||||||
override val kotlinTask: TaskProvider<out KotlinNativeCompile> =
|
override val kotlinTask: TaskProvider<out KotlinNativeCompile> =
|
||||||
with(nativeTargetConfigurator) {
|
with(nativeTargetConfigurator) {
|
||||||
project.createKlibCompilationTask(kotlinCompilation)
|
project.createKlibCompilationTask(kotlinCompilation)
|
||||||
}
|
}.thisTaskProvider
|
||||||
|
|
||||||
override fun run() = Unit
|
override fun run() = Unit
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -149,11 +149,11 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Project.createKlibCompilationTask(compilation: AbstractKotlinNativeCompilation): TaskProvider<out KotlinNativeCompile> {
|
internal fun Project.createKlibCompilationTask(compilation: AbstractKotlinNativeCompilation): KotlinNativeCompile {
|
||||||
val compileTask = project.registerTask<KotlinNativeCompile>(
|
val compileTask = project.tasks.create(
|
||||||
compilation.compileKotlinTaskName,
|
compilation.compileKotlinTaskName,
|
||||||
KotlinNativeCompile::class.java
|
KotlinNativeCompile::class.java
|
||||||
) { task ->
|
).also { task ->
|
||||||
task.compilation = compilation
|
task.compilation = compilation
|
||||||
task.group = BasePlugin.BUILD_GROUP
|
task.group = BasePlugin.BUILD_GROUP
|
||||||
task.description = "Compiles a klibrary from the '${compilation.name}' " +
|
task.description = "Compiles a klibrary from the '${compilation.name}' " +
|
||||||
@@ -178,7 +178,7 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget>(
|
|||||||
project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).apply {
|
project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).apply {
|
||||||
dependsOn(compileTask)
|
dependsOn(compileTask)
|
||||||
}
|
}
|
||||||
createRegularKlibArtifact(compilation, compileTask.get() /*TODO don't instantiate the task eagerly*/)
|
createRegularKlibArtifact(compilation, compileTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
return compileTask
|
return compileTask
|
||||||
|
|||||||
Reference in New Issue
Block a user