You need to include a maven plugin that supports Googles Java format. It seems like your goal verifyGoogleJavaFormat is available for Gradle, but not for Maven. One option is to use https://github.com/Cosium/git-code-format-maven-plugin. It supports format verification and automatic formatting upon comitting.
The Github Repo documentation states that you can include it in your pom.xml like this:
<build>
<plugins>
<plugin>
<groupId>com.cosium.code</groupId>
<artifactId>git-code-format-maven-plugin</artifactId>
<version>3.3</version>
<executions>
<!-- On commit, format the modified java files -->
<execution>
<id>install-formatter-hook</id>
<goals>
<goal>install-hooks</goal>
</goals>
</execution>
<!-- On Maven verify phase, fail if any file
(including unmodified) is badly formatted -->
<execution>
<id>validate-code-format</id>
<goals>
<goal>validate-code-format</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Now, when I run mvn verify on my unformatted project I get an error:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.090 s
[INFO] Finished at: 2022-03-12T17:56:13+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.cosium.code:git-code-format-maven-plugin:3.3:validate-code-format (validate-code-format) on project javatest: /home/bisensee/repos/javatest/src/main/java/Position.java is not correctly formatted ! -> [Help 1]
When we make our next commit the formatter is automatically applied via a Git hook and the next mvn verify succeeds.
GitHub
github.com › marketplace › actions › google-java-format
Google Java Format · Actions · GitHub Marketplace · GitHub
Automatically format your Java files using Google Java Style guidelines. This action automatically downloads the latest release of the Google Java Format program.
Starred by 119 users
Forked by 30 users
Languages: TypeScript 99.6% | JavaScript 0.4%
GitHub
github.com › marketplace › actions › google-java-style-format
Google Java Style Format · Actions · GitHub Marketplace · GitHub
Format all Java files in the repository and commit the changes: name: Format on: push: branches: [ master ] jobs: formatting: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # v2 minimum required - uses: ryanbascom/googlejavaformat@v4 with: args: "--skip-sorting-imports --replace" # Recommended if you use MacOS: # github-token: ${{ secrets.GITHUB_TOKEN }}
GitHub
github.com › apolloconfig › apollo › issues › 4196
Add github action google-java-format or not · Issue #4196 · apolloconfig/apollo
January 6, 2022 - Is your feature request related to a problem? Please describe. Now the java code's format use google style, but sometime a contributor maybe forget format the code. Describe the solution you'd like There is a github action Google Java Format https://github.com/marketplace/actions/google-java-format
Author: apolloconfig
Starred by 12 users
Forked by 4 users
Languages: Python 90.1% | Emacs Lisp 7.0% | Makefile 2.9%
GitHub
github.com › topics › google-java-style-guide
google-java-style-guide · GitHub Topics · GitHub
Sample maven module with custom shell script utilizing maven plugins to automate code formatting using Google Java Style guide, and enforcing code coverage, code quality and code security · formatter git-hooks codecoverage google-java-style-guide codesecurity codequality google-java-format pre-commit-hook pre-commit-hok-java
npm
npmjs.com › package › google-java-format
google-java-format - npm
April 2, 2026 - This will find the matching files and run google-java-format on chunks of 30 files at a time, then show the total formatted files at the end. See node-glob for globbing semantics. Use the -i or --replace argument to format the files by re-writing instead of printing the changes to stdout: ... If you would like to contribute a pre-commit hook, perhaps one that is Husky-compatible, that would be great! Open a PR with the hook and remove this comment :-) May be used in GitHub Actions workflows to verify PRs meet formatting standards, as done in Invertase react-native-firebase, specifically this package.json run script is called in a CI job and sets exit status correctly to fail the job if there are formatting inconsistencies found:
» npm install google-java-format
Published: Jul 11, 2026
Version: 2.3.0