Run the native formatter from the Gradle plugin on Windows - #28
Merged
Merged
Conversation
openjavaformat.native.formatter=true now takes effect on Windows on x86-64 too, where 2.98.0.2 published a binary, nativeImage-windows_x86-64.exe. Before, the plugin ignored the property on Windows and ran the Java formatter. ExecutableTransform made that impossible: it asked for POSIX permissions, which a Windows file system does not have, so Files.getPosixFilePermissions would have thrown. It now skips them where the file system has no POSIX view; an .exe needs none to run. It also keeps an .exe name instead of appending .executable, and since the transformed name also names the copy in the IntelliJ IDEA cache, the binary ends in .exe everywhere the plugin hands it on. The tests could not have run on Windows either. The generated build scripts took paths inside Groovy strings, where a Windows backslash starts an escape, so those paths are written with forward slashes. The classpath was split on ':', which cuts a Windows path after its drive letter, so it is split on File.pathSeparator. FormatDiffTest ran bin/java without .exe, where FormatterServicesTest already added it. And the copy of the binary the tests use was renamed to .bin, the artifact type of every other platform, while the plugin resolves the Windows binary as exe, so that copy keeps .exe. The native CI job on Windows now runs the plugin tests against the image, as on the other platforms. On macOS the native job's tests, 8 in jdk-bootstrap and 31 in the Gradle plugin, and ./gradlew test pass. Windows is for CI to show.
The first Windows run of the plugin tests failed three cases, none of them in the native formatter. The Windows checkout gives example1.patch CRLF line endings, so parsing it as git output found no files; git itself prints a diff with LF, so the test now reads the fixture that way. And Spotless writes the platform's line endings, CRLF on Windows, which the Spotless test compared against a text block with LF; it now compares ignoring line endings.
With the fixture read as LF, the second Windows run parsed both files, and the test failed only on how it wrote the expected path: SingleFileDiff keeps a Path, which prints with backslashes on Windows. The expected string now builds that path with Path.of, so it prints the platform's way on every system.
abashev
added a commit
to openjavaformat/docs
that referenced
this pull request
Sep 22, 2026
The plugin now runs the native formatter on Windows x86-64 as well (openjavaformat/open-java-format#28), so the Gradle page and the home page list Windows next to Linux and macOS. The change ships with the next release: until then the 2.98.0.2 plugin ignores the property on Windows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
openjavaformat.native.formatter=truenow takes effect on Windows on x86-64, with the Windows binary that 2.98.0.2 publishes (nativeImage-windows_x86-64.exe). Until now the plugin ignored the property there and ran the Java formatter..exename instead of appending.executable. That name also names the copy in the IntelliJ IDEA cache.File.pathSeparatorinstead of':', FormatDiffTest runsjava.exe, and the test copy of the binary keeps.exe, the artifact type the plugin resolves on Windows.On macOS the native job's tests (8 in jdk-bootstrap, 31 in the Gradle plugin) and
./gradlew testpass. This PR's CI is the first run of these tests on Windows.