Thank you. This works like you said. With your solution, I had to depend on the “assembleRelease” task in task foo. I am trying to understand why two tasks were used here.
For example, the following works, too:
val assembleAndSignApk by registering {
dependsOn("assembleRelease")
val apk = layout.buildDirectory.file("outputs/apk/release/${rootProject.name}-$version.apk")
inputs.file(apk)
outputs.file(apk.map { it.asFile.resolveSibling("${it.asFile.name}.asc") })
doLast {
signing {
useGpgCmd()
sign(*inputs.files.files.toTypedArray())
}
}
}
I noticed a difference, though. Without the dependency, I get an error regarding the input file missing, whereas with your solution, I get an error about the dependency missing instead.
I want to understand why two tasks are needed and why my approach causes a different error when the dependency is missing.