From 82ecfa7b58173c4c288c1e54ff7b16586d7aa8a6 Mon Sep 17 00:00:00 2001 From: Alex Abashev Date: Mon, 30 Nov 2026 23:17:10 +0300 Subject: [PATCH 1/3] Release the 17 line by tag: the jars, the Gradle plugins and a draft GitHub release A tag runs the release workflow of its commit, so a 17.x tag runs this one. It publishes the jars as one deployment, the Gradle plugins once Maven Central serves the jars, and a draft GitHub release with the runnable jar and the Gradle plugins' jar, all built on JDK 17. The native images, the .deb packages, the WebAssembly module and the JetBrains Marketplace stay with the 21 line, and so do -PreleaseTarget=native and the IntelliJ change notes: the release notes are the GitHub release's text alone. The first job refuses a tag that is not a 17.x, and every other job waits for it. The GitHub release attaches to 17.X.X and is not made the latest; GitHub ignores that for a draft, so the draft is published with "Set as the latest release" unchecked. --- .github/workflows/release.yml | 442 +++--------------- ...pen-java-format.release-conventions.gradle | 93 +--- 2 files changed, 73 insertions(+), 462 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4546aa7e..a692a930 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,26 +1,21 @@ name: Release # Tags only, and the tag is the version: the build reads it from GITHUB_REF_NAME, and jreleaserDeploy and -# publishPlugins refuse anything that is not a clean X.Y.Z or X.Y.Z.N. +# publishPlugins refuse anything that is not a clean X.Y.Z or X.Y.Z.N. A tag runs the workflow of the commit it +# points at, so this one releases the 17 line, and it refuses a tag that is not a 17.x. # -# Two deployments per tag, because a published groupId:artifactId:version can never gain files -# afterwards: the jars go up as one, and every platform's native binary as another. Each is uploaded and -# validated first, and the publish job publishes both only once both are in. A version whose native build -# fails publishes nothing, and its deployments can be dropped in the Portal. +# The 17 line publishes the jars, built on JDK 17, as one deployment: uploaded and validated first, and published +# once the release notes are in. Once Maven Central serves the jars, the Gradle plugins go to the Gradle Plugin +# Portal, signed with the same release key, and a draft GitHub release on the tag collects the runnable jar and the +# Gradle plugins' jar. No native image, IDE plugin, .deb package or WebAssembly module: those come with the 21 line, +# and the Gradle plugin runs the 21 line's native image through openjavaformat.native.formatter.version. # -# Once Maven Central serves both, the Gradle plugins go to the Gradle Plugin Portal, signed with the same -# release key, and the IntelliJ plugin goes to the JetBrains Marketplace, verified against the IDEs it -# supports first. After publishing, a draft GitHub release on the tag collects the runnable jar, the Gradle -# and IDE plugins, the native binaries, the Linux binaries again as .deb packages, and the WebAssembly module, -# which a job of its own builds on Oracle GraalVM. +# The release notes, release-notes/.md, are on the tag before it is pushed: they are the text of the +# GitHub release, and a tag without them publishes nothing. # -# The release notes, release-notes/.md, are on the tag before it is pushed: they are the text of -# the GitHub release and the IntelliJ plugin's change notes, and a tag without them publishes nothing. -# -# Needs seven repository secrets: JRELEASER_MAVENCENTRAL_USERNAME and JRELEASER_MAVENCENTRAL_PASSWORD (the -# Central Portal user token), JRELEASER_GPG_SECRET_KEY and JRELEASER_GPG_PASSPHRASE, GRADLE_PUBLISH_KEY and -# GRADLE_PUBLISH_SECRET (the Gradle Plugin Portal key) and JETBRAINS_MARKETPLACE_TOKEN (a permanent token of -# the Marketplace account that owns the plugin). The draft release uses the workflow's own GITHUB_TOKEN. +# Needs six repository secrets: JRELEASER_MAVENCENTRAL_USERNAME and JRELEASER_MAVENCENTRAL_PASSWORD (the +# Central Portal user token), JRELEASER_GPG_SECRET_KEY and JRELEASER_GPG_PASSPHRASE, and GRADLE_PUBLISH_KEY and +# GRADLE_PUBLISH_SECRET (the Gradle Plugin Portal key). The draft release uses the workflow's own GITHUB_TOKEN. on: push: tags: @@ -34,12 +29,7 @@ concurrency: cancel-in-progress: false jobs: - # The release notes are the IntelliJ plugin's change notes, which the Marketplace shows for the version and - # the IDE under What's New, and the Marketplace never lets the change notes of an uploaded version change: so - # the publish job waits for this one. The IDE does not render Markdown. GitHub's Markdown API renders the - # notes as GitHub renders a release, with the runner's gh and jq, so the build needs no converter; sed then - # drops the attributes GitHub adds for its own pages, such as its hovercards'. release-notes/README.md says - # how to write them. + # The tag and its notes, before anything goes up: every other job waits for this one. release-notes: name: release notes runs-on: ubuntu-latest @@ -48,12 +38,22 @@ jobs: with: persist-credentials: false - # The shell named, since only then does GitHub run bash with pipefail: a failed gh api fails the step - # instead of leaving sed an empty file. - - name: Render the release notes for the IDE - shell: bash + # A tag runs the release workflow of its commit, so a 21.x tag on a commit of this line would release the + # 17 line's jars under a version of the 21 line. + - name: Refuse a tag of another release line + env: + VERSION: ${{ github.ref_name }} + run: | + case "$VERSION" in + 17.*) ;; + *) + echo "::error::${VERSION} is not a version of the 17 line, whose tags are 17.." + exit 1 + ;; + esac + + - name: Check the release notes env: - GH_TOKEN: ${{ github.token }} VERSION: ${{ github.ref_name }} run: | notes="release-notes/${VERSION}.md" @@ -61,22 +61,10 @@ jobs: echo "::error::No release notes for ${VERSION}: add ${notes} to the release line, then move the tag onto that commit" exit 1 fi - mkdir change-notes - jq --null-input --rawfile text "$notes" '{text: $text, mode: "gfm"}' \ - | gh api markdown --input - \ - | sed -E 's/ (dir|class|rel|data-[a-z-]+)="[^"]*"//g' > change-notes/change-notes.html - cat change-notes/change-notes.html - - - name: Hand the change notes to the IntelliJ plugin's jobs - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: change-notes - path: change-notes/change-notes.html - if-no-files-found: error - retention-days: 1 jars: name: jars + needs: release-notes runs-on: ubuntu-latest outputs: deployment-id: ${{ steps.deployment.outputs.id }} @@ -86,11 +74,11 @@ jobs: fetch-depth: 0 persist-credentials: false - - name: Install JDK 21 + - name: Install JDK 17 uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0 with: distribution: temurin - java-version: '21' + java-version: '17' - name: Stage, sign and upload the jars run: ./gradlew jreleaserDeploy @@ -119,264 +107,28 @@ jobs: if-no-files-found: ignore retention-days: 7 - # One job per platform, as in ci.yml, but here each one hands its binary to the deploy job below - # instead of throwing it away. macOS on Apple silicon is built here only: ci.yml leaves it out. - native-images: - name: native image (${{ matrix.runner }}) - runs-on: ${{ matrix.runner }} - timeout-minutes: 90 - # bash on Windows too, as in ci.yml. - defaults: - run: - shell: bash - strategy: - fail-fast: false - matrix: - # The images of ci.yml: Linux on the previous Ubuntu LTS, for an older glibc, the rest the newest. - runner: - - ubuntu-24.04 - - ubuntu-24.04-arm - - macos-latest - - macos-26-intel - - windows-latest - - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - # The Java 21 toolchain for the jars, through JDK21_HOME, as in ci.yml: Gradle does not find the - # runner's own JDK 21 on Windows. Installed before GraalVM, so that Gradle still runs on GraalVM. - - name: Install JDK 21 for the jars - id: jdk21 - uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0 - with: - distribution: temurin - java-version: '21' - - - name: Install GraalVM 25 for the image - uses: graalvm/setup-graalvm@60e76998d25690099182b796e99b8804da582d90 # v1.6.10 - with: - java-version: '25' - distribution: 'graalvm-community' - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Compile the native image - run: ./gradlew -PnativeImage=true :open-java-format-native:nativeCompile - env: - JDK21_HOME: ${{ steps.jdk21.outputs.path }} - - - name: Hand the binary to the deploy job - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: native-image-${{ matrix.runner }} - path: | - open-java-format-native/build/native/nativeCompile/open-java-format-* - !open-java-format-native/build/native/nativeCompile/*.txt - if-no-files-found: error - retention-days: 1 - - # The Linux binaries as .deb packages, for the GitHub release and for the apt repository, openjavaformat/apt, - # which serves the packages of the newest release. Each is built on the runner its binary was built on and - # installed with apt on the oldest Ubuntu and Debian it supports before it goes into the release, by the - # deb-package action that ci.yml runs too. The time of the tag's commit is the time of every file in a - # package, so a re-run makes the same bytes. - deb-packages: - name: deb package (${{ matrix.runner }}) - needs: native-images - runs-on: ${{ matrix.runner }} - strategy: - fail-fast: false - matrix: - runner: - - ubuntu-24.04 - - ubuntu-24.04-arm - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - name: Collect the binary - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - name: native-image-${{ matrix.runner }} - path: native-image - - - name: Find the binary - id: binary - run: | - echo "path=$(ls native-image/open-java-format-linux-glibc_*)" >> "$GITHUB_OUTPUT" - echo "SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)" >> "$GITHUB_ENV" - - - name: Package and install the binary - uses: $/.github/actions/deb-package - with: - binary: ${{ steps.binary.outputs.path }} - version: ${{ github.ref_name }} - out-dir: deb-package - - - name: Hand the package to the GitHub release - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: deb-package-${{ matrix.runner }} - path: deb-package/*.deb - if-no-files-found: error - retention-days: 1 - - # Not `native`: ci.yml already has a job with that id, and `act --job native` could not tell them apart. - native-deploy: - name: native deploy - needs: native-images - runs-on: ubuntu-latest - outputs: - deployment-id: ${{ steps.deployment.outputs.id }} - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Install JDK 21 - uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0 - with: - distribution: temurin - java-version: '21' - - # merge-multiple: every platform's binary lands in one directory under the name it was built - # with, which is where its Maven classifier is read from. - - name: Collect every platform's binary - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - path: native-images - pattern: native-image-* - merge-multiple: true - - - name: Show what was collected - run: ls -l native-images - - # No GraalVM here: nothing is compiled, the binaries are uploaded exactly as they arrived. - - name: Stage, sign and upload the native images - run: ./gradlew -PreleaseTarget=native -PnativeImages=native-images jreleaserDeploy - env: - JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} - JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }} - JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} - JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} - - - name: Hand the deployment to the publish job - id: deployment - run: | - id="$(sed -n 's/^deployMavenCentralSonatypeDeploymentId=//p' build/jreleaser/output.properties)" - if [ -z "$id" ]; then - echo "No deployment ID in build/jreleaser/output.properties" - exit 1 - fi - echo "id=$id" >> "$GITHUB_OUTPUT" - - - name: Keep JReleaser's log - if: ${{ failure() }} - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: jreleaser-log-native - path: build/jreleaser/trace.log - if-no-files-found: ignore - retention-days: 7 - - # The formatter as a WebAssembly module, for the playground on openjavaformat.dev. Built on Oracle GraalVM, the - # only distribution with the Web Image backend (native-image --tool:svm-wasm), and tested in Node against the - # runnable jar of the same tag. Maven Central does not carry it, so only the draft GitHub release waits for it: a - # failure here holds back nothing else, and "Re-run failed jobs" builds it again and then opens the draft. - wasm: - name: wasm - runs-on: ubuntu-latest - timeout-minutes: 60 - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - # The jars, and the runnable jar the module is compared with, compile with Java 21 through JDK21_HOME, as in - # native-images. Installed before GraalVM, so that Gradle still runs on GraalVM. - - name: Install JDK 21 for the jars - id: jdk21 - uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0 - with: - distribution: temurin - java-version: '21' - - # Pinned to the patch: Web Image is experimental, and its options and output change between releases. - - name: Install Oracle GraalVM 25 for the module - uses: graalvm/setup-graalvm@60e76998d25690099182b796e99b8804da582d90 # v1.6.10 - with: - java-version: '25.0.4' - distribution: 'graalvm' - github-token: ${{ secrets.GITHUB_TOKEN }} - - # Web Image runs wasm-opt from the PATH, and needs Binaryen 119 or later; Ubuntu's package is older. - - name: Install Binaryen - env: - BINARYEN_VERSION: version_133 - BINARYEN_SHA256: 2dc9c7813f5375db93d96ead4b78222fcc3e2677bbb832297af4797782a37489 - run: | - archive="binaryen-${BINARYEN_VERSION}-x86_64-linux.tar.gz" - curl --fail --silent --show-error --location --output "${RUNNER_TEMP}/${archive}" \ - "https://github.com/WebAssembly/binaryen/releases/download/${BINARYEN_VERSION}/${archive}" - echo "${BINARYEN_SHA256} ${RUNNER_TEMP}/${archive}" | sha256sum --check - tar -xzf "${RUNNER_TEMP}/${archive}" -C "${RUNNER_TEMP}" - echo "${RUNNER_TEMP}/binaryen-${BINARYEN_VERSION}/bin" >> "$GITHUB_PATH" - - # The tests run the module as a page does, and Node 24 has the WebAssembly GC and exception handling it needs. - # No cache: the tests install no packages, and a release must not restore one another run could have written. - - name: Install Node.js 24 for the tests - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: '24' - package-manager-cache: false - - # wasmTest: the smoke test, then every Java 21 and Java 25 test case's input against the runnable jar. - - name: Build and test the module - run: ./gradlew -Pwasm=true :open-java-format-wasm:wasmTest :open-java-format-wasm:wasmZip - env: - JDK21_HOME: ${{ steps.jdk21.outputs.path }} - - - name: Hand the module to the GitHub release - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: wasm-module - path: open-java-format-wasm/build/distributions/open-java-format-wasm-*.zip - if-no-files-found: error - retention-days: 1 - - # Both deployments are uploaded and validated by now, and the release notes rendered. Publishing one is a - # JReleaser run given its ID, which builds nothing. One leg per deployment, so that a re-run repeats only - # the leg that failed. + # The deployment is uploaded and validated by now, and the release notes are in. Publishing it is a JReleaser run + # given its ID, which builds nothing. publish: - name: publish (${{ matrix.deployment }}) - needs: [jars, native-deploy, release-notes] + name: publish + needs: [jars, release-notes] runs-on: ubuntu-latest - strategy: - matrix: - include: - - deployment: jars - id: ${{ needs.jars.outputs.deployment-id }} - - deployment: native - id: ${{ needs.native-deploy.outputs.deployment-id }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - - name: Install JDK 21 + - name: Install JDK 17 uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0 with: distribution: temurin - java-version: '21' + java-version: '17' - name: Publish the deployment run: ./gradlew jreleaserDeploy env: - JRELEASER_MAVENCENTRAL_DEPLOYMENT_ID: ${{ matrix.id }} + JRELEASER_MAVENCENTRAL_DEPLOYMENT_ID: ${{ needs.jars.outputs.deployment-id }} JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} JRELEASER_DEPLOY_MAVEN_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.JRELEASER_MAVENCENTRAL_PASSWORD }} JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} @@ -386,14 +138,13 @@ jobs: if: ${{ failure() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: jreleaser-log-publish-${{ matrix.deployment }} + name: jreleaser-log-publish path: build/jreleaser/trace.log if-no-files-found: ignore retention-days: 7 - # The plugins depend on the version's jars and native images, so they go up only once Maven Central - # serves both, which takes some minutes after the publish job. The Gradle Plugin Portal never takes a - # version back. + # The plugins depend on the version's jars, so they go up only once Maven Central serves them, which takes some + # minutes after the publish job. The Gradle Plugin Portal never takes a version back. gradle-plugins: name: Gradle plugins needs: publish @@ -405,22 +156,20 @@ jobs: fetch-depth: 0 persist-credentials: false - - name: Install JDK 21 + - name: Install JDK 17 uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0 with: distribution: temurin - java-version: '21' + java-version: '17' - name: Wait for Maven Central to serve the version env: VERSION: ${{ github.ref_name }} run: | - for artifact in open-java-format open-java-format-native; do - url="https://repo1.maven.org/maven2/dev/openjavaformat/${artifact}/${VERSION}/${artifact}-${VERSION}.pom" - until curl --silent --fail --head --output /dev/null "$url"; do - echo "Waiting for ${url}" - sleep 30 - done + url="https://repo1.maven.org/maven2/dev/openjavaformat/open-java-format/${VERSION}/open-java-format-${VERSION}.pom" + until curl --silent --fail --head --output /dev/null "$url"; do + echo "Waiting for ${url}" + sleep 30 done - name: Sign and publish the Gradle plugins @@ -431,63 +180,14 @@ jobs: JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} - # The IntelliJ plugin carries the formatter jars inside its zip, so it does not wait for Maven Central. It - # waits for the publish job like everything else, so that a version whose jars or native images failed - # stays off the Marketplace too. The plugin is checked against the IDEs it declares support for before it - # goes up; a plugin that fails there would fail JetBrains' own check after the upload anyway. The - # Marketplace never takes a version back and rejects a version it already has, so a re-run of this job - # fails once the upload went through. - jetbrains-plugin: - name: JetBrains Marketplace - needs: [publish, release-notes] - runs-on: ubuntu-latest - timeout-minutes: 60 - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Install JDK 21 - uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0 - with: - distribution: temurin - java-version: '21' - - - name: Collect the change notes - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - name: change-notes - path: change-notes - - # Both runs get the change notes, so that the zip verified is the zip uploaded: without them in one, - # patchPluginXml would run again and build another. - - name: Verify the plugin against the IDEs it supports - run: ./gradlew -PchangeNotes=change-notes/change-notes.html :open-java-format-idea-plugin:verifyPlugin - - - name: Keep the verifier's report - if: ${{ failure() }} - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: plugin-verifier-report - path: open-java-format-idea-plugin/build/reports/pluginVerifier - if-no-files-found: ignore - retention-days: 7 - - - name: Upload the plugin - run: ./gradlew -PchangeNotes=change-notes/change-notes.html :open-java-format-idea-plugin:publishPlugin - env: - JETBRAINS_MARKETPLACE_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }} - - # What Maven Central does not carry — the runnable formatter jar, the Gradle plugins' jar, the IntelliJ - # plugin zip, the Eclipse plugin jar, every platform's native binary as a plain download, the .deb - # packages and the WebAssembly module — goes into a draft GitHub release on the tag, each file signed with - # the release key. Its text is release-notes/.md, and the plugin zip has the same change notes as - # the one on the Marketplace. Only once both deployments are published and the packages and the module are - # built; publishing the draft is a click on GitHub, and a re-run fails while a release for the tag exists. + # What Maven Central does not carry, the runnable formatter jar and the Gradle plugins' jar, goes into a draft + # GitHub release on the tag, each file signed with the release key, plus a checksum file. Its text is + # release-notes/.md. Only once the deployment is published; publishing the draft is a click on GitHub, + # with "Set as the latest release" unchecked, so that the latest release stays the 21 line's. A re-run fails while + # a release for the tag exists. github-release: name: draft GitHub release - needs: [publish, deb-packages, wasm, release-notes] + needs: [publish, release-notes] runs-on: ubuntu-latest permissions: contents: write @@ -497,42 +197,14 @@ jobs: fetch-depth: 0 persist-credentials: false - - name: Install JDK 21 + - name: Install JDK 17 uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0 with: distribution: temurin - java-version: '21' - - - name: Collect every platform's binary - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - path: native-images - pattern: native-image-* - merge-multiple: true - - - name: Collect the .deb packages - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - path: deb-packages - pattern: deb-package-* - merge-multiple: true - - - name: Collect the WebAssembly module - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - name: wasm-module - path: wasm-module - - - name: Collect the change notes - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - name: change-notes - path: change-notes + java-version: '17' - - name: Build the plugins and open the draft release - run: >- - ./gradlew -PreleaseTarget=github -PnativeImages=native-images -PdebPackages=deb-packages - -PwasmModule=wasm-module -PchangeNotes=change-notes/change-notes.html jreleaserRelease + - name: Build the jars and open the draft release + run: ./gradlew -PreleaseTarget=github jreleaserRelease env: JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} diff --git a/buildSrc/src/main/groovy/open-java-format.release-conventions.gradle b/buildSrc/src/main/groovy/open-java-format.release-conventions.gradle index b9f68601..f2758167 100644 --- a/buildSrc/src/main/groovy/open-java-format.release-conventions.gradle +++ b/buildSrc/src/main/groovy/open-java-format.release-conventions.gradle @@ -6,26 +6,19 @@ plugins { id 'org.jreleaser' } -// Two deployments, one version. A published groupId:artifactId:version can never gain files, so every -// platform's native binary has to travel in a single deployment — and those binaries come from one CI -// job per platform, long after the jars are staged. `-PreleaseTarget=native` deploys the binaries those jobs -// collected, the default deploys the jars; on a tag both read the same version from it. +// One deployment, the jars: the 17 line publishes no native image, which comes with the 21 line. // // `-PreleaseTarget=github` deploys nothing. It is for `jreleaserRelease`, which opens a draft GitHub -// release on the tag with what Maven Central does not carry — the runnable formatter jar, the Gradle -// plugins' jar, the IntelliJ plugin zip, the Eclipse plugin jar, every platform's native binary as a -// plain download, the Linux binaries as .deb packages, and the WebAssembly module for openjavaformat.dev's -// playground — each file signed, plus a checksum file. Its text is release-notes/.md. +// release on the tag with what Maven Central does not carry — the runnable formatter jar and the Gradle +// plugins' jar — each file signed, plus a checksum file. Its text is release-notes/.md. // // Publishing is a run of its own: with JRELEASER_MAVENCENTRAL_DEPLOYMENT_ID set, JReleaser publishes that // deployment, which an earlier run uploaded and the Portal validated, and nothing is built. The ID has to -// be an environment variable: JReleaser 1.26 drops a deploymentId set in the DSL. The release workflow -// uploads both deployments first and publishes them only once both are in, so a version whose native -// build fails publishes nothing. +// be an environment variable: JReleaser 1.26 drops a deploymentId set in the DSL. // // gradle-open-java-format is not deployed here: the release workflow publishes its plugins to the Gradle -// Plugin Portal once Maven Central serves the jars and native images they depend on. The GitHub release -// carries its jar too, built from the same tag. +// Plugin Portal once Maven Central serves the jars they depend on. The GitHub release carries its jar too, +// built from the same tag. def releaseTarget = providers.gradleProperty('releaseTarget').getOrElse('jars') def deploymentToPublish = providers.environmentVariable('JRELEASER_MAVENCENTRAL_DEPLOYMENT_ID').getOrNull() def releasedProjects @@ -35,60 +28,15 @@ if (releaseTarget == 'jars') { ':open-java-format', ':open-java-format-jdk-bootstrap', ] -} else if (releaseTarget == 'native') { - releasedProjects = [':open-java-format-native'] } else if (releaseTarget == 'github') { releasedProjects = [] } else { - throw new GradleException("Unknown -PreleaseTarget=${releaseTarget}: use 'jars', 'native' or 'github'") + throw new GradleException("Unknown -PreleaseTarget=${releaseTarget}: use 'jars' or 'github'") } def stagingRepositories = releasedProjects.collect { path -> relativePath(project(path).layout.buildDirectory.dir('staging-deploy')) } -// The GitHub release takes the binaries the per-platform jobs collected from -PnativeImages=, exactly -// as the native deployment does, the .deb packages built from the Linux ones from -PdebPackages=, and the -// WebAssembly module's zip that the wasm job built from -PwasmModule=. -def nativeBinaries = [] -def debPackages = [] -def wasmModules = [] -if (releaseTarget == 'github') { - def collectedNativeImages = providers.gradleProperty('nativeImages').getOrNull() - if (collectedNativeImages == null) { - throw new GradleException('-PreleaseTarget=github needs -PnativeImages= holding the native binaries') - } - nativeBinaries = fileTree(file(collectedNativeImages)) { - include 'open-java-format-*' - exclude '**/*.txt' - }.files.sort { it.name } - if (nativeBinaries.isEmpty()) { - throw new GradleException("No native images to release in ${collectedNativeImages}") - } - - def collectedDebPackages = providers.gradleProperty('debPackages').getOrNull() - if (collectedDebPackages == null) { - throw new GradleException('-PreleaseTarget=github needs -PdebPackages= holding the .deb packages') - } - debPackages = fileTree(file(collectedDebPackages)) { - include 'open-java-format_*.deb' - }.files.sort { it.name } - // One per Linux binary: the apt repository serves both architectures or neither. - if (debPackages*.name.collect { it.replaceAll(/.*_/, '') } != ['amd64.deb', 'arm64.deb']) { - throw new GradleException("Expected an amd64 and an arm64 .deb package in ${collectedDebPackages}, found ${debPackages*.name}") - } - - def collectedWasmModule = providers.gradleProperty('wasmModule').getOrNull() - if (collectedWasmModule == null) { - throw new GradleException('-PreleaseTarget=github needs -PwasmModule= holding open-java-format-wasm-.zip') - } - wasmModules = fileTree(file(collectedWasmModule)) { - include 'open-java-format-wasm-*.zip' - }.files.sort { it.name } - if (wasmModules.size() != 1) { - throw new GradleException("Expected one open-java-format-wasm-.zip in ${collectedWasmModule}, found ${wasmModules.size()}") - } -} - // A provider: the root project sets its version only after applying this plugin, and JReleaser reads the // file when its task runs. def releaseNotes = layout.projectDirectory.file(provider { "release-notes/${version}.md" }) @@ -107,7 +55,7 @@ jreleaser { java { groupId = 'dev.openjavaformat' multiProject = true - version = '21' + version = '17' } } } @@ -119,11 +67,14 @@ jreleaser { skipTag = true tagName = '{{projectVersion}}' releaseName = '{{projectVersion}}' - // The current release line; it moves when the next line starts. JReleaser assumes main otherwise, - // and when GitHub has no such branch it tries to push one, which fails from the tag's checkout. - branch = '21.X.X' + // The release line of the tag. JReleaser assumes main otherwise, and when GitHub has no such branch + // it tries to push one, which fails from the tag's checkout. + branch = '17.X.X' // Published by hand after a look. draft = true + // The latest release stays the 21 line's: GitHub ignores this for a draft, so the draft is published + // with "Set as the latest release" unchecked too. + makeLatest = 'FALSE' // The text is release-notes/.md as written; see release-notes/README.md. JReleaser fails // when the file is missing. if (releaseTarget == 'github') { @@ -135,13 +86,8 @@ jreleaser { } // Name templates, not Gradle's version: the root project sets its version only after applying this - // plugin. The jars and the zip are built by the tasks jreleaserRelease depends on below. + // plugin. The jars are built by the tasks jreleaserRelease depends on below. files { - (nativeBinaries + debPackages + wasmModules).each { file -> - artifact { - path = file.absolutePath - } - } if (releaseTarget == 'github') { artifact { path = 'open-java-format/build/libs/open-java-format-{{projectVersion}}-all.jar' @@ -149,12 +95,6 @@ jreleaser { artifact { path = 'gradle-open-java-format/build/libs/gradle-open-java-format-{{projectVersion}}.jar' } - artifact { - path = 'open-java-format-idea-plugin/build/distributions/open-java-format-idea-plugin-{{projectVersion}}.zip' - } - artifact { - path = 'open-java-format-eclipse-plugin/build/libs/open-java-format-eclipse-plugin-{{projectVersion}}.jar' - } } } @@ -204,8 +144,7 @@ tasks.named('jreleaserDeploy') { tasks.named('jreleaserRelease') { if (releaseTarget == 'github') { - dependsOn ':open-java-format:allJar', ':gradle-open-java-format:jar', - ':open-java-format-idea-plugin:buildPlugin', ':open-java-format-eclipse-plugin:jar' + dependsOn ':open-java-format:allJar', ':gradle-open-java-format:jar' } } From 1168c3aec9ab6d6370c178e21b78e72a881f3df9 Mon Sep 17 00:00:00 2001 From: Alex Abashev Date: Mon, 30 Nov 2026 23:17:28 +0300 Subject: [PATCH 2/3] Write the release notes of 17.1.0 The first release of the 17 line: what it carries, what it leaves to the 21 line, and where it formats as 21.1.2 does on JDK 17. The 17 line has no IntelliJ plugin, so its notes are the GitHub release's text alone. --- release-notes/17.1.0.md | 11 +++++++++++ release-notes/README.md | 3 +++ 2 files changed, 14 insertions(+) create mode 100644 release-notes/17.1.0.md diff --git a/release-notes/17.1.0.md b/release-notes/17.1.0.md new file mode 100644 index 00000000..5422982a --- /dev/null +++ b/release-notes/17.1.0.md @@ -0,0 +1,11 @@ +The first release of the 17 line: the formatter and the Gradle plugin of 21.1.2, built for Java 17, for builds that run on JDK 17 to 20. On every file that javac 17 parses, 17.1.0 formats exactly as 21.1.2 does, so a build that checks the format on JDK 17 and on JDK 21 sees one output on both. On JDK 21 and later, use 21.x ([#293](https://github.com/openjavaformat/open-java-format/issues/293)). + +## What the line carries + +- `dev.openjavaformat:open-java-format`, `-spi` and `-jdk-bootstrap` on Maven Central, for Spotless's `palantirJavaFormat` step and for fmt-maven-plugin, and the Gradle plugin `dev.openjavaformat.java-format` with its `-idea`, `-spotless` and `-provider` IDs on the Gradle Plugin Portal. The runnable jar is on this release. +- No native image, IntelliJ or Eclipse plugin, .deb package or WebAssembly module of its own: they do not depend on the JDK a build runs on, and the 21 line's serve builds on JDK 17 too. The Gradle plugin's native formatter takes the version of its image from the new `openjavaformat.native.formatter.version` property; with 17.1.0, set it to `21.1.2` ([#297](https://github.com/openjavaformat/open-java-format/pull/297)). + +## Formatter + +- The syntax of Java 17. Syntax that javac 17 does not parse, such as record patterns and guarded case labels, needs 21.x. +- A semicolon among the imports fails with `extraneous semicolon` at the same place as on 21.1.2, although javac 17 takes it, and an import that only a Javadoc reference to an anchor uses, `{@link Set##anchor}`, stays as on 21.1.2 ([#298](https://github.com/openjavaformat/open-java-format/pull/298)). diff --git a/release-notes/README.md b/release-notes/README.md index dc14159f..691bfc3b 100644 --- a/release-notes/README.md +++ b/release-notes/README.md @@ -11,6 +11,9 @@ The file is used twice, as it is written: Markdown API, as GitHub renders a release. The Marketplace never lets the change notes of an uploaded version change. +The 17 line has no IntelliJ plugin, so there the file is the text of the GitHub release alone; the rules below keep +the two lines' notes alike. + For the notes to read the same in both places: - Write each paragraph and each list item on one line. GitHub renders a release with a line break at every newline, From 833b28945246663bcd1193941fecd60ae8589a6e Mon Sep 17 00:00:00 2001 From: Alex Abashev Date: Mon, 30 Nov 2026 23:19:23 +0300 Subject: [PATCH 3/3] Describe the 17 line in the README, CLAUDE.md and ADR-002 The README says what the 17 line is for, what it publishes and leaves to the 21 line, how the Gradle plugin runs the 21 line's native image, what reaches it and how long it lives; Versions says how its numbers follow the 21 line's, and building and testing are on JDK 17 alone. CLAUDE.md says so too, with the formatting by the 21 line's runnable jar until 17.1.0 is out and no syntax or API newer than Java 17. ADR-002 notes that the line has no visitor for JDK 21. --- CLAUDE.md | 16 +++-- README.md | 81 +++++++++++--------------- docs/decisions/ADR-002-tests-by-jdk.md | 1 + 3 files changed, 47 insertions(+), 51 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index e2eada00..2de74380 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,19 +1,25 @@ # Working in this repository -Building and testing: the README's "Building and testing locally" section. Gradle runs on the Temurin 21 that -`mise install` provides, `./gradlew check` is what CI runs, and `./gradlew formatDiff` formats the files you changed. +Building and testing: the README's "Building and testing locally" section. This is the 17 line: Gradle, the toolchain +and the tests run on the Temurin 17 that `mise install` provides, and `./gradlew check` is what CI runs. Until 17.1.0 +is out nothing in the build formats the code: format the files you changed with the 21 line's runnable jar on JDK 21, +`java -jar open-java-format-21.1.2-all.jar --replace `. Error Prone, NullAway and Checkstyle do not run here; +the code is checked on 21.X.X and comes here as backports. ## Conventions for new code +- **Java 17.** No syntax or API newer than Java 17: javac 17 rejects them. A `switch` over the types of a sealed + interface is an `instanceof` chain that throws in its last branch. A backport that needs such a change says so in + a paragraph of its commit message, under the original one (`git cherry-pick -x`). - **Collections.** Plain `java.util` types. `List.of`, `List.copyOf`, `Map.of` and `Stream.toList()` give unmodifiable collections; unlike Guava's, `Set.of` and `Map.of` do not keep insertion order, and `contains(null)` on them throws. Guava's `ImmutableList`, `ImmutableMap` and `ImmutableSet` are banned by forbidden-apis (`config/forbidden-apis`), which fails the build, in every module but the SPI: `FormatterService` keeps returning `ImmutableList` for compatibility, and the methods that implement it carry their module's `@SuppressForbidden`. - **Nullability.** One annotation, JSpecify's `org.jspecify.annotations.Nullable`; do not add another `Nullable`, - nor a `NotNull` or `NonNull`: what is not `@Nullable` is non-null, and NullAway checks it. It is a type-use - annotation, so on a nested type it goes before the simple name (`Input.@Nullable Token`), and on an array before - the brackets (`String @Nullable []`). + nor a `NotNull` or `NonNull`: what is not `@Nullable` is non-null, and NullAway checks it on the 21 line. It is a + type-use annotation, so on a nested type it goes before the simple name (`Input.@Nullable Token`), and on an array + before the brackets (`String @Nullable []`). - **Local variables.** `var` wherever the initializer gives the type unchanged, in `for` loops too. Not where it would box a primitive (`for (var n : List)`), and not without an initializer that has a type of its own (a lambda, `null`). diff --git a/README.md b/README.md index 4bd00f75..640a79fa 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,23 @@ and published from this repository. Why the project exists is in the [manifesto](https://openjavaformat.dev/manifesto/). +## The 17 line + +This branch, `17.X.X`, is the formatter and the Gradle plugin built for Java 17, for builds that run on JDK 17 to +20: Maven builds such as those of apache/maven-parent and the Plexus and MojoHaus parents, and Gradle builds whose +daemon runs on JDK 17. On every file that javac 17 parses, a 17.x formats exactly as the 21.x of the same minor +version: 17.1.x as 21.1.x. On JDK 21 and later, use 21.x, from the `21.X.X` branch. + +- **What it publishes.** `open-java-format`, `-spi` and `-jdk-bootstrap` on Maven Central, the Gradle plugin on the + Gradle Plugin Portal, and the runnable jar on the GitHub release. The native image, the IDE plugins, the .deb + packages and the WebAssembly module do not depend on the JDK a build runs on, and come with the 21 line. +- **The Gradle plugin's native formatter.** Set `openjavaformat.native.formatter.version` to the 21 release of the + same minor version, `21.1.2` for 17.1.x, and the plugin runs that native image. Without it the plugin asks for a + native image of its own version, which the 17 line does not publish. +- **What reaches it.** Backports from 21.X.X: changes to the output, and fixes for crashes and security issues. + Syntax newer than Java 17 stays on the 21 line. +- **How long it lives.** As long as large projects build on JDK 17. This README announces its last release. + ## Get started Each page is short and every command on it was run against the published artifacts. @@ -114,8 +131,9 @@ private static void configureResolvedVersionsWithVersionMapping(Project project) A version is three numbers, `..`, and each one answers a question of its own. -- **The first is the Java version the formatter is built for**, 21 today. It moves when the minimum - Java version moves. +- **The first is the Java version the formatter is built for**: 17 on this line, 21 on the main one. + It moves when the minimum Java version moves. The 17 line follows the minor versions of the 21 + line, 17.1.x formats as 21.1.x does, and its third number counts its own releases. - **The second moves with every change to the output**: a fix in wrapping or alignment, a new rule, a new feature. A newer minor version can reformat code that the previous one left alone. - **The third moves with fixes that leave the output alone**: a crash, a regression, an internal @@ -129,54 +147,34 @@ fixes made the output differ from upstream, that numbering lost its meaning. ## Building and testing locally -[mise](https://mise.jdx.dev/) pins the tooling: `mise.toml` installs Temurin 21 and -[act](https://github.com/nektos/act). +This is the 17 line: everything builds and runs on JDK 17. [mise](https://mise.jdx.dev/) pins the +tooling: `mise.toml` installs Temurin 17 and [act](https://github.com/nektos/act). ```bash mise trust && mise install -./gradlew check # what the CI build job runs: the tests, Checkstyle and forbidden-apis +./gradlew check # what the CI build job runs: the tests and forbidden-apis ``` -`-PjavaRuntime=25` runs the same tests on JDK 25, as CI's `jdk` jobs do for 25, 26 and 27, and for -the early-access builds of 28, where value classes are a preview feature and the `value` modifier -tests run. The code is compiled for Java 21 either way. Gradle has to find that JDK: installed with -mise, or named with `-Porg.gradle.java.installations.paths=/path/to/jdk`. +Error Prone, NullAway and Checkstyle do not run on this line: their releases are built for Java 21, +and the code they would check is checked on the 21 line, from which it comes here as backports. The Gradle plugins' tests build their projects with Gradle 9.3.1, the oldest the plugins support. -`-PtestkitGradleVersion=9.8.0` builds them with another, as CI's JDK 27 leg does: 9.3.1 does not run -on Java 27, and 9.8.0 is the oldest release that does. Nothing inside the build downloads a JDK. `gradle.properties` turns toolchain auto-download off and -reads the installations from `JDK21_HOME` and `GRAALVM_HOME`, so a missing JDK is an error you can -read rather than a silent download. +reads the installation from `JDK17_HOME`, so a missing JDK is an error you can read rather than a +silent download. -The native image needs a GraalVM 25 behind `GRAALVM_HOME`. CI installs it with -`graalvm/setup-graalvm` and builds the image in a job of its own: +The released Gradle plugin that formats this repository is built for Java 21, so the 17 line applies +none until 17.1.0 is out. Until then, format the files you change with the 21 line's runnable jar on +JDK 21: ```bash -./gradlew -PnativeImage=true :open-java-format-native:nativeCompile +java -jar open-java-format-21.1.2-all.jar --replace ``` -GraalVM has to come from outside Gradle: unpacking a JDK that Gradle downloaded itself does not -preserve the symlink GraalVM ships at `bin/native-image`, and `nativeCompile` then fails on an empty, -unexecutable file. - -### WebAssembly module - -The playground on openjavaformat.dev runs the formatter in the browser, compiled to WebAssembly by -GraalVM's Web Image backend. CI builds and tests it in its `wasm` job, the release workflow in its -own, and the zip goes on the GitHub release; `./gradlew build` leaves it out. Web Image ships in Oracle GraalVM only, so the -module needs Oracle GraalVM 25 behind `GRAALVM_HOME`, Binaryen 119 or later (`wasm-opt`) on the -`PATH`, and Node.js 24 or later for the tests: - -```bash -./gradlew -Pwasm=true :open-java-format-wasm:wasmTest # build, then test in Node against the runnable jar -./gradlew -Pwasm=true :open-java-format-wasm:wasmDev # a bare page next to the module, to try it -jwebserver -d "$PWD/open-java-format-wasm/build/wasm-dev" -``` - -Without `-Pwasm=true` the subproject is not part of the build at all: it compiles against -`org.graalvm.webimage.api`, a module of Oracle GraalVM that no other JDK has. +The native image, the IntelliJ and Eclipse plugins, the WebAssembly module and the benchmarks are +built on the 21 line. Here they stay in the tree, commented out in `settings.gradle`, so that a +backport that touches them applies as it is. ### Running CI locally @@ -186,18 +184,9 @@ is pushed: ```bash mise run ci:list # what jobs exist mise run ci:lint # dry-run every job: resolves images, actions and steps, executes nothing -mise run ci:build # actually run the linux jar+native build job -mise run ci:native # actually run the linux-aarch64 native job +mise run ci:build # actually run the build job ``` -Two caveats: - -- **act cannot containerise macOS**, so the `macos-26-intel` leg has to be checked by building the - native image on a Mac. -- **On an Apple Silicon host** the `ubuntu-24.04` container runs as arm64, so the job labelled - `ubuntu-latest` produces an aarch64 binary locally. Fine for exercising the workflow, not a - substitute for real CI. - ## License and attribution This project is a fork of [palantir-java-format](https://github.com/palantir/palantir-java-format), diff --git a/docs/decisions/ADR-002-tests-by-jdk.md b/docs/decisions/ADR-002-tests-by-jdk.md index 4161d534..40180455 100644 --- a/docs/decisions/ADR-002-tests-by-jdk.md +++ b/docs/decisions/ADR-002-tests-by-jdk.md @@ -75,3 +75,4 @@ A test that needs a newer JDK says so on its class, and its case files live in a - On JDK 23 and 24 the module-import tests no longer run. - Before a push, the tests run on JDK 21 and 25 locally: `./gradlew test -PjavaRuntime=25 -PtestkitGradleVersion=9.3.1`; a change to the JDK 28 tests also on an early-access build of 28, with `-PjavaRuntime=28 -Porg.gradle.java.installations.paths=`. - Comparing the native binary, which parses JDK 25 code whatever the test JVM, with an in-process surface on `test-cases-java25/` needs a test JVM of 25 or later. +- On the 17 line, `17.X.X`, there is no `Java21InputAstVisitor`: javac 17 cannot compile it, and `Formatter.visitorFor` takes `JavaInputAstVisitor` on every JDK (#298). The classes and folders for JDK 21 and later stay there as they are and skip themselves on JDK 17, so that backports apply to them as they are.