From c5a02902a7d95cc1194caa95b1eca46405f908a1 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Thu, 18 Nov 2021 16:05:20 +0300 Subject: [PATCH] [K/N][build] Add artifacts depending on input in library task Depending on noPack option compiler produces file or directory. Artifact field that contains .klib file can't use @OutputDirectory annotation. The same applies for @OutputFile with directory. To workaround make an artifact field internal and use two optional fields that return either file or directory depending on noPack option. --- kotlin-native/runtime/build.gradle.kts | 1 - .../gradle/plugin/konan/tasks/KonanCompileTask.kt | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kotlin-native/runtime/build.gradle.kts b/kotlin-native/runtime/build.gradle.kts index 05fcd82fd82..252e615acc9 100644 --- a/kotlin-native/runtime/build.gradle.kts +++ b/kotlin-native/runtime/build.gradle.kts @@ -439,7 +439,6 @@ konanArtifacts { stdlibBuildTask = project.findKonanBuildTask("stdlib", project.platformManager.hostPlatform.target).apply { configure { dependsOn(":kotlin-native:distCompiler") - outputs.dir(project.buildDir.resolve("stdlib/$hostName/stdlib")) } } } diff --git a/kotlin-native/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/konan/tasks/KonanCompileTask.kt b/kotlin-native/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/konan/tasks/KonanCompileTask.kt index 440ea673219..4eaf5f2dd8f 100644 --- a/kotlin-native/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/konan/tasks/KonanCompileTask.kt +++ b/kotlin-native/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/konan/tasks/KonanCompileTask.kt @@ -391,6 +391,18 @@ open class KonanCompileFrameworkTask: KonanCompileNativeBinary() { } open class KonanCompileLibraryTask: KonanCompileTask() { + override val artifact: File + @Internal get() = destinationDir.resolve(artifactFullName) + + val artifactFile: File? + @Optional @OutputFile get() = if (!noPack) artifact else null + + val artifactDirectory: File? + @Optional @OutputDirectory get() = if (noPack) artifact else null + + override val artifactSuffix: String + @Internal get() = if (!noPack) produce.suffix(konanTarget) else "" + override fun buildCommonArgs() = super.buildCommonArgs().apply { addKey("-nopack", noPack) }