From 6ecfbdf56d9b24c16ac55402cb9307fa457d7ae3 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 5 Nov 2023 13:22:32 +0600 Subject: [PATCH] improvements in publish.gradle --- publish.gradle | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/publish.gradle b/publish.gradle index 689e0bc0c2..87124750ed 100644 --- a/publish.gradle +++ b/publish.gradle @@ -104,17 +104,19 @@ if (project.hasProperty("signing.gnupg.keyName")) { } // Workaround to make test tasks use sign project.getTasks().withType(Sign.class).configureEach { signTask -> - def pubName = signTask.name.removePrefix("sign").removeSuffix("Publication") - + def withoutSign = (signTask.name.startsWith("sign") ? signTask.name.minus("sign") : signTask.name) + def pubName = withoutSign.endsWith("Publication") ? withoutSign.substring(0, withoutSign.length() - "Publication".length()) : withoutSign // These tasks only exist for native targets, hence findByName() to avoid trying to find them for other targets // Task ':linkDebugTest' uses this output of task ':signPublication' without declaring an explicit or implicit dependency - tasks.findByName("linkDebugTest$pubName")?.let { - signTask.mustRunAfter(it) + def debugTestTask = tasks.findByName("linkDebugTest$pubName") + if (debugTestTask != null) { + signTask.mustRunAfter(debugTestTask) } // Task ':compileTestKotlin' uses this output of task ':signPublication' without declaring an explicit or implicit dependency - tasks.findByName("compileTestKotlin$pubName")?.let { - signTask.mustRunAfter(it) + def testTask = tasks.findByName("compileTestKotlin$pubName") + if (testTask != null) { + signTask.mustRunAfter(testTask) } } }