I want to publish an Android library (.aar
) to a Maven Repository. I manage to do it using the signing
and maven-publish
plugins. But the signing
plugin does not seem to work with a keystore file: it seems to take something like this:
signing.keyId=24875D73
signing.password=secret
signing.secretKeyRingFile=/Users/me/.gnupg/secring.gpg
and what I have are a .keystore
file, a keyAlias
(which looks more like “key0” than a PGP key), then a store password and a key password.
So instead of using the signing
plugin, I thought I could do something more like this:
tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease') {
def aarPath = "${project.buildDir}/outputs/aar/XXX-release.aar"
task.doLast {
ant.signjar(
alias: android.signingConfigs.release.keyAlias,
jar: aarPath,
keystore: android.signingConfigs.release.storeFile,
storepass: android.signingConfigs.release.storePassword,
keypass: android.signingConfigs.release.keyPassword,
preservelastmodified: 'true')
ant.verifyjar(
alias: android.signingConfigs.release.keyAlias,
jar: aarPath,
keystore: android.signingConfigs.release.storeFile,
storepass: android.signingConfigs.release.storePassword,
keypass: android.signingConfigs.release.keyPassword)
}
}
}
This works when I do ./gradlew assembleRelease
(i.e. I can verify with jarsigner
that the aar is signed). But when I do ./gradlew publish
, somehow my output aar is not signed. Which confuses me because I thought that the publish
task would run the assembleRelease
task, which would run the signing.
What am I missing? How can I sign my aar with a keystore and still push it to a Maven Repository?