Skip to content

Commit 1b5e3bc

Browse files
committed
signed
1 parent e5f6f72 commit 1b5e3bc

2 files changed

Lines changed: 70 additions & 126 deletions

File tree

.github/workflows/publish_test.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ jobs:
3232
run: ./gradlew --parallel assemble javadoc
3333

3434
- name: Upload to SNAPSHOT repository
35-
run: ./gradlew --parallel publishMavenJavaPublicationToKEYLABRepository
35+
run: |
36+
./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
3637
env:
3738
BUILD_NUMBER: "SNAPSHOT"
38-
SIGNING_KEY_ID: ${{secrets.SIGNING_KEY_ID}}
39-
GPG_PRIVATE_KEY: ${{secrets.GPG_PRIVATE_KEY}}
40-
GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}}
39+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.GPG_PRIVATE_KEY}}
40+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.GPG_PASSPHRASE}}
41+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
42+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
4143

4244
- name: Upload to SNAPSHOT repository
4345
run: ./gradlew --parallel publishMavenJavaPublicationToKEYLABRepository

build.gradle

Lines changed: 64 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ plugins {
1414
id "org.checkerframework" version "0.6.61"
1515

1616
// Plugin for publishing via the new Nexus API
17-
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
18-
19-
id "signing"
17+
id "com.vanniktech.maven.publish" version "0.36.0"
2018
}
2119

2220

@@ -41,8 +39,6 @@ version = "3.0.0$build"
4139
subprojects {
4240
apply plugin: "java"
4341
apply plugin: "java-library"
44-
apply plugin: "maven-publish"
45-
apply plugin: "signing" // GPG signing of artifacts, required by maven central
4642
apply plugin: "idea"
4743
apply plugin: "eclipse"
4844

@@ -81,13 +77,13 @@ subprojects {
8177
testImplementation("ch.qos.logback:logback-classic:1.5.32")
8278

8379
testImplementation(platform("org.junit:junit-bom:6.0.3"))
84-
testImplementation ("org.junit.jupiter:junit-jupiter-api")
85-
testImplementation ("org.junit.jupiter:junit-jupiter-params")
86-
testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine")
87-
testRuntimeOnly ("org.junit.platform:junit-platform-launcher")
88-
testImplementation ("org.assertj:assertj-core:3.27.7")
89-
testImplementation (project(':key.util'))
90-
testImplementation (testFixtures(project(":key.util")))
80+
testImplementation("org.junit.jupiter:junit-jupiter-api")
81+
testImplementation("org.junit.jupiter:junit-jupiter-params")
82+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
83+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
84+
testImplementation("org.assertj:assertj-core:3.27.7")
85+
testImplementation(project(':key.util'))
86+
testImplementation(testFixtures(project(":key.util")))
9187

9288
// test fixtures
9389
testImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.21.3")
@@ -148,10 +144,10 @@ subprojects {
148144
}
149145

150146
addTestListener(new TestListener() {
151-
void afterTest(TestDescriptor desc, TestResult result) {
152-
logger.error("${result.getResultType()}: ${desc.getClassName()}#${desc.getName()}")
153-
}
154-
})
147+
void afterTest(TestDescriptor desc, TestResult result) {
148+
logger.error("${result.getResultType()}: ${desc.getClassName()}#${desc.getName()}")
149+
}
150+
})
155151

156152
addTestListener(new TestListener() {
157153
void beforeTest(TestDescriptor descriptor) {
@@ -292,120 +288,66 @@ subprojects {
292288
}
293289
}
294290

295-
afterEvaluate { // required so project.description is non-null as set by sub build.gradle
296-
publishing {
297-
publications {
298-
mavenJava(MavenPublication) {
299-
from components.java
300-
artifact sourcesJar
301-
artifact javadocJar
302-
pom {
303-
name = projects.name
304-
description = project.description
305-
url = 'https://key-project.org/'
306-
307-
licenses {
308-
license {
309-
name = "GNU General Public License (GPL), Version 2"
310-
url = "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"
311-
}
312-
}
313-
314-
developers {
315-
developer {
316-
id = 'key'
317-
name = 'KeY Developers'
318-
email = 'support@key-project.org'
319-
url = "https://www.key-project.org/about/people/"
320-
}
321-
}
322-
scm {
323-
connection = 'scm:git:git://github.com/keyproject/key.git'
324-
developerConnection = 'scm:git:git://github.com/keyproject/key.git'
325-
url = 'https://github.com/keyproject/key/'
326-
}
327-
}
291+
mavenPublishing {
292+
publishToMavenCentral(true)
293+
signAllPublications()
294+
295+
pom {
296+
name = projects.name
297+
description = project.description
298+
url = 'https://key-project.org/'
299+
300+
licenses {
301+
license {
302+
name = "GNU General Public License (GPL), Version 2"
303+
url = "https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"
328304
}
329305
}
330-
repositories {
331-
maven {
332-
name = "LOCAL"
333-
url= uri("$rootDir/local")
334-
}
335306

336-
maven { // deployment to git.key-project.org/key-public/key
337-
name = "KEYLAB"
338-
url = uri("https://git.key-project.org/api/v4/projects/35/packages/maven")
339-
credentials(HttpHeaderCredentials) {
340-
def userToken = envOrPropertyValue("GITLAB_USER_TOKEN")
341-
def deployToken = envOrPropertyValue("GITLAB_DEPLOY_TOKEN")
342-
def ciToken = envOrPropertyValue("GITLAB_CIJOB_TOKEN")
343-
344-
if (userToken != "") {
345-
name = 'Private-Token'
346-
value = userToken
347-
} else if(deployToken != "") {
348-
name = 'Deploy-Token'
349-
value = deployToken
350-
} else {
351-
name = 'Job-Token'
352-
value = ciToken
353-
}
354-
}
355-
authentication {
356-
header(HttpHeaderAuthentication)
357-
}
307+
developers {
308+
developer {
309+
id = 'key'
310+
name = 'KeY Developers'
311+
email = 'support@key-project.org'
312+
url = "https://www.key-project.org/about/people/"
358313
}
359314
}
315+
scm {
316+
connection = 'scm:git:git://github.com/keyproject/key.git'
317+
developerConnection = 'scm:git:git://github.com/keyproject/key.git'
318+
url = 'https://github.com/keyproject/key/'
319+
}
360320
}
361-
signing {
362-
sign publishing.publications.mavenJava
363-
}
364-
}
365-
}
366321

367-
signing {
368-
// does not work
369-
if(System.getenv("GPG_PRIVATE_KEY") == null) {
370-
println("Use useGpgCmd()")
371-
useGpgCmd() // works better than the Java implementation, which requires PGP keyrings.
372-
} else{
373-
println("Useinmem")
374-
useInMemoryPgpKeys(
375-
System.getenv("SIGNING_KEY_ID"),
376-
System.getenv("GPG_PRIVATE_KEY"),
377-
System.getenv("GPG_PASSPHRASE")
378-
)
379-
}
380-
}
322+
repositories {
323+
maven {
324+
name = "LOCAL"
325+
url= uri("$rootDir/local")
326+
}
381327

382-
nexusPublishing {
383-
repositories {
384-
central {
385-
nexusUrl = uri("https://ossrh-staging-api.central.sonatype.com/service/local/")
386-
snapshotRepositoryUrl = uri("https://central.sonatype.com/repository/maven-snapshots/")
387-
388-
stagingProfileId.set("org.key-project")
389-
390-
/**
391-
* To be able to publish things on Maven Central, you need two things:
392-
*
393-
* (1) a JIRA account with permission on group-id `org.key-project`
394-
* (2) a keyserver-published GPG (w/o sub-keys)
395-
*
396-
* Your `$HOME/.gradle/gradle.properties` should like this:
397-
* ```
398-
* signing.keyId=YourKeyId
399-
* signing.password=YourPublicKeyPassword
400-
* ossrhUsername=your-jira-id
401-
* ossrhPassword=your-jira-password
402-
* ```
403-
*
404-
* You can test signing with `gradle sign`, and publish with `gradle publish`.
405-
* https://central.sonatype.org/publish/publish-guide/
406-
*/
407-
username = envOrPropertyValue("ossrhUsername")
408-
password = envOrPropertyValue("ossrhPassword")
328+
maven { // deployment to git.key-project.org/key-public/key
329+
name = "KEYLAB"
330+
url = uri("https://git.key-project.org/api/v4/projects/35/packages/maven")
331+
credentials(HttpHeaderCredentials) {
332+
def userToken = envOrPropertyValue("GITLAB_USER_TOKEN")
333+
def deployToken = envOrPropertyValue("GITLAB_DEPLOY_TOKEN")
334+
def ciToken = envOrPropertyValue("GITLAB_CIJOB_TOKEN")
335+
336+
if (userToken != "") {
337+
name = 'Private-Token'
338+
value = userToken
339+
} else if(deployToken != "") {
340+
name = 'Deploy-Token'
341+
value = deployToken
342+
} else {
343+
name = 'Job-Token'
344+
value = ciToken
345+
}
346+
}
347+
authentication {
348+
header(HttpHeaderAuthentication)
349+
}
350+
}
409351
}
410352
}
411353
}

0 commit comments

Comments
 (0)