Skip to content

Commit

Permalink
full use of newest publish plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
scottf authored Jun 22, 2021
1 parent be92e62 commit a635591
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ jobs:
run: ./gradlew -i publishToSonatype
- name: On Tag Release Main, Verify, Sign and Publish Release
if: ${{ success() && github.event_name == 'release' }}
run: ./gradlew -i sign publishToSonatype closeAndReleaseRepository
run: ./gradlew -i signArchives signMavenJavaPublication publishToSonatype closeAndReleaseSonatypeStagingRepository

96 changes: 20 additions & 76 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import org.gradle.internal.os.OperatingSystem

plugins {
id 'java-library'
id 'java'
id 'jacoco'
id 'java-library'
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.8.4'
id 'biz.aQute.bnd.builder' version '5.1.2'
id 'io.codearte.nexus-staging' version '0.21.0'
id "de.marcphilipp.nexus-publish" version "0.3.0"
id "org.gradle.test-retry" version "1.1.9"
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'signing'
}

import aQute.bnd.gradle.Bundle
Expand All @@ -20,7 +19,7 @@ import aQute.bnd.gradle.Bundle
// src/main/java/io/nats/client/Nats.java
// src/main/java/io/nats/client/package-info.java
// CHANGELOG.md
def jarVersion = "2.11.5.beta1"
def jarVersion = "2.11.5.beta3"

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

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

tasks {
closeRepository {
onlyIf { nexusPublishing.useStaging.get() }
}
releaseRepository{
onlyIf { nexusPublishing.useStaging.get() }
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -181,23 +171,15 @@ artifacts {
archives javadocJar, sourcesJar, examplesJar
}

if (isRelease) {
signing {
def signingKeyId = System.getenv('SIGNING_KEY_ID')
def signingKey = System.getenv('SIGNING_KEY')
def signingPassword = System.getenv('SIGNING_PASSWORD')
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign configurations.archives
sign publishing.publications.mavenJava
nexusPublishing {
repositories {
sonatype {
username = System.getenv('OSSRH_USERNAME')
password = System.getenv('OSSRH_PASSWORD')
}
}
}

nexusStaging {
packageGroup = group
username = System.getenv('OSSRH_USERNAME')
password = System.getenv('OSSRH_PASSWORD')
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down Expand Up @@ -230,55 +212,17 @@ publishing {
url = 'https://github.com/nats-io/nats.java'
}
}

pom.withXml {
def pomFile = file("${project.buildDir}/generated-pom.xml")
writeTo(pomFile)

if (isRelease) {
def pomAscFile = signing.sign(pomFile).signatureFiles[0]
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
}
}
}

// create the signed artifacts
if (isRelease) {
project.tasks.signArchives.signatureFiles.each {
artifact(it) {
def matcher = it.file =~ /-(sources|javadoc|examples)\.jar\.asc$/
if (matcher.find()) {
classifier = matcher.group(1)
} else {
classifier = null
}
extension = 'jar.asc'
}
}
}
}
}
}

nexusPublishing {
repositories {
sonatype {
username = System.getenv('OSSRH_USERNAME')
password = System.getenv('OSSRH_PASSWORD')
}
}
}

model {
tasks.generatePomFileForMavenJavaPublication {
destination = file("$buildDir/generated-pom.xml")
}

tasks.publishMavenJavaPublicationToSonatypeRepository {
if (isRelease) {
dependsOn project.tasks.signArchives
}
}
if (isRelease) {
signing {
def signingKeyId = System.getenv('SIGNING_KEY_ID')
def signingKey = System.getenv('SIGNING_KEY')
def signingPassword = System.getenv('SIGNING_PASSWORD')
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign configurations.archives
sign publishing.publications.mavenJava
}
}
4 changes: 2 additions & 2 deletions src/examples/java/io/nats/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ You can also just insert some code before the arguments are processed to set the
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:

```bash
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"
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"
```

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

```bash
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
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
```

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

0 comments on commit a635591

Please sign in to comment.