Skip to content

Commit 55012c9

Browse files
committed
Implemente createBundle task in Gradle to create GitHub release bundle
The bundle jars which are uploaded to GitHub include all of the artifacts including the signing files with the artifacts.
1 parent 064516a commit 55012c9

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

buildSrc/src/main/kotlin/b2sdk.gradle.kts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// License https://www.backblaze.com/using_b2_code.html
33

44
import org.gradle.api.credentials.PasswordCredentials
5+
import org.gradle.api.publish.internal.PublicationInternal
56

67
plugins {
78
java
@@ -139,25 +140,33 @@ publishing {
139140
}
140141
}
141142

142-
// Don't configure signing unless this is present
143143
val sonatypeUsername = findProperty("sonatypeUsername")
144144
val sonatypePassword = findProperty("sonatypePassword")
145145

146146
val gpgSigningKey = System.getenv("GPG_SIGNING_KEY")
147147
val gpgPassphrase = System.getenv("GPG_PASSPHRASE")
148148

149-
if (sonatypeUsername != null && sonatypePassword != null) {
150-
signing {
151-
setRequired {
152-
gradle.taskGraph.hasTask("publishToSonatype")
153-
}
149+
signing {
150+
setRequired {
151+
gradle.taskGraph.hasTask("publishToSonatype") || gradle.taskGraph.hasTask("createBundle")
152+
}
154153

155-
if (gpgSigningKey != null && gpgPassphrase != null) {
156-
useInMemoryPgpKeys(gpgSigningKey, gpgPassphrase)
157-
} else {
158-
useGpgCmd()
159-
}
154+
if (gpgSigningKey != null && gpgPassphrase != null) {
155+
useInMemoryPgpKeys(gpgSigningKey, gpgPassphrase)
156+
} else {
157+
useGpgCmd()
158+
}
160159

161-
sign(publishing.publications["maven"])
160+
sign(publishing.publications["maven"])
161+
}
162+
163+
tasks.register<Jar>("createBundle") {
164+
archiveBaseName.set("bundle-for-${project.name}")
165+
from((project.publishing.publications["maven"] as PublicationInternal<*>).publishableArtifacts.files) {
166+
rename {
167+
it
168+
.replace("pom-default.xml", "${project.name}-${project.version}.pom")
169+
.replace("module.json", "${project.name}-${project.version}.module")
170+
}
162171
}
163172
}

0 commit comments

Comments
 (0)