@@ -37,6 +37,7 @@ private object EnvironmentVariables {
3737 const val GPG_PASSPHRASE = " JRELEASER_GPG_PASSPHRASE"
3838 const val GPG_PUBLIC_KEY = " JRELEASER_GPG_PUBLIC_KEY"
3939 const val GPG_SECRET_KEY = " JRELEASER_GPG_SECRET_KEY"
40+ const val GENERIC_TOKEN = " JRELEASER_GENERIC_TOKEN"
4041}
4142
4243internal val ALLOWED_PUBLICATION_NAMES = setOf (
@@ -243,10 +244,7 @@ fun Project.configurePublishing(repoName: String, githubOrganization: String = "
243244 if (! secretKey.isNullOrBlank() && ! passphrase.isNullOrBlank()) {
244245 apply (plugin = " signing" )
245246 extensions.configure<SigningExtension > {
246- useInMemoryPgpKeys(
247- secretKey,
248- passphrase,
249- )
247+ useInMemoryPgpKeys(secretKey, passphrase)
250248 sign(publications)
251249 }
252250
@@ -312,20 +310,19 @@ fun Project.configureNexus(
312310fun Project.configureJReleaser () {
313311 verifyRootProject { " JReleaser configuration must be applied to the root project only" }
314312
315- var missingVariables = false
316- listOf (
313+ val requiredVariables = listOf (
317314 EnvironmentVariables .MAVEN_CENTRAL_USERNAME ,
318315 EnvironmentVariables .MAVEN_CENTRAL_TOKEN ,
319316 EnvironmentVariables .GPG_PASSPHRASE ,
320317 EnvironmentVariables .GPG_PUBLIC_KEY ,
321318 EnvironmentVariables .GPG_SECRET_KEY ,
322- ).forEach {
323- if (System .getenv(it).isNullOrBlank()) {
324- missingVariables = true
325- logger.info(" Skipping JReleaser configuration, missing required environment variable: $it " )
326- }
319+ EnvironmentVariables .GENERIC_TOKEN ,
320+ )
321+
322+ if (! requiredVariables.all { System .getenv(it).isNotBlank() }) {
323+ println (" Skipping JReleaser configuration, missing one or more required environment variables: ${requiredVariables.joinToString()} " )
324+ return
327325 }
328- if (missingVariables) return
329326
330327 // Get SDK version from gradle.properties
331328 val sdkVersion: String by project
@@ -336,23 +333,22 @@ fun Project.configureJReleaser() {
336333 version = sdkVersion
337334 }
338335
336+ // FIXME We're currently signing the artifacts twice. Once using the logic in configurePublishing above,
337+ // and the second time during JReleaser's signing stage.
339338 signing {
340339 active = Active .ALWAYS
341340 armored = true
342341 }
343342
344- // Used for creating a tagged release, uploading files and generating changelogs.
345- // In the future we can set this up to push release tags to GitHub, but for now it's
346- // set up to do nothing.
347- // https://jreleaser.org/guide/latest/reference/release/index.html
343+ // JReleaser requires a releaser to be configured even though we don't use it.
344+ // https://github.com/jreleaser/jreleaser/discussions/1725#discussioncomment-10674529
348345 release {
349346 generic {
350- enabled = true
351347 skipRelease = true
352348 }
353349 }
354350
355- // Used to announce a release to configured announcers.
351+ // We don't announce our releases anywhere
356352 // https://jreleaser.org/guide/latest/reference/announce/index.html
357353 announce {
358354 active = Active .NEVER
@@ -362,14 +358,13 @@ fun Project.configureJReleaser() {
362358 maven {
363359 mavenCentral {
364360 create(" maven-central" ) {
365- active = Active .ALWAYS
366361 url = " https://central.sonatype.com/api/v1/publisher"
367362 stagingRepository(rootProject.layout.buildDirectory.dir(" m2" ).get().toString())
368363 artifacts {
369364 artifactOverride {
370365 artifactId = " version-catalog"
371- jar = false
372- verifyPom = false // jreleaser doesn't understand toml packaging
366+ jar = false // Version catalogs don't produce a JAR
367+ verifyPom = false // JReleaser fails when processing <packaging> toml</packaging> tags: `Unknown packaging: toml`
373368 }
374369 }
375370 maxRetries = 100
@@ -387,20 +382,19 @@ internal fun isAvailableForPublication(project: Project, publication: MavenPubli
387382 // Check SKIP_PUBLISH_PROP
388383 if (project.extra.has(Properties .SKIP_PUBLISHING )) shouldPublish = false
389384
390- // Only publish publications with the configured group from JReleaser, or everything if JReleaser group is not configured
391- val publishGroupName = System .getenv(EnvironmentVariables .GROUP_ID )
392- shouldPublish = shouldPublish && (publishGroupName == null || publication.groupId.equals(publishGroupName, ignoreCase = true ))
393-
385+ // Allow overriding K/N publications for local development
394386 val overrideGroupNameValidation = project.extra.getOrNull<String >(OVERRIDE_KOTLIN_NATIVE_GROUP_NAME_VALIDATION ) == " true"
395387 if (overrideGroupNameValidation) println (" Overriding group name validation for Kotlin/Native publications" )
396388
397- // Validate publication name is allowed to be published
398- shouldPublish = shouldPublish &&
399- (
400- ALLOWED_PUBLICATION_NAMES .any { publication.name.equals(it, ignoreCase = true ) } ||
401- // standard publication
402- (ALLOWED_KOTLIN_NATIVE_PUBLICATION_NAMES .any { publication.name.equals(it, ignoreCase = true ) } && (overrideGroupNameValidation || ALLOWED_KOTLIN_NATIVE_GROUP_NAMES .any { publication.groupId.equals(it, ignoreCase = true ) })) // Kotlin/Native publication
403- )
389+ // Validate publication name
390+ if (publication.name in ALLOWED_PUBLICATION_NAMES ) {
391+ // Standard publication
392+ } else if (publication.name in ALLOWED_KOTLIN_NATIVE_PUBLICATION_NAMES ) {
393+ // Kotlin/Native publication
394+ shouldPublish = shouldPublish && (overrideGroupNameValidation || publication.groupId in ALLOWED_KOTLIN_NATIVE_GROUP_NAMES )
395+ } else {
396+ shouldPublish = false
397+ }
404398
405399 return shouldPublish
406400}
0 commit comments