Search code examples
gradlecode-signinggnupg

Gradle uploadArchives task unable to read secret key


I have created a gradle project and everything builds fine, but when I try to upload to my Maven repository, I get the following Gradle error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not evaluate onlyIf predicate for task ':library:signArchives'.
> Unable to read secret key from file: C:\Users\ideal\pubring.gpg (it may not be a PGP secret key ring)

I followed the instructions at Sonatype to generate the key, then copied it from its generated location to the location listed above. I have also published the public key to MITs key repository. The gradle.properties file in my user directory contains the following entries related to the keychain:

signing.keyId=MY_KEY_ID
signing.password=MY_KEY_PASSWORD
signing.secretKeyRingFile=C:\\Users\\ideal\\pubring.gpg

This is on a Windows platform. I have tried searching for the error message but the only thing which comes up is the source files for the related plugins.


Solution

  • The problem is that you are using the public key, switch to the secret key, normally named "secring.gpg". So in your case it should placed in

    C:\Users\ideal\secring.gpg