Skip to content

Commit 0345d22

Browse files
Merge branch '45-signing' into 'dev'
Re-enable signing of artifacts See merge request objectbox/objectbox-java!62
2 parents 2329ee3 + 7c70ff6 commit 0345d22

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Jenkinsfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ pipeline {
2222
"-PpreferredUsername=$MVN_REPO_LOGIN_USR " +
2323
"-PpreferredPassword=$MVN_REPO_LOGIN_PSW " +
2424
"-PversionPostFix=$versionPostfix"
25+
// Note: for key use Jenkins secret file with PGP key as text in ASCII-armored format.
26+
ORG_GRADLE_PROJECT_signingKeyFile = credentials('objectbox_signing_key')
27+
ORG_GRADLE_PROJECT_signingKeyId = credentials('objectbox_signing_key_id')
28+
ORG_GRADLE_PROJECT_signingPassword = credentials('objectbox_signing_key_password')
2529
}
2630

2731
options {

build.gradle

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ def projectNamesToPublish = [
6767
'objectbox-rxjava'
6868
]
6969

70+
def hasSigningProperties() {
71+
return (project.hasProperty('signingKeyId')
72+
&& project.hasProperty('signingKeyFile')
73+
&& project.hasProperty('signingPassword'))
74+
}
75+
7076
configure(subprojects.findAll { projectNamesToPublish.contains(it.name) }) {
7177
apply plugin: 'maven'
7278
apply plugin: 'signing'
@@ -82,8 +88,9 @@ configure(subprojects.findAll { projectNamesToPublish.contains(it.name) }) {
8288
}
8389

8490
signing {
85-
if (project.hasProperty('signing.keyId') && project.hasProperty('signing.password') &&
86-
project.hasProperty('signing.secretKeyRingFile')) {
91+
if (hasSigningProperties()) {
92+
String signingKey = new File(signingKeyFile).text
93+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
8794
sign configurations.archives
8895
} else {
8996
println "Signing information missing/incomplete for ${project.name}"
@@ -104,6 +111,10 @@ configure(subprojects.findAll { projectNamesToPublish.contains(it.name) }) {
104111
} else if (preferredRepo != null
105112
&& project.hasProperty('preferredUsername')
106113
&& project.hasProperty('preferredPassword')) {
114+
if (!hasSigningProperties()) {
115+
throw new InvalidUserDataException("To upload to repo signing is required.")
116+
}
117+
107118
configuration = configurations.deployerJars
108119

109120
// replace placeholders

0 commit comments

Comments
 (0)