{"id":31970547,"url":"https://github.com/hubspot/prettier-maven-plugin","last_synced_at":"2025-10-14T19:16:16.287Z","repository":{"id":38333362,"uuid":"221643660","full_name":"HubSpot/prettier-maven-plugin","owner":"HubSpot","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-28T19:10:21.000Z","size":135472,"stargazers_count":119,"open_issues_count":12,"forks_count":22,"subscribers_count":130,"default_branch":"master","last_synced_at":"2025-07-11T12:37:14.720Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HubSpot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-14T08:05:46.000Z","updated_at":"2025-05-08T19:42:58.000Z","dependencies_parsed_at":"2024-05-28T22:17:00.455Z","dependency_job_id":"2362ac58-c6e8-4f42-a81d-31d214ab3049","html_url":"https://github.com/HubSpot/prettier-maven-plugin","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/HubSpot/prettier-maven-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fprettier-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fprettier-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fprettier-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fprettier-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HubSpot","download_url":"https://codeload.github.com/HubSpot/prettier-maven-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpot%2Fprettier-maven-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020652,"owners_count":26086895,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-10-14T19:16:07.407Z","updated_at":"2025-10-14T19:16:16.281Z","avatar_url":"https://github.com/HubSpot.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prettier-maven-plugin\n\nMaven plugin for running [prettier-java](https://github.com/jhipster/prettier-java) during a build. Node, prettier, and prettier-java are downloaded automatically as needed.\n\nThere is a `check` goal which (optionally) fails the build if code isn't formatted correctly, and a `write` goal which rewrites the source code in place. A common setup might be to use the `write` goal during local builds, and the `check` goal during CI builds.\n\n### Example Usage\n\nThis example will run the `check` goal inside of Travis CI, and the `write` goal outside of Travis CI. You can update the profile activation conditions based on the CI tool you use.\n\n```xml\n\u003cproperties\u003e\n  \u003c!-- By default just re-write code with prettier --\u003e\n  \u003cplugin.prettier.goal\u003ewrite\u003c/plugin.prettier.goal\u003e\n\u003c/properties\u003e\n\n\u003cbuild\u003e\n  \u003cplugins\u003e\n    \u003cplugin\u003e\n      \u003cgroupId\u003ecom.hubspot.maven.plugins\u003c/groupId\u003e\n      \u003cartifactId\u003eprettier-maven-plugin\u003c/artifactId\u003e\n      \u003cversion\u003e0.16\u003c/version\u003e\n      \u003cconfiguration\u003e\n        \u003cprettierJavaVersion\u003e2.0.0\u003c/prettierJavaVersion\u003e\n        \u003cprintWidth\u003e90\u003c/printWidth\u003e\n        \u003ctabWidth\u003e2\u003c/tabWidth\u003e\n        \u003cuseTabs\u003efalse\u003c/useTabs\u003e\n        \u003cignoreConfigFile\u003etrue\u003c/ignoreConfigFile\u003e\n        \u003cignoreEditorConfig\u003etrue\u003c/ignoreEditorConfig\u003e\n        \u003c!-- Use \u003cinputGlobs\u003e to override the default input patterns --\u003e\n        \u003cinputGlobs\u003e\n          \u003c!-- These are the default patterns, you can omit \u003cinputGlobs\u003e entirely unless you want to override them --\u003e\n          \u003cinputGlob\u003esrc/main/java/**/*.java\u003c/inputGlob\u003e\n          \u003cinputGlob\u003esrc/test/java/**/*.java\u003c/inputGlob\u003e\n        \u003c/inputGlobs\u003e\n      \u003c/configuration\u003e\n      \u003cexecutions\u003e\n        \u003cexecution\u003e\n          \u003cphase\u003evalidate\u003c/phase\u003e\n          \u003cgoals\u003e\n            \u003cgoal\u003e${plugin.prettier.goal}\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\u003cprofiles\u003e\n  \u003cprofile\u003e\n    \u003cid\u003etravis\u003c/id\u003e\n    \u003cactivation\u003e\n      \u003cproperty\u003e\n        \u003cname\u003eenv.TRAVIS\u003c/name\u003e\n      \u003c/property\u003e\n    \u003c/activation\u003e\n    \u003cproperties\u003e\n      \u003c!-- But in our CI environment we want to validate that code is formatted --\u003e\n      \u003cplugin.prettier.goal\u003echeck\u003c/plugin.prettier.goal\u003e\n    \u003c/properties\u003e\n  \u003c/profile\u003e\n\u003c/profiles\u003e\n```\n\nYou can also run in a one-off fashion via the commandline:  \n`mvn prettier:check`  \nor  \n`mvn prettier:write`\n\nYou can also run `mvn prettier:print-args` in order to confirm the configuration values\n\nTo format additional directories or file types via the commandline, you can pass a comma-separated list of patterns, for example:  \n`mvn prettier:write '-Dprettier.inputGlobs=src/main/java/**/*.java,src/test/java/**/*.java,src/main/js/**/*.js'`\n\n### Configuration\n\nIf you want to customize the behavior of prettier, you can use a normal prettier configuration [file](https://prettier.io/docs/en/configuration.html). Alternatively, you can configure prettier directly via the Maven plugin using the following options:\n\n| Name                | -D property name             | Default Value                    | Description                                                                                                                                                                                                                                                       |\n|---------------------|------------------------------|----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| skip                | N/A                          | false                            | If set to true, plugin execution will be skipped                                                                                                                                                                                                                  |\n| fail                | N/A                          | true                             | **Only appplies to `check` goal**. If set to true, the plugin execution will fail if any unformatted files are found                                                                                                                                              |\n| generateDiff        | N/A                          | false                            | **Only appplies to `check` goal. Be sure to have to sh and diff in your PATH**. If set to true, a diff will be generated between the current code and the prettier-formatted code.                                                                                |\n| diffGenerator       | prettier.diffGenerator       | _                                | **Only appplies to `check` goal**. Can be used to supply a custom implementation of [`DiffGenerator`](https://github.com/HubSpot/prettier-maven-plugin/blob/master/prettier-maven-plugin/src/main/java/com/hubspot/maven/plugins/prettier/diff/DiffGenerator.java) \n| nodeVersion         | prettier.nodeVersion         | 16.13.1                          | Controls version of Node used to run prettier-java.                                                                                                                                                                                                               |\n| nodePath            | prettier.nodePath            | -                                | Can be used to supply your own node executable, rather than having the plugin download it. To use the version of node on your `$PATH`, you can simply set this option to `node`.                  |\n| npmPath             | prettier.npmPath             | -                                | Can be used to supply your own npm executable, rather than having the plugin download it. To use the version of npm on your `$PATH`, you can simply set this option to `npm`.                      |\n| prettierJavaVersion | prettier.prettierJavaVersion | 0.7.0                            | Controls version of prettier-java that is used.                                                             |\n| printWidth          | prettier.printWidth          | `null`                           | If set, will be passed to prettier as `--print-width`. More information [here](https://prettier.io/docs/en/options.html#print-width)                                                                                                                              |\n| tabWidth            | prettier.tabWidth            | `null`                           | If set, will be passed to prettier as `--tab-width`. More information [here](https://prettier.io/docs/en/options.html#tab-width)                                                                                                                                  |\n| useTabs             | prettier.useTabs             | `null`                           | If set, will be passed to prettier as `--use-tabs`. More information [here](https://prettier.io/docs/en/options.html#tabs)                                                                                                                                        |\n| endOfLine           | prettier.endOfLine           | `null`                           | If set, will be passed to prettier as `--end-of-line`. More information [here](https://prettier.io/docs/en/options.html#end-of-line)                                                                                                                              |\n| ignoreConfigFile    | prettier.ignoreConfigFile    | `false`                          | If set to true, pretter will be invoked with `--no-config`. More information [here](https://prettier.io/docs/en/cli.html#--no-config)                                                                                                                             |\n| ignoreEditorConfig  | prettier.ignoreEditorConfig  | `false`                          | If set to true, pretter will be invoked with `--no-editorconfig`. More information [here](https://prettier.io/docs/en/cli.html#--no-editorconfig)                                                                                                                 |\n| inputGlobs          | prettier.inputGlobs          | `src/{main,test}/java/**/*.java` | Controls the input paths passed to prettier, useful for formatting additional directories or file types. More information [here](https://prettier.io/docs/en/cli.html#file-patterns)                                                                              |\n| disableGenericsLinebreaks | prettier.disableGenericsLinebreaks | `false` | Prevents prettier from adding linebreaks to generic type declarations (see https://github.com/HubSpot/prettier-maven-plugin/pull/78 for more background) |\n\n### Generic Linebreaks\n\nThe `disableGenericsLinebreaks` option is implemented by patching prettier-plugin-java after downloading. As new versions of prettier-java are released, we may need to create updated patches. The basic flow for creating a new patch is:\n1. Download the new version of prettier-java\n  - `cd /tmp \u0026\u0026 npm install prettier-plugin-java@{version}`\n2. Make two copies of prettier-java code\n  - `mkdir -p a/node_modules \u0026\u0026 cp -r node_modules/prettier-plugin-java a/node_modules`)\n  - `mkdir -p b/node_modules \u0026\u0026 cp -r node_modules/prettier-plugin-java b/node_modules`)\n3. Update the code within `b/node_modules/prettier-plugin-java/dist/` as needed to revert the generic linebreak behavior (for now, these are the relevant PRs: [#512](https://github.com/jhipster/prettier-java/pull/512), [#584](https://github.com/jhipster/prettier-java/pull/584))\n4. Generate a diff between `a/` (original code) and `b/` (updated code)\n  - `git diff -p a b --no-prefix \u003e no-linebreak-generics-{version}.patch`\n5. Add the patch to `src/main/resources/` and update the logic in `PrettierArgs.java` to use it as appropriate\n\n### Note\n\nFor convenience, this plugin downloads Node, prettier, and prettier-java as needed. Node is downloaded from https://nodejs.org/dist/ and prettier-plugin-java is downloaded via npm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubspot%2Fprettier-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhubspot%2Fprettier-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubspot%2Fprettier-maven-plugin/lists"}