It sounds like you want to essentially always ensure that the code is properly formatted before the verifyGoogleJavaFormat task is run (and could complain). In that case, I’d simply make the googleJavaFormat task a dependency of the verifyGoogleJavaFormat task. In your build.gradle file, after you have applied the google-java-format plugin, simply add the following:

verifyGoogleJavaFormat.dependsOn(tasks.googleJavaFormat)

Alternatively, if you really only want to run the code formatter when the build task is run (as opposed to when the verifyGoogleJavaFormat task is run only), you could add this instead:

build.dependsOn(tasks.googleJavaFormat)
verifyGoogleJavaFormat.mustRunAfter(tasks.googleJavaFormat)
Answer from Chriki on Stack Overflow
🌐
GitHub
github.com › sherter › google-java-format-gradle-plugin
GitHub - sherter/google-java-format-gradle-plugin · GitHub
A Gradle plugin that utilizes google-java-format to format the Java source files in your Gradle project.
Author: sherter
🌐
GitHub
github.com › youribonnaffe › gradle-format-plugin
GitHub - youribonnaffe/gradle-format-plugin: A Gradle plugin to format Java source code · GitHub
The Gradle Format plugin enables you to format your Java sources. It operates in place and can be used for instance before pushing changes to enforce a coding style. The formatting can be customized using a properties or XML file with the keys ...
Author: youribonnaffe
Discussions

intellij idea - How can I configure Gradle google-java-format plugin to run goJF in the build step? - Stack Overflow
We wired https://github.com/sherter/google-java-format-gradle-plugin into our project per the readme. We also wired in a pre-commit hook to run the plugin before committing, which ensures that all... More on stackoverflow.com
🌐 stackoverflow.com
Java 17 with gradle 7 Support
But with the upgrade to Java 17 and gradle 7, the plugin results in a build fail with the exception: Detected Java syntax errors in the following files (you can exclude them from this task, see "https://github.com/sherter/google-java-format-gradle-plugin" for details): More on github.com
🌐 github.com
2
October 7, 2021
How can I automatically run google-java-format as part of my Gradle build? - Stack Overflow
Google-java-format-gradle-plugin integrates with Gradle, but how can I run it automatically as part of the normal build? More on stackoverflow.com
🌐 stackoverflow.com
Codestyle and formatters
Spotless? It can use the eclipse formatter which is pretty configurable, or the Google formatter, or others. More on reddit.com
🌐 r/java
27
18
October 21, 2024
🌐
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 - Cosium/maven-git-code-format: A maven plugin that automatically deploys google-java-format as a pre-commit git hook. ... The formatter can be used in software which generates java to output more legible java code.
Author: google
🌐
Maven Repository
mvnrepository.com › artifact › gradle.plugin.com.github.sherter.google-java-format › google-java-format-gradle-plugin
Maven Repository: gradle.plugin.com.github.sherter.google-java-format » google-java-format-gradle-plugin
Home » gradle.plugin.com.github.sherter.google-java-format » google-java-format-gradle-plugin · Google Java Format Gradle Plugin · Gradle Plugins (11) Central · Atlassian External · Atlassian · WSO2 Releases · WSO2 Public · Hortonworks · Mulesoft · JCenter ·
🌐
Maven Repository
mvnrepository.com › artifact › com.github.sherter.google-java-format
Maven Repository: com.github.sherter.google-java-format
GitHub Sherter Google Java Format · Links · Artifact1 · Jenkins Public1 · Gradle Plugins1 · Home » com.github.sherter » google-java-format · com.github.sherter.google-java-format » com.github.sherter.google-java-format.gradle.plugin · GitHub Sherter Google Java Format Gradle Plugin ·
🌐
Gradle
plugins.gradle.org › search
google-java-format
Spotless - keep your code spotless with Gradle · Format your Java source files with google-java-format
Find elsewhere
🌐
GitHub
github.com › qbixus › google-java-format
GitHub - qbixus/google-java-format: Reformats Java source code to comply with Google Java Style. · GitHub
Cosium/maven-git-code-format: A maven plugin that automatically deploys google-java-format as a pre-commit git hook. ... The formatter can be used in software which generates java to output more legible java code.
Author: qbixus
🌐
GitHub
github.com › sherter › google-java-format-gradle-plugin › issues › 67
Java 17 with gradle 7 Support · Issue #67 · sherter/google-java-format-gradle-plugin
October 7, 2021 - Does this plugin support Java 17 with gradle 7? We used this plugin with Java 11 and gradle 6 and it worked very well. But with the upgrade to Java 17 and gradle 7, the plugin results in a build fail with the exception: Detected Java syn...
Author: sherter
🌐
SourceForge
sourceforge.net › projects › google-java-format.mirror
google-java-format download | SourceForge.net
July 30, 2026 - The formatter can be used in software that generates java to output more legible java code. Just include the library in your maven/gradle/etc. configuration. A google-java-format IntelliJ plugin is available from the plugin repository.
🌐
JitPack
jitpack.io › p › google › google-java-format
google / google-java-format Download
Cosium/maven-git-code-format: A maven plugin that automatically deploys google-java-format as a pre-commit git hook. ... The formatter can be used in software which generates java to output more legible java code. Just include the library in your maven/gradle/etc.
🌐
Maven Repository
mvnrepository.com › artifact › com.github.google.google-java-format
Maven Repository: com.github.google.google-java-format
A Java source code formatter that follows Google Java Style. ... aar android apache api arm assets build build-system bundle client clojure cloud config cran data database eclipse example extension framework github gradle groovy io ios javascript jvm kotlin library logging maven mobile module ...
🌐
GitHub
github.com › tmzk1005 › formatter
GitHub - tmzk1005/formatter: gradle plugin format java code
This project provides a mechanism ... regardless of user preferences, IDE settings, etc. This plugin uses the Eclipse code formatter to format java code, format options can be set to overwrite the default, and also support ...
Author: tmzk1005
🌐
Reddit
reddit.com › r/java › codestyle and formatters
r/java on Reddit: Codestyle and formatters
October 21, 2024 -

Hi y'all,

My team would like to standardise code formatting and enforce it in CI. We've tried google-java-formatter but it doesn't look nearly as good as inteliJ's default settings.

Ideally, we'd like to export inteliJs defaults (to have the benefits of built in formatter) and use something that would enforce it on CI build. Has anyone done it? What are your pipelines like? Any tips and tricks?

🌐
GitHub
github.com › hferreiro › google-java-format
GitHub - hferreiro/google-java-format: Reformats Java source code to comply with Google Java Style. · GitHub
Cosium/maven-git-code-format: A maven plugin that automatically deploys google-java-format as a pre-commit git hook. ... The formatter can be used in software which generates java to output more legible java code.
Author: hferreiro
🌐
Medium
shankulk.medium.com › format-your-java-code-with-google-java-format-5bf4de8756f5
Format your Java code with google-java-format | by Shantanu Kulkarni | Medium
March 30, 2023 - It utilizes google-java-format to format the java source code. Add the following plugin to your build.gradle file: plugins { id 'com.github.sherter.google-java-format' version '0.9' }
🌐
GitHub
github.com › palantir › palantir-java-format
GitHub - palantir/palantir-java-format: A modern, lambda-friendly, 120 character Java formatter. · GitHub
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. ./gradlew format can be enabled by using the com.palantir.baseline-format Gradle plugin.
Author: palantir
🌐
Gradle
discuss.gradle.org › help/discuss
Google Java Formatter as external application - Help/Discuss - Gradle Forums
October 5, 2016 - Running the current snapshot version of Google-Java-Formatter against all source sets, I frist tried the plugin https://github.com/sherter/google-java-format-gradle-plugin. It does not support the current snapshot API.