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
🌐
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 › sherter › google-java-format-gradle-plugin
GitHub - sherter/google-java-format-gradle-plugin · GitHub
buildscript { repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.github.sherter.googlejavaformatgradleplugin:google-java-format-gradle-plugin:0.9-SNAPSHOT' } } apply plugin: 'com.github.sherter.google-java-format'
Author: sherter
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
Google Java Formatter as external application
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. Here’s my hand-crafted solution. Download with dependencies and execute ... More on discuss.gradle.org
🌐 discuss.gradle.org
8
1
October 5, 2016
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
🌐
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
🌐
Maven Repository
mvnrepository.com › artifact › gradle.plugin.com.github.sherter.google-java-format
Maven Repository: gradle.plugin.com.github.sherter.google-java-format
Google Java Format Gradle Plugin · Last Release on Jun 8, 2020 · Central · Atlassian External · Atlassian · WSO2 Releases · WSO2 Public · Hortonworks · Mulesoft · JCenter · KtorEAP · Sonatype · 🌐 · DNS Gurus · Free DNS Tools & Analysis · aar amazon 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 npm osgi plugin resources rlang sdk server service spring sql starter testing tools ui web webapp ·
🌐
Oreate AI
oreateai.com › blog › taming-your-java-code-a-look-at-the-googlejavaformat-gradle-plugin › 0c47fd83475fa4964eb9e57bd5c82b96
Taming Your Java Code: A Look at the Google-Java-Format Gradle Plugin - Oreate AI Blog
February 18, 2026 - This task will go through your project and format all the Java source files. If you're more of a 'trust but verify' kind of person, there's also ./gradlew vergjf. This command checks if the code is formatted correctly without actually changing anything, which is super handy for CI/CD pipelines or just before committing. What I really appreciate is the flexibility. You're not locked into one way of doing things. The plugin allows you to specify the toolVersion of google-java-format you want to use, which is great for staying up-to-date or if you have specific version requirements.
🌐
Medium
medium.com › @alexprut › integrate-google-java-style-guide-in-a-java-project-567abb6d7987
Integrate Google Java Style Guide in a Java project | by Alex Prut | Medium
July 28, 2019 - As an example in this tutorial, we’ll integrate the Google Java Style Guide withing the Algo open source project. Along with the official convention definition, Google developed thegoogle-java-format program that reformats the Java source code to comply with the coding style. We’ll be using a third-party Gradle plugin (i.e.
Find elsewhere
🌐
JitPack
jitpack.io › p › sherter › google-java-format-gradle-plugin
sherter / google-java-format-gradle-plugin Download
dependencies { implementation 'com.github.sherter:google-java-format-gradle-plugin:0.9' } dependencies { implementation("com.github.sherter:google-java-format-gradle-plugin:0.9") } <dependency> <groupId>com.github.sherter</groupId> <artifactId>google-java-format-gradle-plugin</artifactId> <version>0.9</version> </dependency> libraryDependencies += "com.github.sherter" % "google-java-format-gradle-plugin" % "0.9" :dependencies [[com.github.sherter/google-java-format-gradle-plugin "0.9"]] © 2015-2026 JitPack | JitCI | Twitter | GitHub | Pricing | Terms | Privacy | Status
🌐
Maven Repository
mvnrepository.com › artifact › com.github.sherter.google-java-format
Maven Repository: com.github.sherter.google-java-format
GitHub Sherter Google Java Format Gradle Plugin · Last Release on Jun 11, 2020 · Central · Atlassian External · Atlassian · WSO2 Releases · WSO2 Public · Hortonworks · KtorEAP · Mulesoft · JCenter · Sonatype · 🌐 · DNS Gurus · Free DNS Tools & Analysis · 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 npm osgi persistence plugin resources rlang sdk server service spring sql starter testing tools ui web webapp ·
🌐
Gradle
plugins.gradle.org › search
Gradle - Plugins
Spotless - keep your code spotless with Gradle · A plugin for applying various code formatting
🌐
Medium
medium.com › @anirudhramesh95 › enforcing-formatting-standards-for-your-java-project-using-gradle-2c21172743e5
Enforcing formatting standards for your Java project using Gradle | by Anirudh Ramesh | Medium
October 8, 2021 - Takes an integer argument if you don't like 4 endWithNewline() setEncoding('utf-8') } java { eclipse() // I like eclipse formatting over google // googleJavaFormat('1.11.0').aosp().reflowLongStrings(), this is the other option } } Note: Initially, comment out ratchetFrom property. This property is used to do incremental linting. i.e — Compare what is in your main / masterbranch and only do linting on changed files (saves time ⏱). For now, leave it commented. ... 5. run ./gradlew spotlessApply .
🌐
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. Here’s my hand-crafted solution. Download with dependencies and execute as a Java program: configurations { format } dependencies { format "com.google.googlejavaformat:google-java-format:1.2-SNAPSHOT" } task downloadFormat(type: Copy) { from configurations.format ...
🌐
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?

🌐
Google
android.googlesource.com › platform › external › google-java-format › + › 32a6c00ff4cfdc3697d556c43968d58602f3cac3 › 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. ... 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.
🌐
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 - When you want to verify that your code is properly formatted, you can run ./gradlew verifyGoogleJavaFormat You can also configure your build script to run the verification before compilation and you’ll force all your team members to use the right formatting every time. Just include the below line in your build.gradle and forget all the worries. Thank me later ;) ... For my projects having Maven as a build tool, I use coveooss/fmt-maven-plugin. It is also a third-party plugin and is an implementation of a google-java-format.
🌐
Stack Overflow
stackoverflow.com › questions › 49933616 › cannot-add-plugin-to-gradle-build-file › 49936581
java - Cannot add plugin to gradle build file? - Stack Overflow
April 20, 2018 - Does this look like a well designed gradle file and how can I get this google formatter to work with it? Copybuildscript { ext { springBootVersion = '2.0.1.RELEASE' } repositories { mavenCentral() jcenter() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}" classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.6" } } apply plugin: 'java' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'maven' apply pl
🌐
Awesomeopensource
awesomeopensource.com › project › sherter › google-java-format-gradle-plugin
Google Java Format Gradle Plugin Alternatives
Reformats Java source code to comply with Google Java Style. dependent packages 169 total releases 21 most recent commit over 2 years ago ... ☔️ interface for parsing, inspecting, transforming, and serializing content through syntax trees ...