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

zphenhs4  于 2023-01-29  发布在  Maven
关注(0)|答案(2)|浏览(189)

我想使用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 -生成密钥
  2. gpg --导出密钥〉~/.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
            }
        }
    }
}

我做错了什么?

2guxujil

2guxujil1#

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

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

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

qncylg1j

qncylg1j2#

请执行以下操作:

gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg

更多信息请点击此处。

相关问题