|
| 1 | +// Applied to the root project: signs the staged publications and uploads them to the Maven Central |
| 2 | +// Portal. `mise run release` runs it; `mise run release:dry-run` rehearses without uploading. |
| 3 | +plugins { |
| 4 | + id 'base' |
| 5 | + id 'org.jreleaser' |
| 6 | +} |
| 7 | + |
| 8 | +// What goes to Maven Central. Each of these applies open-java-format.publishing-conventions, which |
| 9 | +// stages its publications in build/staging-deploy. |
| 10 | +// |
| 11 | +// Not released yet: open-java-format-native needs a binary per platform, each from its own CI job, |
| 12 | +// and all of them have to go up in one deployment. |
| 13 | +def releasedProjects = [ |
| 14 | + ':open-java-format-spi', |
| 15 | + ':open-java-format', |
| 16 | + ':open-java-format-jdk-bootstrap', |
| 17 | + ':gradle-open-java-format', |
| 18 | +] |
| 19 | +def stagingRepositories = releasedProjects.collect { path -> |
| 20 | + relativePath(project(path).layout.buildDirectory.dir('staging-deploy')) |
| 21 | +} |
| 22 | + |
| 23 | +jreleaser { |
| 24 | + dependsOnAssemble = false |
| 25 | + |
| 26 | + project { |
| 27 | + name = 'open-java-format' |
| 28 | + description = 'A modern, lambda-friendly, 120-character Java formatter' |
| 29 | + license = 'Apache-2.0' |
| 30 | + links { |
| 31 | + homepage = 'https://github.com/openjavaformat/open-java-format' |
| 32 | + } |
| 33 | + languages { |
| 34 | + java { |
| 35 | + groupId = 'dev.openjavaformat' |
| 36 | + multiProject = true |
| 37 | + version = '21' |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + release { |
| 43 | + github { |
| 44 | + enabled = false |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + // The key comes from JRELEASER_GPG_SECRET_KEY and JRELEASER_GPG_PASSPHRASE, in the environment or in |
| 49 | + // ~/.jreleaser/config.properties. There is no public key to check the signatures against, hence |
| 50 | + // verify = false. |
| 51 | + signing { |
| 52 | + pgp { |
| 53 | + active = 'ALWAYS' |
| 54 | + armored = true |
| 55 | + verify = false |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + deploy { |
| 60 | + maven { |
| 61 | + mavenCentral { |
| 62 | + // The deployer's name selects its credentials — the Central Portal user token, as |
| 63 | + // JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_USERNAME and _PASSWORD. |
| 64 | + sonatype { |
| 65 | + active = 'ALWAYS' |
| 66 | + url = 'https://central.sonatype.com/api/v1/publisher' |
| 67 | + namespace = 'dev.openjavaformat' |
| 68 | + applyMavenCentralRules = true |
| 69 | + stagingRepositories.each { stagingRepository(it) } |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +// A release cannot be taken back, and the version comes from `git describe`: anywhere but a clean |
| 77 | +// checkout of a release tag it reads like 2.97.0-41-gf6667a2d.dirty. Refuse to upload that. |
| 78 | +def releaseVersion = provider { version.toString() } |
| 79 | + |
| 80 | +tasks.named('jreleaserDeploy') { |
| 81 | + releasedProjects.each { path -> |
| 82 | + dependsOn "${path}:publishAllPublicationsToStagingRepository" |
| 83 | + } |
| 84 | + doFirst { |
| 85 | + if (!dryrun.getOrElse(false) && !(releaseVersion.get() ==~ /\d+\.\d+\.\d+/)) { |
| 86 | + throw new GradleException("Refusing to release ${releaseVersion.get()}: check out a release tag on a " |
| 87 | + + 'clean working tree, or pass --dryrun to rehearse without uploading.') |
| 88 | + } |
| 89 | + } |
| 90 | +} |
0 commit comments