From e0b00a2591deaef4395a19a44d4bf421023cd373 Mon Sep 17 00:00:00 2001 From: Alex Abashev Date: Tue, 24 Nov 2026 16:56:36 +0300 Subject: [PATCH 1/5] Take the release's text and the plugin's change notes from release-notes/ The JetBrains Marketplace showed no change notes for any version of the IntelliJ plugin: plugin.xml had none, and the Marketplace takes them from plugin.xml alone. Its upload API ignores the notes it is given for an IntelliJ plugin, and the notes of an uploaded version can never change. The release notes, written into the draft GitHub release once the plugin was already up, came too late for it. The release notes now go onto the release line before the tag, as release-notes/.md, and serve both: - The release workflow's new release-notes job fails a tag without them, and the publish job waits for it, so such a tag publishes nothing. The IDE shows change notes as HTML and does not render Markdown, so the job renders them with GitHub's Markdown API, through the runner's gh and jq, with no converter in the build. - The IntelliJ plugin's build takes that HTML as -PchangeNotes= for , in the zip for the Marketplace and in the one on the GitHub release. Without the property plugin.xml has none, as before; with a file that does not exist, the build fails. - JReleaser makes the Markdown the draft release's text, in place of the list of commits, and fails when the file is missing. release-notes/README.md says how to write them so that they read the same on GitHub and in the IDE. --- .github/workflows/release.yml | 82 ++++++++++++++++--- ...pen-java-format.release-conventions.gradle | 15 +++- open-java-format-idea-plugin/build.gradle | 13 +++ release-notes/README.md | 22 +++++ 4 files changed, 118 insertions(+), 14 deletions(-) create mode 100644 release-notes/README.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a4fcefa58..f65c94c05 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,6 +14,9 @@ name: Release # and IDE plugins, the native binaries 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 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 @@ -31,6 +34,47 @@ 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. + release-notes: + name: release notes + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + 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 + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ github.ref_name }} + run: | + notes="release-notes/${VERSION}.md" + if [ ! -s "$notes" ]; then + 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 runs-on: ubuntu-latest @@ -260,11 +304,12 @@ jobs: if-no-files-found: error retention-days: 1 - # Both deployments are uploaded and validated by now. 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. + # 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. publish: name: publish (${{ matrix.deployment }}) - needs: [jars, native-deploy] + needs: [jars, native-deploy, release-notes] runs-on: ubuntu-latest strategy: matrix: @@ -351,7 +396,7 @@ jobs: # fails once the upload went through. jetbrains-plugin: name: JetBrains Marketplace - needs: publish + needs: [publish, release-notes] runs-on: ubuntu-latest timeout-minutes: 60 steps: @@ -366,8 +411,16 @@ jobs: 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 :open-java-format-idea-plugin:verifyPlugin + run: ./gradlew -PchangeNotes=change-notes/change-notes.html :open-java-format-idea-plugin:verifyPlugin - name: Keep the verifier's report if: ${{ failure() }} @@ -379,18 +432,19 @@ jobs: retention-days: 7 - name: Upload the plugin - run: ./gradlew :open-java-format-idea-plugin:publishPlugin + 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, and the # WebAssembly module — goes into a draft GitHub release on the tag, each file signed with the release key. - # Only once both deployments are published and the module is built; publishing the draft is a click on - # GitHub, and a re-run fails while a release for the tag exists. + # 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 module is built; publishing the draft is a + # click on GitHub, and a re-run fails while a release for the tag exists. github-release: name: draft GitHub release - needs: [publish, wasm] + needs: [publish, wasm, release-notes] runs-on: ubuntu-latest permissions: contents: write @@ -419,8 +473,16 @@ jobs: 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 + - name: Build the plugins and open the draft release - run: ./gradlew -PreleaseTarget=github -PnativeImages=native-images -PwasmModule=wasm-module jreleaserRelease + run: >- + ./gradlew -PreleaseTarget=github -PnativeImages=native-images -PwasmModule=wasm-module + -PchangeNotes=change-notes/change-notes.html 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 28663a599..6b0c772f1 100644 --- a/buildSrc/src/main/groovy/open-java-format.release-conventions.gradle +++ b/buildSrc/src/main/groovy/open-java-format.release-conventions.gradle @@ -15,7 +15,7 @@ plugins { // 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 and the WebAssembly module for openjavaformat.dev's playground — each file signed, plus a -// checksum file. +// 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 @@ -75,6 +75,10 @@ if (releaseTarget == 'github') { } } +// 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" }) + jreleaser { dependsOnAssemble = false @@ -106,9 +110,12 @@ jreleaser { branch = '21.X.X' // Published by hand after a look. draft = true - changelog { - formatted = 'ALWAYS' - format = '- {{commitShortHash}} {{commitTitle}}' + // The text is release-notes/.md as written; see release-notes/README.md. JReleaser fails + // when the file is missing. + if (releaseTarget == 'github') { + changelog { + external.set(releaseNotes) + } } } } diff --git a/open-java-format-idea-plugin/build.gradle b/open-java-format-idea-plugin/build.gradle index 9796fb5ab..6b3bebc3e 100644 --- a/open-java-format-idea-plugin/build.gradle +++ b/open-java-format-idea-plugin/build.gradle @@ -84,6 +84,16 @@ dependencies { implementation libs.jspecify } +// The change notes, which the Marketplace shows for the version and the IDE under What's New, are the +// release notes, release-notes/.md. The IDE does not render Markdown, so the release workflow +// renders them to HTML and passes the file as -PchangeNotes=; see .github/workflows/release.yml. +// Every other build leaves plugin.xml without change notes. +def changeNotesPath = providers.gradleProperty('changeNotes').getOrNull() +def changeNotesFile = changeNotesPath == null ? null : rootProject.layout.projectDirectory.file(changeNotesPath) +if (changeNotesFile != null && !changeNotesFile.asFile.isFile()) { + throw new GradleException("-PchangeNotes=${changeNotesPath}: no such file") +} + intellijPlatform { // Bytecode instrumentation (@NotNull assertions, GUI forms) needs the platform's // java-compiler-ant-tasks, whose version the plugin cannot derive from a non-installer @@ -103,6 +113,9 @@ intellijPlatform { name = 'open-java-format' // No description here: patchPluginXml would overwrite the one in plugin.xml, which is the // marketplace listing and is written in HTML. + if (changeNotesFile != null) { + changeNotes = providers.fileContents(changeNotesFile).asText + } ideaVersion { sinceBuild = '242' // JBR 21: the first IDEs that can load this plugin's bytecode untilBuild = provider { null } diff --git a/release-notes/README.md b/release-notes/README.md new file mode 100644 index 000000000..dc14159f5 --- /dev/null +++ b/release-notes/README.md @@ -0,0 +1,22 @@ +# Release notes + +One file per release, named after its tag: `21.1.0.md` for the tag `21.1.0`. It goes onto the release line in a +pull request before the tag is pushed, and the release workflow publishes nothing for a tag without one. + +The file is used twice, as it is written: + +- **The GitHub release.** JReleaser makes it the text of the draft release, which is then published by hand. +- **The IntelliJ plugin's change notes**, which the JetBrains Marketplace shows for the version and the IDE shows + under **What's New**. The IDE does not render Markdown, so the workflow renders the file to HTML with GitHub's + Markdown API, as GitHub renders a release. The Marketplace never lets the change notes of an uploaded version + change. + +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, + and so does the API here. +- Write every link in full, `[#259](https://github.com/openjavaformat/open-java-format/pull/259)`. The IDE gets no + link for a bare `#259` or `@name`, and a relative link leads nowhere outside the repository. +- Keep to paragraphs, `##` headings, lists, links, `code` and **bold**: what the IDE's plugin page shows. + +The release workflow, [`.github/workflows/release.yml`](../.github/workflows/release.yml), has the rest. From b6a7578c12631e7b299824f4e90f607b8ea877f9 Mon Sep 17 00:00:00 2001 From: Alex Abashev Date: Tue, 24 Nov 2026 16:56:36 +0300 Subject: [PATCH 2/5] Write the release notes for 21.1.0 The IntelliJ IDEA plugin formats inside the IDE's JVM and optimizes imports with open-java-format. The formatter, the command line, the build plugins, Eclipse and the library get a line for each change since 21.0.2 that users can see. --- release-notes/21.1.0.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 release-notes/21.1.0.md diff --git a/release-notes/21.1.0.md b/release-notes/21.1.0.md new file mode 100644 index 000000000..838a72a7c --- /dev/null +++ b/release-notes/21.1.0.md @@ -0,0 +1,41 @@ +The IntelliJ IDEA plugin now formats inside the IDE's own JVM, with no process to start for a file, and Optimize Imports sorts and removes imports as open-java-format does, so the IDE and the build agree on imports too. The output differs from 21.0.2 in a few narrow cases, listed under Formatter, so take this release with one reformatting run, in a commit of its own. + +## IntelliJ IDEA plugin + +- Reformat Code and Optimize Imports run the formatter inside the IDE's JVM: 124 ms for a file of 4,026 lines, and 9 ms to fix its imports once warm, where a JVM started for each file took 0.3 s to 1 s. The settings page offers three ways under **Run the formatter**: **In the IDE process**, the default, **In a separate JVM**, on the IDE's runtime, the project SDK or another JDK of the IDE, Java 21 or later, and **Native binary**. A project that had **Use native binary** ticked keeps it ([#223](https://github.com/openjavaformat/open-java-format/issues/223), [#259](https://github.com/openjavaformat/open-java-format/pull/259)). +- Inside the IDE, the javac of the IDE's runtime decides which syntax parses: Java 21 in IntelliJ IDEA 2024.2, Java 25 in 2026.3. A project with newer syntax chooses a separate JVM on a newer JDK. There are no VM options to edit: the plugin opens javac to the formatter alone. Where it cannot, **In the IDE process** is greyed out with the reason under it, and the plugin formats in a separate JVM ([#259](https://github.com/openjavaformat/open-java-format/pull/259)). +- The way to run is saved as `formatterMode` in `.idea/open-java-format.xml`. A plugin older than 21.1.0 that reads the file formats in a JVM of its own ([#259](https://github.com/openjavaformat/open-java-format/pull/259)). +- **Optimize Imports** removes unused imports and sorts the others as the command line does, and so do Reformat Code with "Optimize imports", Actions on Save and "Optimize imports" before a commit. Up to 21.0.2 the IDE's own optimizer laid them out by the IDE's settings, and the build sorted them again ([#222](https://github.com/openjavaformat/open-java-format/issues/222), [#255](https://github.com/openjavaformat/open-java-format/pull/255)). +- Imports the IDE inserts, by auto-import, Alt+Enter or completion, follow open-java-format's layout: single-class imports rather than `.*`, and the static imports first. A project whose `.editorconfig` sets code style properties for Java files keeps those instead ([#255](https://github.com/openjavaformat/open-java-format/pull/255)). +- With "Optimize imports on the fly", typing no longer waits for the formatter in IntelliJ IDEA 2024.2 to 2025.1. From 2025.2 the IDE optimizes imports on the fly, and with Alt+Enter, by its own optimizer, which never asks the plugin: it follows the layout above, but removes an unused `import a.b.*;`, which open-java-format keeps ([#253](https://github.com/openjavaformat/open-java-format/issues/253), [#267](https://github.com/openjavaformat/open-java-format/pull/267)). +- In a project that takes the formatter from its Gradle build, the plugin reads the formatter's version once and closes its jars, so on Windows a build or a cache cleanup no longer fails on a jar the IDE holds. A formatter jar without an `Implementation-Version` no longer fails every format with a `NullPointerException` ([#258](https://github.com/openjavaformat/open-java-format/issues/258), [#264](https://github.com/openjavaformat/open-java-format/pull/264)). +- With debug logging on for `#com.palantir.javaformat`, `idea.log` says how each format and import optimization ended and how long it took ([#265](https://github.com/openjavaformat/open-java-format/pull/265)). + +## Formatter + +- A line comment that starts with `//` and a no-break space, or another Unicode space such as the ideographic space of Japanese comments, keeps it, where a regular space used to go in front of it; code formatted before keeps that space. Two kinds of wrapped comment that changed again on a second run now settle on the first ([google/google-java-format#1530](https://github.com/google/google-java-format/pull/1530) by Liam Miller-Cushon; [#249](https://github.com/openjavaformat/open-java-format/issues/249), [#251](https://github.com/openjavaformat/open-java-format/pull/251)). +- A long string literal under a cast, as the enclosing expression of a qualified `.new` or as the qualifier of a method reference stays whole, as `--skip-reflowing-long-strings` leaves it. It used to fail the whole file with "Something has gone terribly wrong" ([#252](https://github.com/openjavaformat/open-java-format/issues/252), [#256](https://github.com/openjavaformat/open-java-format/pull/256)). +- A Unicode escape in whitespace or in a comment delimiter, and an ignorable character in an identifier or keyword, fail with an error at its line and column, where the error used to point nowhere useful. The output for accepted input does not change ([google/google-java-format#1527](https://github.com/google/google-java-format/pull/1527) by Liam Miller-Cushon; [#244](https://github.com/openjavaformat/open-java-format/issues/244), [#246](https://github.com/openjavaformat/open-java-format/pull/246)). +- A stray `;` between imports fails with `extraneous semicolon` at its line, not with "Imports not contiguous" for the whole file ([google/google-java-format#1528](https://github.com/google/google-java-format/pull/1528) by Liam Miller-Cushon; [#245](https://github.com/openjavaformat/open-java-format/issues/245), [#248](https://github.com/openjavaformat/open-java-format/pull/248)). +- The layout allocates a sixth less, and a file with no long string to reflow skips that work; the output does not change ([#250](https://github.com/openjavaformat/open-java-format/issues/250), [#254](https://github.com/openjavaformat/open-java-format/pull/254), [#269](https://github.com/openjavaformat/open-java-format/pull/269)). + +Javadoc formatting, which only the `formatJavadoc` option of the API turns on; the command line and the plugins leave Javadoc as it is: + +- The `

` tags that end a comment are dropped, and a comment that then fits on one line becomes a one-liner ([#237](https://github.com/openjavaformat/open-java-format/issues/237), [#247](https://github.com/openjavaformat/open-java-format/pull/247)). +- A `

` after a blank line gets no `

` in front of it, which doclint reported as an empty `

` tag ([#268](https://github.com/openjavaformat/open-java-format/issues/268), [#270](https://github.com/openjavaformat/open-java-format/pull/270)). + +## Command line, build plugins and Eclipse + +- Formatting ranges, with `--lines`, `--offset` and `--length` or `--character-ranges`, leaves the imports alone, unused ones too, and reflows long strings only in the code the ranges rewrite. `formatDiff`, Eclipse and IntelliJ IDEA format ranges the same way ([#219](https://github.com/openjavaformat/open-java-format/issues/219), [#220](https://github.com/openjavaformat/open-java-format/pull/220), [#233](https://github.com/openjavaformat/open-java-format/pull/233), [#234](https://github.com/openjavaformat/open-java-format/pull/234)). +- The Maven plugin and the Spotless step write what the command line writes; in 3,865 files that changes one. A file with a stray `;` between imports, which they used to drop, now fails as on the command line ([#220](https://github.com/openjavaformat/open-java-format/pull/220)). +- `formatDiff` on the JVM reflows long strings as it does with the native binary, and no longer fails with "git diff took too long to terminate" on a diff larger than 64 KB ([#232](https://github.com/openjavaformat/open-java-format/pull/232), [#257](https://github.com/openjavaformat/open-java-format/issues/257)). +- The Gradle plugin writes the `.idea` files it changes as IntelliJ IDEA writes them, so the IDE's next save no longer rewrites them, and an empty `min-version` in `externalDependencies.xml` no longer fails the task ([#262](https://github.com/openjavaformat/open-java-format/issues/262), [#266](https://github.com/openjavaformat/open-java-format/pull/266)). +- Format in an Eclipse Java editor wraps a long string in the selection, as `--character-ranges` does ([#235](https://github.com/openjavaformat/open-java-format/pull/235)). + +## Library + +- `Formatter.getFormatReplacements`, `Input.getPositionTokenMap` and `SnippetFormatter.format` return `java.util.List` and Guava's `RangeMap` instead of `ImmutableList` and `ImmutableRangeMap`, so code compiled against 21.0.2 that calls them has to be compiled again. `FormatterService` in the SPI is unchanged ([#202](https://github.com/openjavaformat/open-java-format/issues/202), [#218](https://github.com/openjavaformat/open-java-format/pull/218)). + +## Thanks + +To Liam Miller-Cushon of google-java-format, whose three fixes are ported here, and to [joaonsk203](https://github.com/joaonsk203) and [doomfrawen](https://github.com/doomfrawen), whose pull requests to google-java-format, [#1526](https://github.com/google/google-java-format/pull/1526) and [#1534](https://github.com/google/google-java-format/pull/1534), proposed the two Javadoc changes. From d92782efa3aea01de67dbd75d8a82c687107b402 Mon Sep 17 00:00:00 2001 From: Alex Abashev Date: Tue, 24 Nov 2026 17:09:12 +0300 Subject: [PATCH 3/5] Shorten the release notes for 21.1.0 A few sentences for each part, on what users notice most, and no links: a line for every pull request, each with its issue and pull request, read as a list of commits rather than as release notes. --- release-notes/21.1.0.md | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/release-notes/21.1.0.md b/release-notes/21.1.0.md index 838a72a7c..ac4a02875 100644 --- a/release-notes/21.1.0.md +++ b/release-notes/21.1.0.md @@ -1,41 +1,23 @@ -The IntelliJ IDEA plugin now formats inside the IDE's own JVM, with no process to start for a file, and Optimize Imports sorts and removes imports as open-java-format does, so the IDE and the build agree on imports too. The output differs from 21.0.2 in a few narrow cases, listed under Formatter, so take this release with one reformatting run, in a commit of its own. +The IntelliJ IDEA plugin now formats inside the IDE and optimizes imports with open-java-format. The output differs from 21.0.2 in a few narrow cases, so take this release with one reformatting run, in a commit of its own. ## IntelliJ IDEA plugin -- Reformat Code and Optimize Imports run the formatter inside the IDE's JVM: 124 ms for a file of 4,026 lines, and 9 ms to fix its imports once warm, where a JVM started for each file took 0.3 s to 1 s. The settings page offers three ways under **Run the formatter**: **In the IDE process**, the default, **In a separate JVM**, on the IDE's runtime, the project SDK or another JDK of the IDE, Java 21 or later, and **Native binary**. A project that had **Use native binary** ticked keeps it ([#223](https://github.com/openjavaformat/open-java-format/issues/223), [#259](https://github.com/openjavaformat/open-java-format/pull/259)). -- Inside the IDE, the javac of the IDE's runtime decides which syntax parses: Java 21 in IntelliJ IDEA 2024.2, Java 25 in 2026.3. A project with newer syntax chooses a separate JVM on a newer JDK. There are no VM options to edit: the plugin opens javac to the formatter alone. Where it cannot, **In the IDE process** is greyed out with the reason under it, and the plugin formats in a separate JVM ([#259](https://github.com/openjavaformat/open-java-format/pull/259)). -- The way to run is saved as `formatterMode` in `.idea/open-java-format.xml`. A plugin older than 21.1.0 that reads the file formats in a JVM of its own ([#259](https://github.com/openjavaformat/open-java-format/pull/259)). -- **Optimize Imports** removes unused imports and sorts the others as the command line does, and so do Reformat Code with "Optimize imports", Actions on Save and "Optimize imports" before a commit. Up to 21.0.2 the IDE's own optimizer laid them out by the IDE's settings, and the build sorted them again ([#222](https://github.com/openjavaformat/open-java-format/issues/222), [#255](https://github.com/openjavaformat/open-java-format/pull/255)). -- Imports the IDE inserts, by auto-import, Alt+Enter or completion, follow open-java-format's layout: single-class imports rather than `.*`, and the static imports first. A project whose `.editorconfig` sets code style properties for Java files keeps those instead ([#255](https://github.com/openjavaformat/open-java-format/pull/255)). -- With "Optimize imports on the fly", typing no longer waits for the formatter in IntelliJ IDEA 2024.2 to 2025.1. From 2025.2 the IDE optimizes imports on the fly, and with Alt+Enter, by its own optimizer, which never asks the plugin: it follows the layout above, but removes an unused `import a.b.*;`, which open-java-format keeps ([#253](https://github.com/openjavaformat/open-java-format/issues/253), [#267](https://github.com/openjavaformat/open-java-format/pull/267)). -- In a project that takes the formatter from its Gradle build, the plugin reads the formatter's version once and closes its jars, so on Windows a build or a cache cleanup no longer fails on a jar the IDE holds. A formatter jar without an `Implementation-Version` no longer fails every format with a `NullPointerException` ([#258](https://github.com/openjavaformat/open-java-format/issues/258), [#264](https://github.com/openjavaformat/open-java-format/pull/264)). -- With debug logging on for `#com.palantir.javaformat`, `idea.log` says how each format and import optimization ended and how long it took ([#265](https://github.com/openjavaformat/open-java-format/pull/265)). +Reformat Code and Optimize Imports run the formatter inside the IDE's own JVM, with no process to start, and take milliseconds where a file used to take up to a second. The IDE's Java then decides which syntax parses: Java 21 in IntelliJ IDEA 2024.2, Java 25 in 2026.3. For newer syntax, choose **In a separate JVM** with a newer JDK under **Run the formatter** in the plugin's settings, next to **Native binary**; a project that used the native binary keeps it. -## Formatter - -- A line comment that starts with `//` and a no-break space, or another Unicode space such as the ideographic space of Japanese comments, keeps it, where a regular space used to go in front of it; code formatted before keeps that space. Two kinds of wrapped comment that changed again on a second run now settle on the first ([google/google-java-format#1530](https://github.com/google/google-java-format/pull/1530) by Liam Miller-Cushon; [#249](https://github.com/openjavaformat/open-java-format/issues/249), [#251](https://github.com/openjavaformat/open-java-format/pull/251)). -- A long string literal under a cast, as the enclosing expression of a qualified `.new` or as the qualifier of a method reference stays whole, as `--skip-reflowing-long-strings` leaves it. It used to fail the whole file with "Something has gone terribly wrong" ([#252](https://github.com/openjavaformat/open-java-format/issues/252), [#256](https://github.com/openjavaformat/open-java-format/pull/256)). -- A Unicode escape in whitespace or in a comment delimiter, and an ignorable character in an identifier or keyword, fail with an error at its line and column, where the error used to point nowhere useful. The output for accepted input does not change ([google/google-java-format#1527](https://github.com/google/google-java-format/pull/1527) by Liam Miller-Cushon; [#244](https://github.com/openjavaformat/open-java-format/issues/244), [#246](https://github.com/openjavaformat/open-java-format/pull/246)). -- A stray `;` between imports fails with `extraneous semicolon` at its line, not with "Imports not contiguous" for the whole file ([google/google-java-format#1528](https://github.com/google/google-java-format/pull/1528) by Liam Miller-Cushon; [#245](https://github.com/openjavaformat/open-java-format/issues/245), [#248](https://github.com/openjavaformat/open-java-format/pull/248)). -- The layout allocates a sixth less, and a file with no long string to reflow skips that work; the output does not change ([#250](https://github.com/openjavaformat/open-java-format/issues/250), [#254](https://github.com/openjavaformat/open-java-format/pull/254), [#269](https://github.com/openjavaformat/open-java-format/pull/269)). +**Optimize Imports**, and everything that runs it, such as Actions on Save, now removes and sorts imports as the command line does. Imports the IDE inserts follow the same layout. -Javadoc formatting, which only the `formatJavadoc` option of the API turns on; the command line and the plugins leave Javadoc as it is: +## Formatter -- The `

` tags that end a comment are dropped, and a comment that then fits on one line becomes a one-liner ([#237](https://github.com/openjavaformat/open-java-format/issues/237), [#247](https://github.com/openjavaformat/open-java-format/pull/247)). -- A `

` after a blank line gets no `

` in front of it, which doclint reported as an empty `

` tag ([#268](https://github.com/openjavaformat/open-java-format/issues/268), [#270](https://github.com/openjavaformat/open-java-format/pull/270)). +A line comment that starts with a no-break space or another Unicode space keeps it, and a long string literal under a cast, a qualified `.new` or a method reference no longer fails the whole file. A misplaced Unicode escape and a stray `;` between imports fail with an error at their line. With the `formatJavadoc` option, a comment loses the `

` tags at its end, and a `

` gets no `

` in front of it. ## Command line, build plugins and Eclipse -- Formatting ranges, with `--lines`, `--offset` and `--length` or `--character-ranges`, leaves the imports alone, unused ones too, and reflows long strings only in the code the ranges rewrite. `formatDiff`, Eclipse and IntelliJ IDEA format ranges the same way ([#219](https://github.com/openjavaformat/open-java-format/issues/219), [#220](https://github.com/openjavaformat/open-java-format/pull/220), [#233](https://github.com/openjavaformat/open-java-format/pull/233), [#234](https://github.com/openjavaformat/open-java-format/pull/234)). -- The Maven plugin and the Spotless step write what the command line writes; in 3,865 files that changes one. A file with a stray `;` between imports, which they used to drop, now fails as on the command line ([#220](https://github.com/openjavaformat/open-java-format/pull/220)). -- `formatDiff` on the JVM reflows long strings as it does with the native binary, and no longer fails with "git diff took too long to terminate" on a diff larger than 64 KB ([#232](https://github.com/openjavaformat/open-java-format/pull/232), [#257](https://github.com/openjavaformat/open-java-format/issues/257)). -- The Gradle plugin writes the `.idea` files it changes as IntelliJ IDEA writes them, so the IDE's next save no longer rewrites them, and an empty `min-version` in `externalDependencies.xml` no longer fails the task ([#262](https://github.com/openjavaformat/open-java-format/issues/262), [#266](https://github.com/openjavaformat/open-java-format/pull/266)). -- Format in an Eclipse Java editor wraps a long string in the selection, as `--character-ranges` does ([#235](https://github.com/openjavaformat/open-java-format/pull/235)). +Formatting ranges leaves the imports alone and reflows long strings only in the code it rewrites, the same on the command line, in `formatDiff`, in Eclipse and in IntelliJ IDEA. The Maven plugin and the Spotless step now write what the command line writes, and `formatDiff` no longer fails on a diff larger than 64 KB. ## Library -- `Formatter.getFormatReplacements`, `Input.getPositionTokenMap` and `SnippetFormatter.format` return `java.util.List` and Guava's `RangeMap` instead of `ImmutableList` and `ImmutableRangeMap`, so code compiled against 21.0.2 that calls them has to be compiled again. `FormatterService` in the SPI is unchanged ([#202](https://github.com/openjavaformat/open-java-format/issues/202), [#218](https://github.com/openjavaformat/open-java-format/pull/218)). +`Formatter.getFormatReplacements`, `Input.getPositionTokenMap` and `SnippetFormatter.format` return `java.util.List` and Guava's `RangeMap` instead of `ImmutableList` and `ImmutableRangeMap`, so code that calls them has to be compiled again. ## Thanks -To Liam Miller-Cushon of google-java-format, whose three fixes are ported here, and to [joaonsk203](https://github.com/joaonsk203) and [doomfrawen](https://github.com/doomfrawen), whose pull requests to google-java-format, [#1526](https://github.com/google/google-java-format/pull/1526) and [#1534](https://github.com/google/google-java-format/pull/1534), proposed the two Javadoc changes. +To Liam Miller-Cushon of google-java-format, whose three fixes are ported here, and to joaonsk203 and doomfrawen, whose pull requests to google-java-format proposed the two Javadoc changes. From 01ac706ff4eb8662a089e66c2d7c0f4119184174 Mon Sep 17 00:00:00 2001 From: Alex Abashev Date: Tue, 24 Nov 2026 17:11:14 +0300 Subject: [PATCH 4/5] Link the people thanked in the 21.1.0 notes, and their pull requests --- release-notes/21.1.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-notes/21.1.0.md b/release-notes/21.1.0.md index ac4a02875..6d882278d 100644 --- a/release-notes/21.1.0.md +++ b/release-notes/21.1.0.md @@ -20,4 +20,4 @@ Formatting ranges leaves the imports alone and reflows long strings only in the ## Thanks -To Liam Miller-Cushon of google-java-format, whose three fixes are ported here, and to joaonsk203 and doomfrawen, whose pull requests to google-java-format proposed the two Javadoc changes. +To Liam Miller-Cushon of google-java-format, whose three fixes are ported here, and to [joaonsk203](https://github.com/joaonsk203) and [doomfrawen](https://github.com/doomfrawen), whose pull requests to google-java-format, [#1526](https://github.com/google/google-java-format/pull/1526) and [#1534](https://github.com/google/google-java-format/pull/1534), proposed the two Javadoc changes. From bde6b31b821a5099067ec3c99f13364d9db2aecf Mon Sep 17 00:00:00 2001 From: Alex Abashev Date: Tue, 24 Nov 2026 17:20:57 +0300 Subject: [PATCH 5/5] Say in the plugin's description where Optimize Imports runs The description said that Optimize Imports sorts and removes imports as open-java-format does, but not how to have it on every save, nor what becomes of the imports the IDE adds. It now names Actions on Save, the commit and the Reformat Code dialog, and that inserted imports follow open-java-format's layout unless EditorConfig sets Java code style properties. --- .../src/main/resources/META-INF/plugin.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/open-java-format-idea-plugin/src/main/resources/META-INF/plugin.xml b/open-java-format-idea-plugin/src/main/resources/META-INF/plugin.xml index 49e149ae3..73225c6d8 100644 --- a/open-java-format-idea-plugin/src/main/resources/META-INF/plugin.xml +++ b/open-java-format-idea-plugin/src/main/resources/META-INF/plugin.xml @@ -10,6 +10,7 @@ Formats Java code with open-java-format, a maintained fork of palantir-java-format: 120 columns, 4-space indents and lambda-friendly line breaking.

With the plugin enabled, Reformat Code runs open-java-format instead of the IDE's built-in Java formatter, and Optimize Imports removes unused imports and sorts the others as open-java-format does, so the IDE and your build produce identical files. The IDE's own Java code style settings no longer apply.

+

To format and fix imports on every save, tick Reformat code and Optimize imports under Tools → Actions on Save; Optimize imports before a commit and in the Reformat Code dialog runs open-java-format too. Imports the IDE adds as you type follow the same layout, unless the project's .editorconfig sets Java code style properties.

The formatter runs inside the IDE, with no process to start for a file, whatever version the project SDK is. A project that applies the dev.openjavaformat.java-format Gradle plugin takes the formatter version from the build; every other project uses the version bundled with this plugin.

The plugin's settings page offers two other ways to run it. In a separate JVM runs it on the IDE's runtime, the project SDK or another JDK of the IDE, Java 21 or later, and parses the syntax of that JDK's version. Native binary runs the formatter compiled for your platform, which the plugin downloads, in a Maven, Gradle or any other project; a binary of your own works too.

Requires IntelliJ IDEA 2024.2 or later, or another IDE with Java support such as Android Studio.