{"id":18753001,"url":"https://github.com/spotify/fmt-maven-plugin","last_synced_at":"2025-04-07T16:11:24.088Z","repository":{"id":37087714,"uuid":"54135736","full_name":"spotify/fmt-maven-plugin","owner":"spotify","description":"Opinionated Maven Plugin that formats your Java code.","archived":false,"fork":false,"pushed_at":"2024-10-07T07:06:33.000Z","size":286,"stargazers_count":348,"open_issues_count":14,"forks_count":68,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-31T15:07:56.295Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spotify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-17T16:56:30.000Z","updated_at":"2025-03-28T01:46:09.000Z","dependencies_parsed_at":"2024-01-22T11:47:21.135Z","dependency_job_id":"8adf87d0-4c2a-41a8-a266-6a7b342cd6a6","html_url":"https://github.com/spotify/fmt-maven-plugin","commit_stats":null,"previous_names":["coveooss/fmt-maven-plugin"],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Ffmt-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Ffmt-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Ffmt-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spotify%2Ffmt-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spotify","download_url":"https://codeload.github.com/spotify/fmt-maven-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247685627,"owners_count":20979085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T17:23:41.334Z","updated_at":"2025-04-07T16:11:24.046Z","avatar_url":"https://github.com/spotify.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/spotify/fmt-maven-plugin/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/spotify/fmt-maven-plugin/actions/workflows/ci.yml?query=branch%3Amain)\n[![license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/spotify/fmt-maven-plugin/blob/main/LICENSE)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.spotify.fmt/fmt-maven-plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.spotify.fmt/fmt-maven-plugin)\n\n## fmt-maven-plugin \n\n**UPDATE 2022-02-14:** This plugin has moved from [coveooss](https://github.com/coveooss/) to the [spotify](https://github.com/spotify/) Github org. The new groupId will be `com.spotify.fmt`, and the `master` branch has been renamed to `main`.\n\nFormats your code using [google-java-format](https://github.com/google/google-java-format) which follows [Google's code styleguide](https://google.github.io/styleguide/javaguide.html).\n\nThe format cannot be configured by design.\n\nIf you want your IDE to stick to the same format, google-java-format also includes integrations for IntelliJ and Eclipse IDE's, following the installation instructions on the [README](https://github.com/google/google-java-format/blob/master/README.md#using-the-formatter).\n\n## Usage\n\n### Standard pom.xml\n\nTo have your sources automatically formatted on each build, add to your pom.xml:\n\n```xml\n    \u003cbuild\u003e\n        \u003cplugins\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003ecom.spotify.fmt\u003c/groupId\u003e\n                \u003cartifactId\u003efmt-maven-plugin\u003c/artifactId\u003e\n                \u003cversion\u003eVERSION\u003c/version\u003e\n                \u003cexecutions\u003e\n                    \u003cexecution\u003e\n                        \u003cgoals\u003e\n                            \u003cgoal\u003eformat\u003c/goal\u003e\n                        \u003c/goals\u003e\n                    \u003c/execution\u003e\n                \u003c/executions\u003e\n            \u003c/plugin\u003e\n        \u003c/plugins\u003e\n    \u003c/build\u003e\n```\n\nIf you prefer, you can only check formatting at build time using the `check` goal:\n\n```xml\n    \u003cbuild\u003e\n        \u003cplugins\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003ecom.spotify.fmt\u003c/groupId\u003e\n                \u003cartifactId\u003efmt-maven-plugin\u003c/artifactId\u003e\n                \u003cversion\u003eVERSION\u003c/version\u003e\n                \u003cexecutions\u003e\n                    \u003cexecution\u003e\n                        \u003cgoals\u003e\n                            \u003cgoal\u003echeck\u003c/goal\u003e\n                        \u003c/goals\u003e\n                    \u003c/execution\u003e\n                \u003c/executions\u003e\n            \u003c/plugin\u003e\n        \u003c/plugins\u003e\n    \u003c/build\u003e\n```\n\n#### Overriding the Default Lifecycle Phase\n\nBoth goals have a [Maven lifecycle phase](https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#lifecycle-reference) configured by default.\n\n| Goal      | Default Phase     |\n|-----------|-------------------|\n| `format`  | `process-sources` |\n| `check`   | `verify`          |\n\nYou may prefer to run these goals in a different phase instead.  \nMaven allows you to override the default phase by specifying a `\u003cphase\u003e` for the `\u003cexecution\u003e`.\n\nFor example, you may prefer that the `check` goal is performed in an earlier phase such as `validate`:\n\n```xml\n                    \u003cexecution\u003e\n                        \u003cphase\u003evalidate\u003c/phase\u003e\n                        \u003cgoals\u003e\n                            \u003cgoal\u003echeck\u003c/goal\u003e\n                        \u003c/goals\u003e\n                    \u003c/execution\u003e\n```\n\n### Options\n\n`sourceDirectory` represents the directory where your Java sources that need to be formatted are contained. It defaults to `${project.build.sourceDirectory}`\n\n`testSourceDirectory` represents the directory where your test's Java sources that need to be formatted are contained. It defaults to `${project.build.testSourceDirectory}`\n\n`additionalSourceDirectories` represents a list of additional directories that contains Java sources that need to be formatted. It defaults to an empty list.\n\n`verbose` is whether the plugin should print a line for every file that is being formatted. It defaults to `false`.\n\n`filesNamePattern` represents the pattern that filters files to format. The defaults value is set to `.*\\.java`.\n\n`skip` is whether the plugin should skip the operation.\n\n`skipSortingImports` is whether the plugin should skip sorting imports.\n\n`skipSourceDirectory` is whether the plugin should skip formatting/checking the `sourceDirectory`. It defaults to `false`.\n\n`skipTestSourceDirectory` is whether the plugin should skip formatting/checking the `testSourceDirectory`. It defaults to `false`.\n\n`style` sets the formatter style to be `google` or `aosp`. By default this is `google`. Projects using Android conventions may prefer `aosp`.\n\n`forkMode` lets you specify whether to run google-java-format in a fork or in-process. Also adds JVM arguments to expose JDK internal javac APIs. Value `default` (which is the default) will fork (to avoid warnings for JDK9+ and to be able to run at all for JDK16+), `never` runs in-process, regardless of JDK version and `always` will always fork.\n\nexample:\n```xml\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003ecom.spotify.fmt\u003c/groupId\u003e\n            \u003cartifactId\u003efmt-maven-plugin\u003c/artifactId\u003e\n            \u003cversion\u003eVERSION\u003c/version\u003e\n            \u003cconfiguration\u003e\n                \u003csourceDirectory\u003esome/source/directory\u003c/sourceDirectory\u003e\n                \u003ctestSourceDirectory\u003esome/test/directory\u003c/testSourceDirectory\u003e\n                \u003cverbose\u003etrue\u003c/verbose\u003e\n                \u003cfilesNamePattern\u003e.*\\.java\u003c/filesNamePattern\u003e\n                \u003cadditionalSourceDirectories\u003e\n                    \u003cparam\u003esome/dir\u003c/param\u003e\n                    \u003cparam\u003esome/other/dir\u003c/param\u003e\n                \u003c/additionalSourceDirectories\u003e\n                \u003cskip\u003efalse\u003c/skip\u003e\n                \u003cskipSourceDirectory\u003efalse\u003c/skipSourceDirectory\u003e\n                \u003cskipTestSourceDirectory\u003efalse\u003c/skipTestSourceDirectory\u003e\n                \u003cskipSortingImports\u003efalse\u003c/skipSortingImports\u003e\n                \u003cstyle\u003egoogle\u003c/style\u003e\n            \u003c/configuration\u003e\n            \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cgoals\u003e\n                        \u003cgoal\u003eformat\u003c/goal\u003e\n                    \u003c/goals\u003e\n                \u003c/execution\u003e\n            \u003c/executions\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n\n\n### check Options\n\n`displayFiles` default = true. Display the list of the files that are not compliant.\n\n`displayLimit` default = 100. Number of files to display that are not compliant.\n\n`failOnError` default = true. Fail the build if non-compliant files are found.\n\n\nexample to not display the non-compliant files:\n```xml\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003ecom.spotify.fmt\u003c/groupId\u003e\n            \u003cartifactId\u003efmt-maven-plugin\u003c/artifactId\u003e\n            \u003cversion\u003eVERSION\u003c/version\u003e\n            \u003cconfiguration\u003e\n                \u003cdisplayFiles\u003efalse\u003c/displayFiles\u003e\n            \u003c/configuration\u003e\n            \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cgoals\u003e\n                        \u003cgoal\u003echeck\u003c/goal\u003e\n                    \u003c/goals\u003e\n                \u003c/execution\u003e\n            \u003c/executions\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\nexample to limit the display up to 10 files\n```xml\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003ecom.spotify.fmt\u003c/groupId\u003e\n            \u003cartifactId\u003efmt-maven-plugin\u003c/artifactId\u003e\n            \u003cversion\u003eVERSION\u003c/version\u003e\n            \u003cconfiguration\u003e\n                \u003cdisplayLimit\u003e10\u003c/displayLimit\u003e\n            \u003c/configuration\u003e\n            \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cgoals\u003e\n                        \u003cgoal\u003echeck\u003c/goal\u003e\n                    \u003c/goals\u003e\n                \u003c/execution\u003e\n            \u003c/executions\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\nexample to only warn about non-compliant files instead of failing the build\n```xml\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003ecom.spotify.fmt\u003c/groupId\u003e\n            \u003cartifactId\u003efmt-maven-plugin\u003c/artifactId\u003e\n            \u003cversion\u003eVERSION\u003c/version\u003e\n            \u003cconfiguration\u003e\n                \u003cfailOnError\u003efalse\u003c/failOnError\u003e\n            \u003c/configuration\u003e\n            \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cgoals\u003e\n                        \u003cgoal\u003echeck\u003c/goal\u003e\n                    \u003c/goals\u003e\n                \u003c/execution\u003e\n            \u003c/executions\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n### Command line\n\nYou can also use it on the command line\n\n`mvn com.spotify.fmt:fmt-maven-plugin:format`\n\nYou can pass parameters via standard `-D` syntax.\n`mvn com.spotify.fmt:fmt-maven-plugin:format -Dverbose=true`\n\n`-Dfmt.skip` is whether the plugin should skip the operation.\n\n### Using with Java 8\n\nStarting from version 1.8, Google Java Formatter requires Java 11 to run. Incidently, all versions of this plugin starting from 2.10 inclusively also require this Java version to properly function. The 2.9.x release branch is the most up-to-date version that still runs on Java 8.\n\n### Deploy\n\n- `git checkout main \u0026\u0026 git pull`\n- `mvn release:prepare` - use x.y format for release version and x.y.z for SCM tag. (You can only do this as admin of the repo)\n- `mvn release:perform -P release` (make sure to use Maven settings which include credentials for the Sonatype staging repo)\n- `git fetch` - to make sure your local repo is up to date with the commits from the release plugin.\n- Create a GitHub release with merged PRs and other information.\n- Check that the release is available in [Sonatype staging](https://oss.sonatype.org/#nexus-search;quick~com.spotify.fmt)\n- Wait for the release to be available in [Maven Central](https://repo1.maven.org/maven2/com/spotify/fmt/fmt-maven-plugin/)\n- Update version used for actual formatting in the POM.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotify%2Ffmt-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspotify%2Ffmt-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspotify%2Ffmt-maven-plugin/lists"}