google-java-format and indentation settings
See original GitHub issueWe would like to use Google Java Format and still enforce 4 space indentation. Ideal way of doing this would be to use both googleJavaFormat("1.7")
and indentWithSpaces(4)
in the order and expect spotless to apply them in the given order and get the required result.
java {
removeUnusedImports()
googleJavaFormat("1.7")
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
paddedCell()
}
Is there a way to enforce order of the execution of spotless to get the best of both?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Google IntelliJ java style: changing 2-space indentation to 4 ...
I was able to change to 4-space indentations by selecting the Android Open Source Project (AOSP) style in the google-java-format plugin ...
Read more >Google Java Style Guide
4.2 Block indentation: +2 spaces. Each time a new block or block-like construct is opened, the indent increases by two spaces. When the...
Read more >google-java-format - Pants build
Use AOSP style instead of Google Style (4-space indentation). ("AOSP" is the Android Open Source Project.) Advanced options ...
Read more >platform/external/google-java-format - Git at Google
To install it, go to your IDE's settings and select the Plugins category. Click the Marketplace tab, search for the google-java-format plugin, and...
Read more >Java formatting and linting - Visual Studio Code
After setting the formatter profile, the Format Document command will use the specific profile to format your Java files. Editing formatter settings. The ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As this issue pops up in searches when trying to solve this for Java and Maven, I will paste the solution here as well. Similarly as said here for Gradle build:
you can do the same with Maven:
I strongly recommend
googleJavaFormat("1.7").aosp()
over @nedtwigg’s solution in this case because it is the official solution. 😃