Skip to content

Commit fd41055

Browse files
authored
vanniktech publish plugin (#176)
* vanniktech publish plugin * Not compatible with Java 8 * More Java 8
1 parent 52eb3e2 commit fd41055

File tree

3 files changed

+58
-84
lines changed

3 files changed

+58
-84
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
matrix:
2323
os: [ubuntu-latest]
2424
java-distribution: [adopt]
25-
java-version: [8]
25+
java-version: [11]
2626
dockcross-only:
2727
[
2828
"android-arm",
@@ -85,7 +85,7 @@ jobs:
8585
matrix:
8686
os: [macos-latest]
8787
java-distribution: [adopt]
88-
java-version: [8]
88+
java-version: [11]
8989

9090
steps:
9191
- uses: actions/checkout@v4
@@ -193,13 +193,13 @@ jobs:
193193
194194
- name: Publish to Sonatype OSSRH (Maven Central)
195195
env:
196-
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
197-
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
198-
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
199-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
200-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
201-
OSSRH_STAGING_PROFILE_ID: ${{ secrets.OSSRH_STAGING_PROFILE_ID }}
202-
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Ph3GithubArtifactsUse=true -Ph3GithubArtifactsByRun=true
196+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
197+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
198+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
199+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
200+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }}
201+
# OSSRH_STAGING_PROFILE_ID: ${{ secrets.OSSRH_STAGING_PROFILE_ID }}
202+
run: ./gradlew publishAndReleaseToMavenCentral -Ph3GithubArtifactsUse=true -Ph3GithubArtifactsByRun=true
203203

204204
- name: Create GitHub Release (with changelog notes)
205205
# This uses an action to create a release on GitHub

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix:
1919
os: [ubuntu-latest]
2020
java-distribution: [adopt]
21-
java-version: [8, 11, 17, 21, 22]
21+
java-version: [11, 17, 21, 22]
2222
dockcross-only: ["android-arm", "android-arm64", "linux-arm64", "linux-armv5", "linux-armv7", "linux-s390x", "linux-ppc64le", "linux-x64", "linux-x86", "windows-static-x64", "windows-static-x86"]
2323

2424
steps:
@@ -59,7 +59,7 @@ jobs:
5959

6060
- uses: actions/upload-artifact@v4
6161
name: Upload artifacts
62-
if: ${{ matrix.java-version == 8 }}
62+
if: ${{ matrix.java-version == 11 }}
6363
with:
6464
name: docker-built-shared-objects-${{ matrix.dockcross-only }}
6565
path: |
@@ -118,7 +118,7 @@ jobs:
118118
# TODO: Windows pinned back
119119
os: [macos-latest, windows-2022]
120120
java-distribution: [adopt]
121-
java-version: [8, 11, 17, 21, 22]
121+
java-version: [11, 17, 21, 22]
122122

123123
steps:
124124
- uses: actions/checkout@v4
@@ -149,7 +149,7 @@ jobs:
149149

150150
- uses: actions/upload-artifact@v4
151151
name: Upload Mac OS Artifacts
152-
if: ${{ matrix.os == 'macos-latest' && matrix.java-version == 8 }}
152+
if: ${{ matrix.os == 'macos-latest' && matrix.java-version == 11 }}
153153
with:
154154
name: macos-built-shared-objects
155155
path: src/main/resources/*/*.dylib
@@ -206,7 +206,7 @@ jobs:
206206
matrix:
207207
os: [ubuntu-latest]
208208
java-distribution: [adopt]
209-
java-version: [8]
209+
java-version: [11]
210210

211211
steps:
212212
- uses: actions/checkout@v4

build.gradle

Lines changed: 44 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import com.vanniktech.maven.publish.JavaLibrary
2+
import com.vanniktech.maven.publish.JavadocJar
3+
14
buildscript {
25
repositories {
36
mavenCentral()
@@ -15,7 +18,7 @@ plugins {
1518
// TODO: Requires Java 11
1619
// id 'com.diffplug.spotless' version '6.25.0'
1720
id 'com.github.nbaztec.coveralls-jacoco' version '1.2.20'
18-
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
21+
id 'com.vanniktech.maven.publish' version '0.34.0'
1922
}
2023

2124
group = 'com.uber'
@@ -117,75 +120,46 @@ sourcesJar {
117120
dependsOn buildH3
118121
}
119122

120-
publishing {
121-
publications {
122-
mavenJava(MavenPublication) {
123-
from components.java
124-
pom {
125-
name = 'h3'
126-
url = 'https://github.com/uber/h3-java'
127-
description = project.description
128-
licenses {
129-
license {
130-
name = 'Apache License, Version 2.0'
131-
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
132-
distribution = 'repo'
133-
}
134-
}
135-
organization {
136-
name = 'Uber Open Source'
137-
url = 'https://github.com/uber/'
138-
}
139-
scm {
140-
connection = 'scm:git:git://github.com/uber/h3-java.git'
141-
developerConnection = 'scm:git:ssh://[email protected]/uber/h3-java.git'
142-
url = 'http://github.com/uber/h3-java/tree/master'
143-
}
144-
developers {
145-
developer {
146-
id = 'isaacbrodsky'
147-
name = 'Isaac Brodsky'
148-
149-
organization = 'Uber Technologies, Inc.'
150-
organizationUrl = 'https://github.com/uber/'
151-
}
152-
}
153-
}
154-
}
155-
}
123+
mavenPublishing {
124+
coordinates(project.group, "h3", project.version)
156125

157-
// repositories {
158-
// maven {
159-
// def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
160-
// def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
161-
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
162-
// credentials {
163-
// username = project.findProperty('ossrhUsername') ?: ''
164-
// password = project.findProperty('ossrhPassword') ?: ''
165-
// }
166-
// }
167-
// }
168-
}
169-
170-
signing {
171-
// Use in-memory PGP signing keys from environment variables
172-
useInMemoryPgpKeys(
173-
System.getenv("SIGNING_KEY_ID"), // PGP key ID (short format) – optional, can be null
174-
System.getenv("SIGNING_KEY"), // PGP secret key (ASCII-armored, e.g. base64-encoded)
175-
System.getenv("SIGNING_PASSWORD") // PGP key passphrase
176-
)
177-
sign(publishing.publications) // Sign all publications
178-
}
179-
180-
nexusPublishing {
181-
repositories {
182-
sonatype {
183-
// Performance optimization, not needed:
184-
// stagingProfileId.set(System.getenv("OSSRH_STAGING_PROFILE_ID"))
185-
username.set(System.getenv("OSSRH_USERNAME"))
186-
password.set(System.getenv("OSSRH_PASSWORD"))
187-
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
188-
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
189-
}
126+
pom {
127+
name = "h3"
128+
description = project.description
129+
url = "https://github.com/uber/h3-java"
130+
licenses {
131+
license {
132+
name = "The Apache License, Version 2.0"
133+
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
134+
distribution = "http://www.apache.org/licenses/LICENSE-2.0.txt"
135+
}
136+
}
137+
organization {
138+
name = 'Uber Open Source'
139+
url = 'https://github.com/uber/'
140+
}
141+
developers {
142+
developer {
143+
id = "isaacbrodsky"
144+
name = "Isaac Brodsky"
145+
146+
}
190147
}
148+
scm {
149+
url = "http://github.com/uber/h3-java/tree/master"
150+
connection = "scm:git:git://github.com/uber/h3-java.git"
151+
developerConnection = "scm:git:ssh://[email protected]/uber/h3-java.git"
152+
}
153+
}
154+
155+
// the first parameter configures the -javadoc artifact, possible values:
156+
// - `JavadocJar.None()` don't publish this artifact
157+
// - `JavadocJar.Empty()` publish an empty jar
158+
// - `JavadocJar.Javadoc()` to publish standard javadocs
159+
// the second whether to publish a sources jar
160+
configure(new JavaLibrary(new JavadocJar.Javadoc(), true))
161+
162+
publishToMavenCentral()
163+
164+
signAllPublications()
191165
}

0 commit comments

Comments
 (0)