[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4330":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":16,"starSnapshotCount":16,"syncStatus":32,"lastSyncTime":33,"discoverSource":34},4330,"google-java-format","google\u002Fgoogle-java-format","google","Reformats Java source code to comply with Google Java Style.","",null,"Java",6144,919,131,139,0,1,3,23,4,70.69,"Other",false,"master",true,[27,28],"formatter","java","2026-06-12 04:00:22","# google-java-format\n\n`google-java-format` is a program that reformats Java source code to comply with\n[Google Java Style][].\n\n[Google Java Style]: https:\u002F\u002Fgoogle.github.io\u002Fstyleguide\u002Fjavaguide.html\n\n## Using the formatter\n\n### From the command-line\n\n[Download the formatter](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgoogle-java-format\u002Freleases)\nand run it with:\n\n```\njava -jar \u002Fpath\u002Fto\u002Fgoogle-java-format-${GJF_VERSION?}-all-deps.jar \u003Coptions> [files...]\n```\n\nNote that it uses the `jdk.compiler` module to parse the Java source code. The\n`java` binary version used must therefore be from a JDK (not JRE) with a version\nequal to or newer than the Java language version of the files being formatted.\nThe minimum Java version can be found in `core\u002Fpom.xml` (currently Java 21). An\nalternative is to use the available GraalVM based native binaries instead.\n\nThe formatter can act on whole files, on limited lines (`--lines`), on specific\noffsets (`--offset`), passing through to standard-out (default) or altered\nin-place (`--replace`).\n\nOption `--help` will print full usage details; including built-in documentation\nabout other flags, such as `--aosp`, `--fix-imports-only`,\n`--skip-sorting-imports`, `--skip-removing-unused-import`,\n`--skip-reflowing-long-strings`, `--skip-javadoc-formatting`, or the `--dry-run`\nand `--set-exit-if-changed`.\n\nUsing `@\u003Cfilename>` reads options and filenames from a file, instead of\narguments.\n\nTo reformat changed lines in a specific patch, use\n[`google-java-format-diff.py`](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgoogle-java-format\u002Fblob\u002Fmaster\u002Fscripts\u002Fgoogle-java-format-diff.py).\n\n***Note:*** *There is no configurability as to the formatter's algorithm for\nformatting. This is a deliberate design decision to unify our code formatting on\na single format.*\n\n### IntelliJ, Android Studio, and other JetBrains IDEs\n\nA\n[google-java-format IntelliJ plugin](https:\u002F\u002Fplugins.jetbrains.com\u002Fplugin\u002F8527)\nis available from the plugin repository. To install it, go to your IDE's\nsettings and select the `Plugins` category. Click the `Marketplace` tab, search\nfor the `google-java-format` plugin, and click the `Install` button.\n\nThe plugin will be disabled by default. To enable,\n[open the Project settings](https:\u002F\u002Fwww.jetbrains.com\u002Fhelp\u002Fidea\u002Fconfigure-project-settings.html),\nthen click \"google-java-format Settings\" and check the \"Enable\ngoogle-java-format\" checkbox.\n\nTo enable it by default in new projects,\n[open the default settings for new projects](https:\u002F\u002Fwww.jetbrains.com\u002Fhelp\u002Fidea\u002Fconfigure-project-settings.html#new-default-settings)\nand configure it under \"Other Settings\u002Fgoogle-java-format Settings\".\n\nWhen enabled, it will replace the normal `Reformat Code` and `Optimize Imports`\nactions.\n\n#### IntelliJ JRE Config\n\nThe google-java-format plugin uses some internal classes that aren't available\nwithout extra configuration. To use the plugin, you need to\n[add some options to your IDE's Java runtime](https:\u002F\u002Fwww.jetbrains.com\u002Fhelp\u002Fidea\u002Ftuning-the-ide.html#procedure-jvm-options).\nTo do that, go to `Help→Edit Custom VM Options...` and paste in these lines:\n\n```\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.api=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.code=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.file=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.parser=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.tree=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.util=ALL-UNNAMED\n```\n\nOnce you've done that, restart the IDE.\n\n### Eclipse\n\nThe latest version of the `google-java-format` Eclipse plugin can be downloaded\nfrom the [releases page](https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fgoogle-java-format\u002Freleases).\nDrop it into the Eclipse\n[drop-ins folder](http:\u002F\u002Fhelp.eclipse.org\u002Fneon\u002Findex.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fp2_dropins_format.html)\nto activate the plugin.\n\nThe plugin adds two formatter implementations:\n\n*   `google-java-format`: using 2 spaces indent\n*   `aosp-java-format`: using 4 spaces indent\n\nThese that can be selected in \"Window\" > \"Preferences\" > \"Java\" > \"Code Style\" >\n\"Formatter\" > \"Formatter Implementation\".\n\n#### Eclipse JRE Config\n\nThe plugin uses some internal classes that aren't available without extra\nconfiguration. To use the plugin, you will need to edit the\n[`eclipse.ini`](https:\u002F\u002Fwiki.eclipse.org\u002FEclipse.ini) file.\n\nOpen the `eclipse.ini` file in any editor and paste in these lines towards the\nend (but anywhere after `-vmargs` will do):\n\n```\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.api=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.code=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.file=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.parser=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.tree=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.util=ALL-UNNAMED\n```\n\nOnce you've done that, restart the IDE.\n\n### Third-party integrations\n\n*   Visual Studio Code\n    *   [google-java-format-for-vs-code](https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=JoseVSeb.google-java-format-for-vs-code)\n*   Gradle plugins\n    *   [spotless](https:\u002F\u002Fgithub.com\u002Fdiffplug\u002Fspotless\u002Ftree\u002Fmain\u002Fplugin-gradle#google-java-format)\n    *   [sherter\u002Fgoogle-java-format-gradle-plugin](https:\u002F\u002Fgithub.com\u002Fsherter\u002Fgoogle-java-format-gradle-plugin)\n*   Apache Maven plugins\n    *   [spotless](https:\u002F\u002Fgithub.com\u002Fdiffplug\u002Fspotless\u002Ftree\u002Fmain\u002Fplugin-maven#google-java-format)\n    *   [spotify\u002Ffmt-maven-plugin](https:\u002F\u002Fgithub.com\u002Fspotify\u002Ffmt-maven-plugin)\n    *   [talios\u002Fgoogleformatter-maven-plugin](https:\u002F\u002Fgithub.com\u002Ftalios\u002Fgoogleformatter-maven-plugin)\n    *   [Cosium\u002Fmaven-git-code-format](https:\u002F\u002Fgithub.com\u002FCosium\u002Fmaven-git-code-format):\n        A maven plugin that automatically deploys google-java-format as a\n        pre-commit git hook.\n*   SBT plugins\n    *   [sbt\u002Fsbt-java-formatter](https:\u002F\u002Fgithub.com\u002Fsbt\u002Fsbt-java-formatter)\n*   [Github Actions](https:\u002F\u002Fgithub.com\u002Ffeatures\u002Factions)\n    *   [googlejavaformat-action](https:\u002F\u002Fgithub.com\u002Faxel-op\u002Fgooglejavaformat-action):\n        Automatically format your Java files when you push on github\n\n### as a library\n\nThe formatter can be used in software which generates java to output more\nlegible java code. Just include the library in your maven\u002Fgradle\u002Fetc.\nconfiguration.\n\n`google-java-format` uses internal javac APIs for parsing Java source. The\nfollowing JVM flags are required when running on JDK 16 and newer, due to\n[JEP 396: Strongly Encapsulate JDK Internals by Default](https:\u002F\u002Fopenjdk.java.net\u002Fjeps\u002F396):\n\n```\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.api=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.code=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.file=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.parser=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.tree=ALL-UNNAMED\n--add-exports=jdk.compiler\u002Fcom.sun.tools.javac.util=ALL-UNNAMED\n```\n\n#### Maven\n\n```xml\n\u003Cdependency>\n  \u003CgroupId>com.google.googlejavaformat\u003C\u002FgroupId>\n  \u003CartifactId>google-java-format\u003C\u002FartifactId>\n  \u003Cversion>${google-java-format.version}\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n#### Gradle\n\n```groovy\ndependencies {\n  implementation 'com.google.googlejavaformat:google-java-format:$googleJavaFormatVersion'\n}\n```\n\nYou can then use the formatter through the `formatSource` methods. E.g.\n\n```java\nString formattedSource = new Formatter().formatSource(sourceString);\n```\n\nor\n\n```java\nCharSource source = ...\nCharSink output = ...\nnew Formatter().formatSource(source, output);\n```\n\nYour starting point should be the instance methods of\n`com.google.googlejavaformat.java.Formatter`.\n\n## Building from source\n\n```\nmvn install\n```\n\n## Contributing\n\nPlease see [the contributors guide](CONTRIBUTING.md) for details.\n\n## License\n\n```text\nCopyright 2015 Google Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not\nuse this file except in compliance with the License. You may obtain a copy of\nthe License at\n\n    http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\nWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\nLicense for the specific language governing permissions and limitations under\nthe License.\n```\n","google-java-format 是一个用于将 Java 源代码格式化为符合 Google Java 代码风格的工具。它基于 JDK 的编译器模块解析 Java 代码，并支持多种命令行选项，如仅格式化特定行、偏移量处理、直接输出或就地替换等，但不提供对格式化算法的自定义配置。此外，该项目还提供了 IntelliJ IDEA 和其他 JetBrains IDEs 的插件版本，方便开发者在集成开发环境中一键格式化代码。适用于需要统一团队内 Java 代码风格的场景，特别是遵循 Google 编码规范的项目。",2,"2026-06-11 02:59:40","top_language"]