是否存在用于在Java项目上优化导入的命令行工具?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了是否存在用于在Java项目上优化导入的命令行工具?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1637字,纯文字阅读大概需要3分钟。
内容图文
![是否存在用于在Java项目上优化导入的命令行工具?](/upload/InfoBanner/zyjiaocheng/679/05292ed2c1eb40df86090e17c5b6a2f6.jpg)
我正在寻找一种工具,该工具可自动在代码库上优化导入过程.大多数IDE(例如IntelliJ)都可以使用此工具,该工具可以删除未使用的导入并将任何.*导入扩展为代码专门使用的那些.
我想将其添加为MVN目标或Ant Task,或者将其添加为提交/推送之前可以运行的内容.
也许有一种在命令行上运行IntelliJ的方法来专门执行此功能,但是我还没有找到这样的命令.
解决方法:
如果您正在寻找用于优化Java导入的命令行工具,请签出Google Java Style Formatter.它提供了一个修复导入的选项:
$java -jar google-java-format-1.4-all-deps.jar
no files were provided
Usage: google-java-format [options] file(s)
Options:
-i, -r, -replace, --replace
Send formatted output back to files, not stdout.
-
Format stdin -> stdout
--aosp, -aosp, -a
Use AOSP style instead of Google Style (4-space indentation)
--fix-imports-only
Fix import order and remove any unused imports, but do no other formatting.
--skip-sorting-imports
Do not fix the import order. Unused imports will still be removed.
--skip-removing-unused-imports
Do not remove unused imports. Imports will still be sorted.
--length, -length
Character length to format.
--lines, -lines, --line, -line
Line range(s) to format, like 5:10 (1-based; default is all).
--offset, -offset
Character offset to format (0-based; default is all).
--help, -help, -h
Print this usage statement
--version, -version, -v
Print the version.
If -i is given with -, the result is sent to stdout.
The --lines, --offset, and --length flags may be given more than once.
The --offset and --length flags must be given an equal number of times.
If --lines, --offset, or --length are given, only one file (or -) may be given.
google-java-format: Version 1.0
https://github.com/google/google-java-format
内容总结
以上是互联网集市为您收集整理的是否存在用于在Java项目上优化导入的命令行工具?全部内容,希望文章能够帮你解决是否存在用于在Java项目上优化导入的命令行工具?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。