@@ -26,6 +26,23 @@ if (project.hasProperty("signing.gnupg.keyName")) {
26
26
def signingTasks = project.getTasks().withType(Sign.class)
27
27
mustRunAfter(signingTasks)
28
28
}
29
+ // Workaround to make test tasks use sign
30
+ project.getTasks().withType(Sign.class).configureEach { signTask ->
31
+ def withoutSign = (signTask.name.startsWith("sign") ? signTask.name.minus("sign") : signTask.name)
32
+ def pubName = withoutSign.endsWith("Publication") ? withoutSign.substring(0, withoutSign.length() - "Publication".length()) : withoutSign
33
+ // These tasks only exist for native targets, hence findByName() to avoid trying to find them for other targets
34
+
35
+ // Task ':linkDebugTest<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
36
+ def debugTestTask = tasks.findByName("linkDebugTest${' $' } pubName")
37
+ if (debugTestTask != null) {
38
+ signTask.mustRunAfter(debugTestTask)
39
+ }
40
+ // Task ':compileTestKotlin<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
41
+ def testTask = tasks.findByName("compileTestKotlin${' $' } pubName")
42
+ if (testTask != null) {
43
+ signTask.mustRunAfter(testTask)
44
+ }
45
+ }
29
46
}
30
47
"""
31
48
GpgSigning .Enabled ->
@@ -43,5 +60,28 @@ task signAll {
43
60
dependsOn(it)
44
61
}
45
62
}
63
+
64
+ // Workaround to make android sign operations depend on signing tasks
65
+ project.getTasks().withType(AbstractPublishToMaven.class).configureEach {
66
+ def signingTasks = project.getTasks().withType(Sign.class)
67
+ mustRunAfter(signingTasks)
68
+ }
69
+ // Workaround to make test tasks use sign
70
+ project.getTasks().withType(Sign.class).configureEach { signTask ->
71
+ def withoutSign = (signTask.name.startsWith("sign") ? signTask.name.minus("sign") : signTask.name)
72
+ def pubName = withoutSign.endsWith("Publication") ? withoutSign.substring(0, withoutSign.length() - "Publication".length()) : withoutSign
73
+ // These tasks only exist for native targets, hence findByName() to avoid trying to find them for other targets
74
+
75
+ // Task ':linkDebugTest<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
76
+ def debugTestTask = tasks.findByName("linkDebugTest${' $' } pubName")
77
+ if (debugTestTask != null) {
78
+ signTask.mustRunAfter(debugTestTask)
79
+ }
80
+ // Task ':compileTestKotlin<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
81
+ def testTask = tasks.findByName("compileTestKotlin${' $' } pubName")
82
+ if (testTask != null) {
83
+ signTask.mustRunAfter(testTask)
84
+ }
85
+ }
46
86
"""
47
87
}
0 commit comments