Repository navigation
Releases
v4
For open-java-format 2.98.0.2 and later.
The version to check with goes in .open-java-format-version at the repository root:
2.98.0.6
- uses: actions/checkout@v7
- uses: openjavaformat/open-java-format-action@v4
with:
mode: ${{ github.event_name == 'push' && 'all' || 'changed' }}What changed since v3
- The
versioninput is gone. The action and the pre-commit hook both read.open-java-format-versionfrom the repository root, so the two cannot drift apart. Without the file, or with something in it that is not a version number, both stop and say what to put there. - The hook no longer pins
FORMATTER_VERSIONat its top. A repository that copied the v3 hook takes the v4 one. - The log warning and the code scanning alert for a newer open-java-format release now point at
.open-java-format-version, line 1.
To move from v3: put the version the workflow passed as version in .open-java-format-version, drop the input, and switch to @v4.
A workflow that pins open-java-format 2.98.0.1 should stay on @v1: that version needs --ojf, which v2 and later do not pass.
v3
For open-java-format 2.98.0.2 and later.
- uses: actions/checkout@v7
- uses: openjavaformat/open-java-format-action@v3
with:
version: '2.98.0.6'
mode: ${{ github.event_name == 'push' && 'all' || 'changed' }}What changed since v2
- The check for a newer open-java-format release can go to code scanning as well as the job log. With
code-scanning: trueand thesecurity-events: writepermission, the action uploads a SARIF file: one alert under Security → Code scanning and in the "Code scanning results" check of a pull request while the version is behind, placed on the line of the workflow that names the version, and closed on its own once the version is updated. This is off by default, so a workflow that does not ask for it runs as before. See Code scanning in the README, which shows a recommended setup with the check in the log alone and one with code scanning too. versiondefaults to 2.98.0.6, and so does the hook'sFORMATTER_VERSION.
A workflow that pins open-java-format 2.98.0.1 should stay on @v1: that version needs --ojf, which v2 and v3 do not pass.
v2
For open-java-format 2.98.0.2 and later.
- uses: actions/checkout@v7
- uses: openjavaformat/open-java-format-action@v2
with:
version: '2.98.0.2'
mode: ${{ github.event_name == 'push' && 'all' || 'changed' }}What changed since v1
- The action and the pre-commit hook no longer pass
--ojf: open-java-format 2.98.0.2 has a single style. Fix files locally withopen-java-format --replace <files>. versiondefaults to 2.98.0.2, and so does the hook'sFORMATTER_VERSION.- Windows runners on x86-64 work, with the Windows binary that 2.98.0.2 ships. The hook runs under Git Bash as well.
actions/cacheinside the action is pinned to a commit SHA, for repositories that require pinned actions.- The CI now runs the action and the hook against a formatted file and one that is not, on Linux and macOS on both architectures and on Windows.
A workflow that pins open-java-format 2.98.0.1 should stay on @v1: that version needs --ojf, which v2 does not pass.
v1
First release of the GitHub Action for open-java-format.
Checks the formatting of Java files with the open-java-format native binary, downloaded from Maven Central — no Java, Maven or Gradle needed on the runner. The same check also comes as a git pre-commit hook.
- uses: actions/checkout@v7
- uses: openjavaformat/open-java-format-action@v1
with:
version: '2.98.0.1'
mode: ${{ github.event_name == 'push' && 'all' || 'changed' }}What's in it
mode: changedchecks only the files of the pull request or push,mode: allchecks every.javafile- Files are checked in the open-java-format style (
--ojf); fix them locally withopen-java-format --ojf --replace <files> - Files matching
.open-java-format-excludein the repository root are skipped, by the action and the hook alike - A warning when a newer open-java-format release is out
- Native binaries for Linux x86_64 and aarch64 (glibc), macOS Apple Silicon and Intel