Hello, all. I'm trying to get code signing to work...
# community-support
p
Hello, all. I'm trying to get code signing to work to publish a library to Maven Central, but I keep getting stuck with the signing plugin telling me this when running `./gradlew signMavenJavaPublication`:
Copy code
Execution failed for task ':signMavenJavaPublication'.
> Cannot perform signing task ':signMavenJavaPublication' because it has no configured signatory
I've spent quite some time trying to resolve this, but even with debug output on I can't see why this would err, and the source code of the signing extension seems to indicate something was not injected, which makes it somewhat hard to follow. The layout of my
build.gradle.kts
looks like this:
Copy code
plugins {
    kotlin("jvm") version "2.1.20"
    `java-library`
    `maven-publish`
    signing
}

...

kotlin {
    jvmToolchain(21)
}

publishing {
    publications {
        create<MavenPublication>("mavenJava") {
            pom {
...
            }
        }
    }
}

signing {
    sign(publishing.publications["mavenJava"])
}
And my
~/.gradle/gradle.properties
has:
Copy code
signing.keyId=233EB591
signing.password=...
signing.secreteKeyRingFile=/home/peter/.gnupg/secring.gpg

ossrhUsername=...
ossrhPassword=...
I also tried copying that file into the project's root folder, but that didn't help either. What am I missing? Are there any tricks to debug this? PS: One thing I am very unsure about is the
keyId
bit, since
gpg -K
doesn't show a
keyId
field (the number is the last bit of the second line of
sec
).
t
Fwiw, I use `signing { useGpgCmd() }`; I also have
signing.gnupg.keyName
with the same value as
signing.keyId
in my
gradle.properties
(and no
signing.password
). Been using that for years without any issue (and can't remember why I used that approach; I presume specifically to not have the key password in a file or on the command line) HTH edit: just checked the docs, and yes, that was the reason; of course that means I can only publish from my machine, and not from some CI.
p
Thanks, Thomas. Unfortunately, CI is the goal for me: I'd like to release via GitHub actions. I made that work with Maven a few years back, but I just can't get that replicated that with Gradle.
v
Do you really want to know the solution? You will be pretty ashamed. 😄
image.png
👀 1
So what the error tells you, you did not properly configure the signatory. 🙂
p
Thanks, @Vampire. In my defense: I did copy and paste the config files for a reason - it is not the first time I could not see some typo somewhere, even though I was wondering about that scenario 🤦 I would also argue that the error message did not tell me that it couldn't find a keyring file, which would have been much more helpful. It produces a much more useful message when the
keyId
is wrong. It's probably not a topic for this forum, but I think that error message could be better, and there should be debug logging to dump out all the properties involved (or at least the non-secret ones). Either of those would have probably avoided me being stupid for that long 🙂 Should I file an enhancement request for this somewhere? Happy to do that if I get a pointer.
👌 1
v
If you want it improved, yes, on the GitHub issue tracker