Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JReleaser config #2059

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 74 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ plugins {
id "com.github.spotbugs" version "4.7.1"
id "io.codearte.nexus-staging" version "0.30.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get rid of this too right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I left it in so we could fall back to it if necessary

id "me.champeau.jmh" version "0.7.1"
id 'com.github.johnrengelman.shadow' version "7.1.2"
id "com.github.johnrengelman.shadow" version "7.1.2"
id "org.jreleaser" version "1.9.0"
}

ext {
Expand All @@ -39,6 +40,14 @@ allprojects {
version = libraryVersion
}

// Only using JReleaser based on a flag allows going back to the old
// release process if necessary. We can remove this later.
def useJreleaser = project.hasProperty("useJreleaser")

// JReleaser publishes artifacts from a local staging repository, rather than maven local.
// https://jreleaser.org/guide/latest/examples/maven/staging-artifacts.html#_gradle
def stagingDirectory = rootProject.layout.buildDirectory.dir("staging")

subprojects {
apply plugin: "java-library"

Expand Down Expand Up @@ -127,14 +136,23 @@ subprojects {

publishing {
repositories {
mavenCentral {
url = uri("https://aws.oss.sonatype.org/service/local/staging/deploy/maven2/")
if (project.hasProperty("sonatypeUser")) {
credentials {
username = project.property("sonatypeUser")
password = project.property("sonatypePassword")
}
// JReleaser's `publish` task publishes to all repositories, so only configure one.
if (useJreleaser) {
maven {
name = "localStaging"
url = stagingDirectory
}
} else {
mavenCentral {
name = "sonatypeNexus"
url = uri("https://aws.oss.sonatype.org/service/local/staging/deploy/maven2/")
if (project.hasProperty("sonatypeUser")) {
credentials {
username = project.property("sonatypeUser")
password = project.property("sonatypePassword")
}
}
}
}
}

Expand Down Expand Up @@ -271,6 +289,53 @@ allprojects {
}
}

if (useJreleaser) {
jreleaser {
dryrun = false

// Used for creating a tagged release, uploading files and generating changelog.
// In the future we can set this up to push release tags to GitHub, but for now it's
// set up to do nothing.
// https://jreleaser.org/guide/latest/reference/release/index.html
release {
generic {
enabled = true
skipRelease = true
}
}

// Used to announce a release to configured announcers.
// https://jreleaser.org/guide/latest/reference/announce/index.html
announce {
active = "NEVER"
}

// Signing configuration.
// https://jreleaser.org/guide/latest/reference/signing.html
signing {
active = "ALWAYS"
armored = true
}

// Configuration for deploying to Maven Central.
// https://jreleaser.org/guide/latest/examples/maven/maven-central.html#_gradle
deploy {
maven {
nexus2 {
'maven-central' {
active = "ALWAYS"
url = "https://aws.oss.sonatype.org/service/local"
snapshotUrl = "https://aws.oss.sonatype.org/content/repositories/snapshots"
closeRepository = false
releaseRepository = false
stagingRepository(stagingDirectory.get().toString())
}
}
}
}
}
}

/*
* Sonatype Staging Finalization
* ====================================================
Expand All @@ -280,7 +345,7 @@ allprojects {
* validated. This configuration is for the root project because
* it operates at the "group" level.
*/
if (project.hasProperty("sonatypeUser") && project.hasProperty("sonatypePassword")) {
if (!useJreleaser && project.hasProperty("sonatypeUser") && project.hasProperty("sonatypePassword")) {
apply plugin: "io.codearte.nexus-staging"
nexusStaging {
packageGroup = "software.amazon"
Expand Down