I want to publish my project to maven using maven-publish
and signing
. The problem is that when i try to publish: gradle publish
i get this error:
* 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
Before publishing i generate key as following:
Then i change my ~/.gradle.gradle.properties
:
signing.keyId=ID
signing.password=PASS
signing.secretKeyRingFile=/Users/nick/.gnupg/secring.gpg
My gradle.build looks as follows:
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
}
}
}
}
What i do wrong?
I've solved this issue by generating not secring.gpg
, but secring.kbx
:
gpg --export-secret-keys -o ~/secring.kbx
I'm not sure that this is the right approach but at least gradle plugin can finally work.