Skip to content

Commit a635591

Browse files
authored
full use of newest publish plugin
1 parent be92e62 commit a635591

File tree

3 files changed

+23
-79
lines changed

3 files changed

+23
-79
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@ jobs:
5656
run: ./gradlew -i publishToSonatype
5757
- name: On Tag Release Main, Verify, Sign and Publish Release
5858
if: ${{ success() && github.event_name == 'release' }}
59-
run: ./gradlew -i sign publishToSonatype closeAndReleaseRepository
59+
run: ./gradlew -i signArchives signMavenJavaPublication publishToSonatype closeAndReleaseSonatypeStagingRepository
6060

build.gradle

Lines changed: 20 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import org.gradle.internal.os.OperatingSystem
22

33
plugins {
4-
id 'java-library'
54
id 'java'
6-
id 'jacoco'
5+
id 'java-library'
76
id 'maven-publish'
8-
id 'signing'
7+
id 'jacoco'
98
id 'com.github.kt3k.coveralls' version '2.8.4'
109
id 'biz.aQute.bnd.builder' version '5.1.2'
11-
id 'io.codearte.nexus-staging' version '0.21.0'
12-
id "de.marcphilipp.nexus-publish" version "0.3.0"
1310
id "org.gradle.test-retry" version "1.1.9"
11+
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
12+
id 'signing'
1413
}
1514

1615
import aQute.bnd.gradle.Bundle
@@ -20,7 +19,7 @@ import aQute.bnd.gradle.Bundle
2019
// src/main/java/io/nats/client/Nats.java
2120
// src/main/java/io/nats/client/package-info.java
2221
// CHANGELOG.md
23-
def jarVersion = "2.11.5.beta1"
22+
def jarVersion = "2.11.5.beta3"
2423

2524
def isRelease = System.getenv("BUILD_EVENT") == "release"
2625

@@ -30,15 +29,6 @@ version = isRelease ? jarVersion : jarVersion + "-SNAPSHOT"
3029
archivesBaseName = 'jnats'
3130
group = 'io.nats'
3231

33-
tasks {
34-
closeRepository {
35-
onlyIf { nexusPublishing.useStaging.get() }
36-
}
37-
releaseRepository{
38-
onlyIf { nexusPublishing.useStaging.get() }
39-
}
40-
}
41-
4232
java {
4333
sourceCompatibility = JavaVersion.VERSION_1_8
4434
targetCompatibility = JavaVersion.VERSION_1_8
@@ -181,23 +171,15 @@ artifacts {
181171
archives javadocJar, sourcesJar, examplesJar
182172
}
183173

184-
if (isRelease) {
185-
signing {
186-
def signingKeyId = System.getenv('SIGNING_KEY_ID')
187-
def signingKey = System.getenv('SIGNING_KEY')
188-
def signingPassword = System.getenv('SIGNING_PASSWORD')
189-
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
190-
sign configurations.archives
191-
sign publishing.publications.mavenJava
174+
nexusPublishing {
175+
repositories {
176+
sonatype {
177+
username = System.getenv('OSSRH_USERNAME')
178+
password = System.getenv('OSSRH_PASSWORD')
179+
}
192180
}
193181
}
194182

195-
nexusStaging {
196-
packageGroup = group
197-
username = System.getenv('OSSRH_USERNAME')
198-
password = System.getenv('OSSRH_PASSWORD')
199-
}
200-
201183
publishing {
202184
publications {
203185
mavenJava(MavenPublication) {
@@ -230,55 +212,17 @@ publishing {
230212
url = 'https://github.com/nats-io/nats.java'
231213
}
232214
}
233-
234-
pom.withXml {
235-
def pomFile = file("${project.buildDir}/generated-pom.xml")
236-
writeTo(pomFile)
237-
238-
if (isRelease) {
239-
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
240-
artifact(pomAscFile) {
241-
classifier = null
242-
extension = 'pom.asc'
243-
}
244-
}
245-
}
246-
247-
// create the signed artifacts
248-
if (isRelease) {
249-
project.tasks.signArchives.signatureFiles.each {
250-
artifact(it) {
251-
def matcher = it.file =~ /-(sources|javadoc|examples)\.jar\.asc$/
252-
if (matcher.find()) {
253-
classifier = matcher.group(1)
254-
} else {
255-
classifier = null
256-
}
257-
extension = 'jar.asc'
258-
}
259-
}
260-
}
261215
}
262216
}
217+
}
263218

264-
nexusPublishing {
265-
repositories {
266-
sonatype {
267-
username = System.getenv('OSSRH_USERNAME')
268-
password = System.getenv('OSSRH_PASSWORD')
269-
}
270-
}
271-
}
272-
273-
model {
274-
tasks.generatePomFileForMavenJavaPublication {
275-
destination = file("$buildDir/generated-pom.xml")
276-
}
277-
278-
tasks.publishMavenJavaPublicationToSonatypeRepository {
279-
if (isRelease) {
280-
dependsOn project.tasks.signArchives
281-
}
282-
}
219+
if (isRelease) {
220+
signing {
221+
def signingKeyId = System.getenv('SIGNING_KEY_ID')
222+
def signingKey = System.getenv('SIGNING_KEY')
223+
def signingPassword = System.getenv('SIGNING_PASSWORD')
224+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
225+
sign configurations.archives
226+
sign publishing.publications.mavenJava
283227
}
284228
}

src/examples/java/io/nats/examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ You can also just insert some code before the arguments are processed to set the
8484
In the examples, the usage will show `java <program> -cp <classpath> ...` Make sure you add both the client library and examples into the classpath. For example:
8585

8686
```bash
87-
java -cp build/libs/jnats-2.11.0-SNAPSHOT.jar:build/libs/jnats-2.11.0-SNAPSHOT-examples.jar io.nats.examples.NatsPub nats://localhost:4222 test "hello world"
87+
java -cp build/libs/jnats-2.11.5-SNAPSHOT.jar:build/libs/jnats-2.11.5-SNAPSHOT-examples.jar io.nats.examples.NatsPub nats://localhost:4222 test "hello world"
8888
```
8989

9090
### Some examples depend on others
@@ -102,7 +102,7 @@ java -Djavax.net.ssl.keyStore=src/test/resources/keystore.jks -Djavax.net.ssl.ke
102102
To run with the completely unverified client:
103103

104104
```bash
105-
java -cp build/libs/jnats-2.11.0-SNAPSHOT.jar:build/libs/jnats-2.11.0-SNAPSHOT-examples.jar io.nats.examples.NatsSub opentls://localhost:4443 test 3
105+
java -cp build/libs/jnats-2.11.5-SNAPSHOT.jar:build/libs/jnats-2.11.5-SNAPSHOT-examples.jar io.nats.examples.NatsSub opentls://localhost:4443 test 3
106106
```
107107

108108
There are a set tls configuration for the server in the test files that can be used to run the NATS server.

0 commit comments

Comments
 (0)