我想使用maven-publish
和signing
将我的项目发布到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
发布之前,我生成密钥如下:
- gpg -生成密钥
- 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
}
}
}
}
我做错了什么?
2条答案
按热度按时间2guxujil1#
我通过生成
secring.kbx
而不是secring.gpg
解决了这个问题:我不确定这是否是正确的方法,但至少gradle插件终于可以工作了。
qncylg1j2#
请执行以下操作:
更多信息请点击此处。