[Gradle, K/N] Use TCA-compliant API in KotlinNativeTargetConfigurator

#KT-47768 Fixed
This commit is contained in:
Alexander Likhachev
2021-11-19 18:10:53 +03:00
committed by Space
parent eba6a4a000
commit 5802ab1342
2 changed files with 15 additions and 8 deletions
@@ -69,7 +69,7 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget> : AbstractKotl
if (binary !is TestExecutable) {
tasks.named(binary.compilation.target.artifactsTaskName).configure { it.dependsOn(result) }
tasks.maybeCreate(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(result)
locateOrRegisterTask<Task>(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).configure { it.dependsOn(result) }
}
if (binary is Framework) {
@@ -438,17 +438,19 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget> : AbstractKotl
compilation.output.classesDirs.from(compileTaskProvider.flatMap { it.outputFile })
project.project.tasks.getByName(compilation.compileAllTaskName).dependsOn(compileTaskProvider)
project.project.tasks.named(compilation.compileAllTaskName).configure {
it.dependsOn(compileTaskProvider)
}
if (compilation.isMainCompilationData()) {
if (compilation is KotlinNativeCompilation) {
project.project.tasks.getByName(compilation.target.artifactsTaskName).apply {
dependsOn(compileTaskProvider)
project.project.tasks.named(compilation.target.artifactsTaskName).configure {
it.dependsOn(compileTaskProvider)
}
}
project.project.tasks.getByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).apply {
dependsOn(compileTaskProvider)
project.project.tasks.named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).configure {
it.dependsOn(compileTaskProvider)
}
}
val shouldAddCompileOutputsToElements = compilation.owner is KotlinGradleVariant || compilation.isMainCompilationData()
@@ -131,7 +131,9 @@ class Executable constructor(
get() = super.baseName
set(value) {
super.baseName = value
runTask?.executable = outputFile.absolutePath
runTaskProvider?.configure {
it.executable = outputFile.absolutePath
}
}
var entryPoint: String? = null
@@ -155,8 +157,11 @@ class Executable constructor(
* A task running this executable.
* Returns null if the executables's target is not a host one (macosX64, linuxX64 or mingw64).
*/
val runTaskProvider: TaskProvider<AbstractExecTask<*>>?
get() = runTaskName?.let { project.tasks.withType(AbstractExecTask::class.java).named(it) }
val runTask: AbstractExecTask<*>?
get() = runTaskName?.let { project.tasks.getByName(it) as AbstractExecTask<*> }
get() = runTaskProvider?.get()
}
class TestExecutable(