无法从密钥环文件 secring.gpg 中检索密钥,因为它不存在

Unable to retrieve secret key from key ring file secring.gpg as it does not exist

我想使用 maven-publishsigning 将我的项目发布到 Maven。问题是当我尝试发布时:gradle publish 我得到这个错误:

 * What went wrong: Execution failed for task ':project:signMavenJavaPublication'.
    > Unable to retrieve secret key from key ring file '/Users/nick/.gnupg/secring.gpg ' as it does not exist

在发布之前我生成密钥如下:

  1. gpg --gen-key
  2. gpg --export-secret-keys > ~/.gnupg/secring.gpg

然后我改变我的 ~/.gradle.gradle.properties:

signing.keyId=ID
signing.password=PASS
signing.secretKeyRingFile=/Users/nick/.gnupg/secring.gpg 

我的 gradle.build 看起来如下:

subprojects {
    if (it.name != 'exclusion') {
        apply plugin: 'java-library'
        apply plugin: 'maven-publish'
        apply plugin: 'signing'
    }

    dependencies {
...
    }

    test {
        useJUnitPlatform()

        testLogging {
            events "passed", "skipped", "failed"
        }

        testClassesDirs = sourceSets.test.output
        classpath = sourceSets.test.runtimeClasspath
    }

    task sourcesJar(type: Jar) {
        from sourceSets.main.allJava
        archiveClassifier = 'sources'
    }

    task javadocJar(type: Jar) {
        from javadoc
        archiveClassifier = 'javadoc'
    }

    javadoc {
        if(JavaVersion.current().isJava9Compatible()) {
            options.addBooleanOption('html5', true)
        }
    }

    if (it.name != 'exclusion') {
        publishing {
            publications {
                mavenJava(MavenPublication) {
                    artifactId = it.name
                    from components.java
                    artifact sourcesJar
                    artifact javadocJar
                    versionMapping {
                        usage('java-api') {
                            fromResolutionOf('runtimeClasspath')
                        }
                        usage('java-runtime') {
                            fromResolutionResult()
                        }
                    }
                    pom {
...
                        licenses {
...
                        }
                        developers {
...
                        }
                        scm {
...
                        }
                    }
                }
            }

            repositories {
                maven {
...
                }
            }
        }

        if (project.hasProperty("signing.keyId")) {
            signing {
                sign publishing.publications.mavenJava
            }
        }
    }
}

我做错了什么?

我解决了这个问题,生成的不是 secring.gpg,而是 secring.kbx:

gpg --export-secret-keys -o ~/secring.kbx

我不确定这是正确的方法,但至少 gradle 插件终于可以工作了。