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
🌐
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
🌐
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
Find elsewhere
🌐
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
🌐
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 › sherter › google-java-format-gradle-plugin › issues
Issues · sherter/google-java-format-gradle-plugin
June 22, 2024 - Contribute to sherter/google-java-format-gradle-plugin development by creating an account on GitHub.
Author: sherter
🌐
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
🌐
Google
android.googlesource.com › platform › external › google-java-format › + › 8612b8937d1dde47f0078918ccda945310a65bdc › README.md
google-java-format
Cosium/maven-git-code-format: A maven plugin that automatically deploys google-java-format as a pre-commit git hook. ... maltzj/google-style-precommit-hook: A pre-commit (pre-commit.com) hook that will automatically run GJF whenever you commit code to your repository ... 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.