Lines Matching +full:google +full:- +full:java +full:- +full:format
1 # google-java-format chapter
3 `google-java-format` is a program that reformats Java source code to comply with
4 [Google Java Style][].
6 [Google Java Style]: https://google.github.io/styleguide/javaguide.html
10 ### from the command-line
12 [Download the formatter](https://github.com/google/google-java-format/releases)
16 java -jar /path/to/google-java-format-${GJF_VERSION?}-all-deps.jar <options> [files...]
19 The formatter can act on whole files, on limited lines (`--lines`), on specific
20 offsets (`--offset`), passing through to standard-out (default) or altered
21 in-place (`--replace`).
24 [`google-java-format-diff.py`](https://github.com/google/google-java-format/blob/master/scripts/goo…
28 a single format.*
33 [google-java-format IntelliJ plugin](https://plugins.jetbrains.com/plugin/8527)
36 for the `google-java-format` plugin, and click the `Install` button.
39 to `File→Settings...→google-java-format Settings` (or `IntelliJ
40 IDEA→Preferences...→Other Settings→google-java-format Settings` on macOS) and
41 check the `Enable google-java-format` checkbox. (A notification will be
52 The google-java-format plugin uses some internal classes that aren't available
57 --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
58 --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
59 --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
60 --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
61 --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
62 --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
69 The latest version of the `google-java-format` Eclipse plugin can be downloaded
70 from the [releases page](https://github.com/google/google-java-format/releases).
72 [drop-ins folder](http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fre…
75 The plugin adds a `google-java-format` formatter implementation that can be
76 configured in `Window > Preferences > Java > Code Style > Formatter > Formatter
79 ### Third-party integrations
82 * [spotless](https://github.com/diffplug/spotless/tree/main/plugin-gradle#google-java-format)
83 …* [sherter/google-java-format-gradle-plugin](https://github.com/sherter/google-java-format-gradl…
85 * [spotless](https://github.com/diffplug/spotless/tree/main/plugin-maven#google-java-format)
86 * [spotify/fmt-maven-plugin](https://github.com/spotify/fmt-maven-plugin)
87 … * [talios/googleformatter-maven-plugin](https://github.com/talios/googleformatter-maven-plugin)
88 * [Cosium/maven-git-code-format](https://github.com/Cosium/maven-git-code-format):
89 A maven plugin that automatically deploys google-java-format as a
90 pre-commit git hook.
92 * [sbt/sbt-java-formatter](https://github.com/sbt/sbt-java-formatter)
94 * [googlejavaformat-action](https://github.com/axel-op/googlejavaformat-action):
95 Automatically format your Java files when you push on github
99 The formatter can be used in software which generates java to output more
100 legible java code. Just include the library in your maven/gradle/etc.
103 `google-java-format` uses internal javac APIs for parsing Java source. The
105 [JEP 396: Strongly Encapsulate JDK Internals by Default](https://openjdk.java.net/jeps/396):
108 --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
109 --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
110 --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
111 --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
112 --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
113 --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
120 <groupId>com.google.googlejavaformat</groupId>
121 <artifactId>google-java-format</artifactId>
122 <version>${google-java-format.version}</version>
130 implementation 'com.google.googlejavaformat:google-java-format:$googleJavaFormatVersion'
136 ```java
142 ```java
149 `com.google.googlejavaformat.java.Formatter`.
164 Copyright 2015 Google Inc.
170 http://www.apache.org/licenses/LICENSE-2.0