diff --git a/docs/about.md b/docs/about.md index 25ce6fc..8f52b99 100644 --- a/docs/about.md +++ b/docs/about.md @@ -13,11 +13,14 @@ project exists is in the [manifesto](manifesto.md). | [Gradle Plugin Portal](https://plugins.gradle.org/plugin/dev.openjavaformat.java-format) | `dev.openjavaformat.java-format` | | [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/34359-open-java-format) | the IntelliJ IDEA plugin | | [GitHub Releases](https://github.com/openjavaformat/open-java-format/releases/latest) | native binaries, the runnable jar, the Gradle, IntelliJ IDEA and Eclipse plugins | +| [Homebrew tap](https://github.com/openjavaformat/homebrew-tap) | `openjavaformat/tap/open-java-format`, the native binary for macOS and Linux | The Maven Central artifacts, the Gradle plugins and the files of a GitHub release are built by the [release workflow](https://github.com/openjavaformat/open-java-format/blob/main/.github/workflows/release.yml) from the tag of the version. The Maven plugin has a repository and a release workflow of its own, -[openjavaformat/fmt-maven-plugin](https://github.com/openjavaformat/fmt-maven-plugin). +[openjavaformat/fmt-maven-plugin](https://github.com/openjavaformat/fmt-maven-plugin). The Homebrew +formula installs the native binaries of the GitHub release: a workflow in the tap moves it to each +new release within the hour, once it has installed and tested it on every platform. ## Versions diff --git a/docs/get-started/command-line.md b/docs/get-started/command-line.md index 138d1cc..60ccca8 100644 --- a/docs/get-started/command-line.md +++ b/docs/get-started/command-line.md @@ -1,7 +1,50 @@ # Command line The formatter comes as a native binary that needs no Java, and as a runnable jar for every platform -the binaries do not cover. +the binaries do not cover. On macOS and Linux, Homebrew installs the binary and keeps it current; +mise installs it on Windows too, and pins its version per project. + +## Homebrew + +``` sh +brew install openjavaformat/tap/open-java-format +open-java-format --version +``` + +The formula comes from our tap, [openjavaformat/homebrew-tap](https://github.com/openjavaformat/homebrew-tap). +It downloads the native binary of the latest release from GitHub, checks it against the release's +checksums and puts `open-java-format` on your `PATH`. It covers macOS on Apple silicon and Intel and +Linux on x86-64 and AArch64; on Windows, run it in WSL or download the binary below. Homebrew fetches +the file with `curl`, so macOS does not quarantine it. + +`brew upgrade` takes each new release, at the latest an hour after it is published. A new minor +version can change the output (see [Versions](../about.md#versions)): `brew pin open-java-format` +holds the installed one. + +## mise + +``` sh +mise use github:openjavaformat/open-java-format@{{ ojf_version }} +open-java-format --version +``` + +[mise](https://mise.jdx.dev) installs the tool from the GitHub release with its +[github backend](https://mise.jdx.dev/dev-tools/backends/github.html): it picks the native binary for +your platform, checks it against the digest GitHub publishes and the release's build attestation, and +puts `open-java-format` on your `PATH`. That works on macOS, on Linux with glibc and on Windows +x86-64. On Windows on ARM and on musl-based Linux it would pick the wrong file, so use the jar there. + +`mise use` writes the version into the project's `mise.toml`, so everyone on the project formats with +the same one: + +``` toml title="mise.toml" +[tools] +"github:openjavaformat/open-java-format" = "{{ ojf_version }}" +``` + +Add `-g` to install it for your user instead of one project. Without a version, `mise use` writes +`latest`, and `mise upgrade` then takes each new release. A new minor version can change the output +(see [Versions](../about.md#versions)), which is why the example pins one. ## Download @@ -17,8 +60,8 @@ Pick the file for your platform from the | Windows, x86-64 | `open-java-format-windows_x86-64.exe` | | Anything else with Java 21 or later | `open-java-format-{{ ojf_version }}-all.jar` | -There is no native binary for Windows on ARM or for musl-based Linux such as Alpine. Use the jar -there. +The Linux binaries need glibc 2.34 or later. There is no native binary for Windows on ARM or for +musl-based Linux such as Alpine. Use the jar there. ``` sh title="Native binary, here for Apple silicon" curl -LO https://github.com/openjavaformat/open-java-format/releases/download/{{ ojf_version }}/open-java-format-macos_aarch64 diff --git a/docs/index.md b/docs/index.md index 95be825..41a1c2f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -155,7 +155,12 @@ on the [Maven plugin](get-started/maven.md) page. ### On the command line Every [release](https://github.com/openjavaformat/open-java-format/releases/latest) carries native -binaries for Linux, macOS and Windows, and a runnable jar for Java 21 or later. +binaries for Linux, macOS and Windows, and a runnable jar for Java 21 or later. On macOS and Linux, +Homebrew installs the binary. + +``` sh title="Install with Homebrew" +brew install openjavaformat/tap/open-java-format +``` ``` sh title="Format files in place" open-java-format --replace src/main/java/com/example/Hello.java