# 使用 Homebrew, MacPorts, Nix, scoop 安装 google-java-format

查看 google-java-format 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:google-java-format
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install google-java-format
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install google-java-format
```

  证据: MacPorts ports tree: java/google-java-format/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- Nix (92%):

```sh
nix profile install nixpkgs#google-java-format
```

  证据: nixpkgs package indexes: pkgs/by-name/go/google-java-format/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

### Windows

- Scoop (92%):

```sh
scoop install extras/google-java-format
```

  证据: Scoop official bucket manifest trees: bucket/google-java-format.json from https://api.github.com/repos/ScoopInstaller/Extras/git/trees/master?recursive=1

## 软件包事实

- **软件包键:** brew:google-java-format
- **软件包管理器:** Homebrew
- **版本:** 1.36.1
- **来源摘要:** Reformats Java source code to comply with Google Java Style
- **主页:** <https://github.com/google/google-java-format>
- **仓库:** <https://github.com/google/google-java-format>
- **最后更新:** 2026-07-30T20:58:59Z
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- google-java-format (别名)
- google-java-format-diff (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 1.36.1
## 项目历史与用法

google-java-format is Google's command-line and library implementation of the Google Java Style formatter. The project deliberately avoids user-configurable formatting rules so Java code can be normalized to one Google style across editors, builds, and scripts.

### 项目历史

Google opened the GitHub repository in May 2015 and published a 0.1 Alpha release in November 2015. The 1.0 release followed in April 2016, establishing the formatter as a packaged tool rather than only an internal style convention.

The README describes several integration surfaces around the same formatter engine: a command-line jar or native binary, a diff-oriented helper script, JetBrains and Eclipse plugins, and use as a Java library from Maven or Gradle builds. That shape made the project useful both for individual developer machines and for automated formatting checks.

### 采用历史

Adoption grew through the Java tooling ecosystem because the formatter is intentionally prescriptive. The official README lists third-party integrations for Visual Studio Code, Gradle, Maven, SBT, and GitHub Actions, showing how package maintainers and build-tool authors wrapped the same formatter for their own workflows.

Package-manager adoption followed the CLI packaging model: Homebrew, MacPorts, Nix, and Scoop package the formatter so users can run `google-java-format` or `google-java-format-diff` without hand-managing the release jar.

### 使用方式

The common package-manager use is formatting whole Java files from the shell, rewriting files in place with `--replace`, checking changed lines with the diff helper, or enforcing style in CI with a nonzero exit when files differ. The library mode supports code generators and build tools that need formatted Java output.

The formatter depends on javac internals through the `jdk.compiler` module, so editor and library integrations document extra JVM export flags on strongly encapsulated JDKs.

### 为什么软件包爱好者会关心

google-java-format matters to package nerds because it packages a style guide as executable policy. It is a canonical example of a formatter with almost no bikeshed surface: installation, editor integration, and CI wiring matter more than local configuration.

It also sits at the intersection of Java release engineering and package distribution: jars, native binaries, IDE plugins, Maven artifacts, and OS package-manager formulae all expose the same opinionated formatting behavior.

### 时间线

- 2015: GitHub repository created under google/google-java-format.
- 2015: 0.1 Alpha published on GitHub Releases.
- 2016: 1.0 release published on GitHub Releases.
- 2017: 1.x releases added a steady release cadence for package managers and editor integrations.
- 2021: JDK strong encapsulation made the documented `--add-exports` flags important for plugin and library users.

### Related projects

- The README points to Google Java Style, the IntelliJ and Eclipse plugins, google-java-format-diff, Spotless Gradle and Maven integrations, fmt-maven-plugin, sbt-java-formatter, and GitHub Actions wrappers.

### 来源

- <https://api.github.com/repos/google/google-java-format>
- <https://github.com/google/google-java-format>
- <https://github.com/google/google-java-format#readme>
- <https://github.com/google/google-java-format/releases>


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals

## 其他软件包管理器记录

- Nix - google-java-format: normalized package name match | nixpkgs package indexes: pkgs/by-name/go/google-java-format/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- MacPorts - google-java-format: normalized package name match | MacPorts ports tree: java/google-java-format/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Scoop - extras/google-java-format: normalized package name match | Scoop official bucket manifest trees: bucket/google-java-format.json from https://api.github.com/repos/ScoopInstaller/Extras/git/trees/master?recursive=1


## Combined YAML source

View the package source record on GitHub. [combined/google-java-format.yml](https://github.com/mxcl/pkgdb/blob/main/combined/google-java-format.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
