Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ private object Properties {
}

private object EnvironmentVariables {
object JReleaser {
const val GROUP_ID = "JRELEASER_PROJECT_JAVA_GROUP_ID"
const val MAVEN_CENTRAL_USERNAME = "JRELEASER_MAVENCENTRAL_USERNAME"
const val MAVEN_CENTRAL_TOKEN = "JRELEASER_MAVENCENTRAL_TOKEN"
const val GPG_PASSPHRASE = "JRELEASER_GPG_PASSPHRASE"
const val GPG_PUBLIC_KEY = "JRELEASER_GPG_PUBLIC_KEY"
const val GPG_SECRET_KEY = "JRELEASER_GPG_SECRET_KEY"
}
const val GROUP_ID = "JRELEASER_PROJECT_JAVA_GROUP_ID"
const val MAVEN_CENTRAL_USERNAME = "JRELEASER_MAVENCENTRAL_USERNAME"
const val MAVEN_CENTRAL_TOKEN = "JRELEASER_MAVENCENTRAL_TOKEN"
const val GPG_PASSPHRASE = "JRELEASER_GPG_PASSPHRASE"
const val GPG_PUBLIC_KEY = "JRELEASER_GPG_PUBLIC_KEY"
const val GPG_SECRET_KEY = "JRELEASER_GPG_SECRET_KEY"
}

private val ALLOWED_PUBLICATION_NAMES = setOf(
Expand Down Expand Up @@ -113,8 +111,8 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = "
}
}

val secretKey = System.getenv(EnvironmentVariables.JReleaser.GPG_SECRET_KEY)
val passphrase = System.getenv(EnvironmentVariables.JReleaser.GPG_PASSPHRASE)
val secretKey = System.getenv(EnvironmentVariables.GPG_SECRET_KEY)
val passphrase = System.getenv(EnvironmentVariables.GPG_PASSPHRASE)

if (!secretKey.isNullOrBlank() && !passphrase.isNullOrBlank()) {
apply(plugin = "signing")
Expand Down Expand Up @@ -143,16 +141,6 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = "
}
}
}

/*
Creates a placeholder JAR for the version catalog
The `version-catalog` plugin doesn't generate one because it isn't needed but JReleaser requires a jar
https://docs.gradle.org/current/userguide/version_catalogs.html#sec:version-catalog-plugin
*/
tasks.register<Jar>("versionCatalogJar") {
archiveBaseName.set("version-catalog")
from("gradle/libs.versions.toml")
}
}

/**
Expand All @@ -163,11 +151,11 @@ fun Project.configureJReleaser() {

var missingVariables = false
listOf(
EnvironmentVariables.JReleaser.MAVEN_CENTRAL_USERNAME,
EnvironmentVariables.JReleaser.MAVEN_CENTRAL_TOKEN,
EnvironmentVariables.JReleaser.GPG_PASSPHRASE,
EnvironmentVariables.JReleaser.GPG_PUBLIC_KEY,
EnvironmentVariables.JReleaser.GPG_SECRET_KEY,
EnvironmentVariables.MAVEN_CENTRAL_USERNAME,
EnvironmentVariables.MAVEN_CENTRAL_TOKEN,
EnvironmentVariables.GPG_PASSPHRASE,
EnvironmentVariables.GPG_PUBLIC_KEY,
EnvironmentVariables.GPG_SECRET_KEY,
).forEach {
if (System.getenv(it).isNullOrBlank()) {
missingVariables = true
Expand Down Expand Up @@ -195,6 +183,13 @@ fun Project.configureJReleaser() {
active = Active.ALWAYS
url = "https://central.sonatype.com/api/v1/publisher"
stagingRepository(rootProject.layout.buildDirectory.dir("m2").get().toString())
artifacts {
artifactOverride {
artifactId = "version-catalog"
jar = false
verifyPom = false // jreleaser doesn't understand toml packaging
}
}
Comment on lines +186 to +192
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment: Nice!

}
}
}
Expand All @@ -209,7 +204,7 @@ private fun isAvailableForPublication(project: Project, publication: MavenPublic
if (project.extra.has(Properties.SKIP_PUBLISHING)) shouldPublish = false

// Only publish publications with the configured group from JReleaser or everything if JReleaser group is not configured
val publishGroupName = System.getenv(EnvironmentVariables.JReleaser.GROUP_ID)
val publishGroupName = System.getenv(EnvironmentVariables.GROUP_ID)
shouldPublish = shouldPublish && (publishGroupName == null || publication.groupId.startsWith(publishGroupName))

// Validate publication name is allowed to be published
Expand Down
Loading