@@ -16,16 +16,18 @@ import org.gradle.plugins.signing.SigningExtension
1616import org.jreleaser.gradle.plugin.JReleaserExtension
1717import org.jreleaser.model.Active
1818
19- private object SystemProperties {
19+ private object Properties {
2020 const val SKIP_PUBLISHING = " skipPublish"
21+ }
2122
23+ private object EnvironmentVariables {
2224 object JReleaser {
23- const val GROUP_ID = " jreleaser.project.java.group.id "
24- const val MAVEN_CENTRAL_USERNAME = " jreleaser.mavencentral.username "
25- const val MAVEN_CENTRAL_TOKEN = " jreleaser.mavencentral.token "
26- const val GPG_PASSPHRASE = " jreleaser.gpg.passphrase "
27- const val GPG_PUBLIC_KEY = " jreleaser.gpg.public.key "
28- const val GPG_SECRET_KEY = " jreleaser.gpg.secret.key "
25+ const val GROUP_ID = " JRELEASER_PROJECT_JAVA_GROUP_ID "
26+ const val MAVEN_CENTRAL_USERNAME = " JRELEASER_MAVENCENTRAL_USERNAME "
27+ const val MAVEN_CENTRAL_TOKEN = " JRELEASER_MAVENCENTRAL_TOKEN "
28+ const val GPG_PASSPHRASE = " JRELEASER_GPG_PASSPHRASE "
29+ const val GPG_PUBLIC_KEY = " JRELEASER_GPG_PUBLIC_KEY "
30+ const val GPG_SECRET_KEY = " JRELEASER_GPG_SECRET_KEY "
2931 }
3032}
3133
@@ -52,7 +54,7 @@ private val ALLOWED_PUBLICATION_NAMES = setOf(
5254 * Mark this project as excluded from publishing
5355 */
5456fun Project.skipPublishing () {
55- extra.set(SystemProperties .SKIP_PUBLISHING , true )
57+ extra.set(Properties .SKIP_PUBLISHING , true )
5658}
5759
5860/* *
@@ -111,12 +113,15 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = "
111113 }
112114 }
113115
114- if (project.hasProperty(SystemProperties .JReleaser .GPG_SECRET_KEY ) && project.hasProperty(SystemProperties .JReleaser .GPG_PASSPHRASE )) {
116+ val secretKey = System .getenv(EnvironmentVariables .JReleaser .GPG_SECRET_KEY )
117+ val passphrase = System .getenv(EnvironmentVariables .JReleaser .GPG_PASSPHRASE )
118+
119+ if (! secretKey.isNullOrBlank() && ! passphrase.isNullOrBlank()) {
115120 apply (plugin = " signing" )
116121 extensions.configure<SigningExtension > {
117122 useInMemoryPgpKeys(
118- project.property( SystemProperties . JReleaser . GPG_SECRET_KEY ) as String ,
119- project.property( SystemProperties . JReleaser . GPG_PASSPHRASE ) as String ,
123+ secretKey ,
124+ passphrase ,
120125 )
121126 sign(publications)
122127 }
@@ -140,7 +145,7 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = "
140145 }
141146
142147 /*
143- Creates a dummy JAR for the version catalog
148+ Creates a placeholder JAR for the version catalog
144149 The `version-catalog` plugin doesn't generate one because it isn't needed but JReleaser requires a jar for publishing
145150 https://docs.gradle.org/current/userguide/version_catalogs.html#sec:version-catalog-plugin
146151
@@ -159,21 +164,20 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = "
159164fun Project.configureJReleaser () {
160165 verifyRootProject { " JReleaser configuration must be applied to the root project only" }
161166
162- var missingSystemProperties = false
167+ var missingVariables = false
163168 listOf (
164- SystemProperties .JReleaser .GROUP_ID ,
165- SystemProperties .JReleaser .MAVEN_CENTRAL_USERNAME ,
166- SystemProperties .JReleaser .MAVEN_CENTRAL_TOKEN ,
167- SystemProperties .JReleaser .GPG_PASSPHRASE ,
168- SystemProperties .JReleaser .GPG_PUBLIC_KEY ,
169- SystemProperties .JReleaser .GPG_SECRET_KEY ,
169+ EnvironmentVariables .JReleaser .MAVEN_CENTRAL_USERNAME ,
170+ EnvironmentVariables .JReleaser .MAVEN_CENTRAL_TOKEN ,
171+ EnvironmentVariables .JReleaser .GPG_PASSPHRASE ,
172+ EnvironmentVariables .JReleaser .GPG_PUBLIC_KEY ,
173+ EnvironmentVariables .JReleaser .GPG_SECRET_KEY ,
170174 ).forEach {
171- if (! project.hasProperty (it)) {
172- missingSystemProperties = true
173- logger.warn(" Skipping JReleaser configuration, missing required system property : $it " )
175+ if (System .getenv (it).isNullOrBlank( )) {
176+ missingVariables = true
177+ logger.warn(" Skipping JReleaser configuration, missing required environment variable : $it " )
174178 }
175179 }
176- if (missingSystemProperties ) return
180+ if (missingVariables ) return
177181
178182 // Get SDK version from gradle.properties
179183 val sdkVersion: String by project
@@ -205,10 +209,10 @@ private fun isAvailableForPublication(project: Project, publication: MavenPublic
205209 var shouldPublish = true
206210
207211 // Check SKIP_PUBLISH_PROP
208- if (project.extra.has(SystemProperties .SKIP_PUBLISHING )) shouldPublish = false
212+ if (project.extra.has(Properties .SKIP_PUBLISHING )) shouldPublish = false
209213
210- // Validate publishGroupName
211- val publishGroupName = System .getenv(SystemProperties .JReleaser .GROUP_ID )
214+ // Only publish publications with the configured group from JReleaser or everything if JReleaser group is not configured
215+ val publishGroupName = System .getenv(EnvironmentVariables .JReleaser .GROUP_ID )
212216 shouldPublish = shouldPublish && (publishGroupName == null || publication.groupId.startsWith(publishGroupName))
213217
214218 // Validate publication name is allowed to be published
0 commit comments