{"id":13511782,"url":"https://github.com/jhipster/prettier-java","last_synced_at":"2025-05-13T17:14:17.590Z","repository":{"id":37693196,"uuid":"116288348","full_name":"jhipster/prettier-java","owner":"jhipster","description":"Prettier Java Plugin","archived":false,"fork":false,"pushed_at":"2025-05-11T07:04:26.000Z","size":8161,"stargazers_count":1135,"open_issues_count":50,"forks_count":108,"subscribers_count":22,"default_branch":"main","last_synced_at":"2025-05-11T07:31:47.758Z","etag":null,"topics":["java","prettier"],"latest_commit_sha":null,"homepage":"http://www.jhipster.tech/prettier-java/","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/jhipster.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null},"funding":{"open_collective":"generator-jhipster","custom":"https://www.jhipster.tech/sponsors/"}},"created_at":"2018-01-04T17:28:57.000Z","updated_at":"2025-05-11T07:12:02.000Z","dependencies_parsed_at":"2023-02-18T03:31:06.214Z","dependency_job_id":"e2519fe9-801b-4922-b75f-b3b821e246cb","html_url":"https://github.com/jhipster/prettier-java","commit_stats":{"total_commits":654,"total_committers":40,"mean_commits":16.35,"dds":0.5779816513761468,"last_synced_commit":"d18871d1ec1cc2c4b841d13d4e3e432dc7133d8b"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhipster%2Fprettier-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhipster%2Fprettier-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhipster%2Fprettier-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jhipster%2Fprettier-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jhipster","download_url":"https://codeload.github.com/jhipster/prettier-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253534443,"owners_count":21923523,"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":["java","prettier"],"created_at":"2024-08-01T03:01:10.677Z","updated_at":"2025-05-13T17:14:17.552Z","avatar_url":"https://github.com/jhipster.png","language":"Java","readme":"![Github Actions Build Status](https://github.com/jhipster/prettier-java/actions/workflows/github-ci.yml/badge.svg?branch=main)\n\n# Prettier Java\n\n![Prettier Java Banner](./logo/prettier-java-wide-dark.svg#gh-dark-mode-only)\n![Prettier Java Banner](./logo/prettier-java-wide-light.svg#gh-light-mode-only)\n\n## Intro\n\nPrettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.\n\n## How it works\n\nA Prettier plugin must first parse the source code of the target language\ninto a traversable data structure (Usually an **A**bstract **S**yntax **T**ree)\nand then print out that data structure in a \"pretty\" style.\n\nPrettier-Java uses a [Java-Parser](./packages/java-parser) implemented in JavaScript using the\n[Chevrotain Parser Building Toolkit for JavaScript](https://github.com/SAP/chevrotain).\nWhat this means is that unlike many other Prettier plugins,\n`prettier-java` has **no additional runtime pre-requisites** (e.g: Python executable).\nIt could even be used inside a browser.\n\n## Subpackages\n\nThis project contains 2 packages:\n\n- [prettier-plugin-java](./packages/prettier-plugin-java) A plugin for\n  [Prettier](https://prettier.io/) to format Java code\n\n  [![npm-prettier-plugin-java][npm-prettier-plugin-java-image]][npm-prettier-plugin-java-url]\n\n* [java-parser](./packages/java-parser) A Java Parser using [Chevrotain](https://github.com/SAP/chevrotain) which output a **C**oncrete **S**yntax **T**ree\n\n  [![npm-java-parser][npm-java-parser-image]][npm-java-parser-url]\n\n[npm-prettier-plugin-java-image]: https://img.shields.io/npm/v/prettier-plugin-java.svg?color=blue\u0026label=prettier-plugin-java\u0026logo=prettier-plugin-java\n[npm-prettier-plugin-java-url]: https://www.npmjs.com/package/prettier-plugin-java\n[npm-java-parser-image]: https://img.shields.io/npm/v/java-parser.svg?color=blue\u0026label=java-parser\u0026logo=java-parser\n[npm-java-parser-url]: https://www.npmjs.com/package/java-parser\n\n## Install\n\n### Pre-requirements\n\n- [Node version](https://nodejs.org/en/download/releases/) 10+\n- [Prettier](https://github.com/prettier/prettier)\n\n### Install Prettier and Prettier-Java plugin\n\n```bash\n# Local installation\nnpm install prettier-plugin-java --save-dev\n\n# Or globally\nnpm install -g prettier prettier-plugin-java\n```\n\nor with yarn:\n\n```bash\n# Local installation\nyarn add prettier-plugin-java --dev\n\n# Or globally\nyarn global add prettier prettier-plugin-java\n```\n\nNote: If you want to install the prettier-plugin-java globally, you should also install the prettier package globally.\n\n## Usage\n\nTo reformat all your Java files, you first need to create `.prettierrc.yaml` with following content:\n\n```yaml\nplugins:\n  - prettier-plugin-java\n```\n\nThen run:\n\n```bash\n# If you have installed the package locally\nnpx prettier --write \"**/*.java\"\n\n# Or globally\nprettier --write \"**/*.java\"\n```\n\nTo see **IDE configuration** or other advanced usage: please go to the [Advanced Usage](./docs/advanced_usage.md) section\n\n## Maven plugin\n\nA neat maven plugin for prettier-java was made by developers from HubSpot. \\\nAdd it to the `plugins` section of your `build` configuration\n\n```xml\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        \u003c!-- Find the latest version at https://github.com/jhipster/prettier-java/releases --\u003e\n        \u003cversion\u003e0.8\u003c/version\u003e\n    \u003c/plugin\u003e\n  \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\nIf you would like to use this plugin, we recommend you to check their [project](https://github.com/HubSpot/prettier-maven-plugin) as is it well documented.\n\n## Organize imports\n\nPrettier-java is currently sorting imports according to the [Google Java Style guide](https://google.github.io/styleguide/javaguide.html#s3.3-import-statements).\n\nIf you are using an IDE such as IntelliJ, you might want to configure it to match with Prettier-java.\n\nFor IntelliJ, you can use this configuration:\n![IntelliJ config](./docs/intellij_imports_config.png)\n\nYou can also import the Checkstyle configuration provided in the next section.\n\nFor VSCode with [Language Support for Java](https://marketplace.visualstudio.com/items?itemName=redhat.java), you can use this configuration (`settings.json`):\n\n```json\n{\n  \"java.completion.importOrder\": [\"#\"]\n}\n```\n\n## Checkstyle configuration\n\nYou can use Prettier in combination with other linter, like Checkstyle.\n\nHere is one [Checkstyle Prettier compatible configuration](./docs/checkstyle/checkstyle.xml) you can use to start with !\n\nYou can directly import the config into IntelliJ Idea for instance:\n\n![Import Checkstyle configuration](./docs/checkstyle/import-checkstyle-configuration.gif)\n\n## Indent configuration\n\nIn `.prettierrc.yaml`, you can configure the indent:\n\nFor using four spaces:\n\n```yaml\ntabWidth: 4\n```\n\nFor more configuration options such as using tabs, maximum line length, and more see \u003chttps://prettier.io/docs/en/configuration.html\u003e.\n\n## Contributing\n\nContributions are very welcome.\nSee the [contribution guide](./CONTRIBUTING.md) to get started.\nAnd the [Help Wanted](https://github.com/jhipster/prettier-java/labels/help%20wanted) issues.\n\n## Credits\n\nSpecial thanks to [@thorbenvh8](https://github.com/thorbenvh8) for creating the original `prettier-java`\nplugin and the associated Java Parser implemented in JavaScript.\n\nWe would also like to thank the [Chevrotain](https://github.com/SAP/chevrotain/graphs/contributors) and [Prettier](https://github.com/prettier/prettier/graphs/contributors) contributors which made this possible.\n","funding_links":["https://opencollective.com/generator-jhipster","https://www.jhipster.tech/sponsors/"],"categories":["Java","java"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhipster%2Fprettier-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjhipster%2Fprettier-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjhipster%2Fprettier-java/lists"}