GitHub
github.com › google › google-java-format
GitHub - google/google-java-format: Reformats Java source code to comply with Google Java Style. · GitHub
August 14, 2026 - Option --help will print full usage ... as --aosp, --fix-imports-only, --skip-sorting-imports, --skip-removing-unused-import, --skip-reflowing-long-strings, --skip-javadoc-formatting, or the --dry-run and --set-exit-if-changed. Using @<filename> reads options and filenames from a file, instead of arguments. To reformat changed lines in a specific patch, use google-java-form...
Author: google
Stack Overflow
stackoverflow.com › questions › 76716652 › how-to-get-similar-google-java-formatting-in-intellij-and-with-maven
How to get similar google java formatting in intellij and with maven - Stack Overflow
Copy <plugin> <groupId>com.diffplug.spotless</groupId> <artifactId>spotless-maven-plugin</artifactId> <version>2.30.0</version> <executions> <execution> <goals> <goal>check</goal> </goals> </execution> </executions> <configuration> <java> <googleJavaFormat> <version>1.7</version> <style>AOSP</style> </googleJavaFormat> <removeUnusedImports /> <licenseHeader> <file>../license-header</file> </licenseHeader> </java> </configuration> </plugin> Am I missing something? Aren't they supposed to work with google format (which should be the same...)?
Android Open Source Project
source.android.com › docs › setup › contribute › code-style
AOSP Java code style for contributors | Android Open Source Project
March 13, 2025 - Every file should have a copyright statement at the top, followed by package and import statements (each block separated by a blank line), and finally the class or interface declaration. In the Javadoc comments, describe what the class or interface does.
Top answer 1 of 2
13
I was able to change to 4-space indentations by selecting the Android Open Source Project (AOSP) style in the google-java-format plugin settings:

It looks like the only difference between the two styles is that AOSP doubles the spacing to 4 instead of 2: https://github.com/google/google-java-format/blob/master/core/src/main/java/com/google/googlejavaformat/java/JavaFormatterOptions.java#L37
2 of 2
6
First I disabled the IntelliJ google-java-format plugin.Downloaded IntelliJ-java-google-style.xml from here and modified indent size property as below. After importing this style in IntelliJ, I am able to indent to 4 spaces. To import the code style XML, please refer to this link
<codeStyleSettings language="CSS">
<indentOptions>
<option name="INDENT_SIZE" value="4" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
GitHub
github.com › google › google-java-format › blob › master › scripts › google-java-format-diff.py
google-java-format/scripts/google-java-format-diff.py at master · google/google-java-format
binary = which('google-java-format') or '/usr/bin/google-java-format' base_command = [binary] · if args.i: base_command.append('-i') if args.aosp: base_command.append('--aosp') if args.skip_sorting_imports: base_command.append('--skip-sorting-imports') if args.skip_removing_unused_imports: base_command.append('--skip-removing-unused-imports') if args.skip_javadoc_formatting: base_command.append('--skip-javadoc-formatting') ·
Author: google