How to only enable the Signing plugin if we're about to release

I’m trying to migrate from Bintray to Maven Central, so one of the things I have to do is sign the artefacts. I have the following in my

signing {
    val signingKey: String? by project
    val signingPassword: String? by project
    useInMemoryPgpKeys(signingKey, signingPassword)

The environment variables will be provided by a GitHub Action.

However, that’s causing ./gradlew build to fail on my computer with:

Execution failed for task ':signArchives'.
> Cannot perform signing task ':signArchives' because it has no configured signatory

I don’t want to specify some dummy credentials just to make this work. I only want to use signing { ... } if I’m running ./gradlew publish (since I’m using the maven-publish plugin). How can I do that?


Like this: command-framework/publishing.gradle.kts at master · Vampire/command-framework · GitHub

1 Like

Thank you! It worked.