Download the formatter and run it with: To reformat changed lines in a specific patch, use google-java-format-diff.py. Note: There is no configurability as to the formatter's algorithm for formatting.
Applying this automatically configures IntelliJ, whether you run ./gradlew idea or import the project directly from IntelliJ, to use the correct version of the formatter when formatting java code.