Skip to content

Commit

Permalink
ICU-22921 Document a way to remove unused includes from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
mihnita authored and Squash Bot committed Dec 12, 2024
1 parent 515d0a7 commit d1e9c9e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/processes/release/tasks/healthy-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,37 @@ the UTF-8 signature byte sequence ("BOM").~~
## Clean up import statements
### From command line
This can be done from command line using the
[Google Java Format](https://github.com/google/google-java-format) tool.
**WARNING:** requires JDK 17 or newer (December 2024)
Download the latest Google Java Format from Maven Central:
```sh
mvn dependency:copy -Dartifact=com.google.googlejavaformat:google-java-format:LATEST:jar:all-deps \
-DoutputDirectory=/tmp \
-Dmdep.stripVersion=true \
-q -ntp
```
Cleanup all Java files (only imports, nothing else):
```sh
find . -type f -name '*.java' | xargs java -jar /tmp/google-java-format-all-deps.jar -i --aosp --fix-imports-only --skip-sorting-imports
```
Remove the Google Java Format artifact from the temporary folder:
```sh
rm /tmp/google-java-format-all-deps.jar
```
You can (of course) download it from
[GitHub Releases](https://github.com/google/google-java-format/releases). \
Or save it in a personal tools folder and keep it around.
### From Eclipse
The Eclipse IDE provides a feature which allow you to organize import statements
for multiple files. Right click on projects/source folders/files, you can select
\[Source\] - \[Organize Imports\] which resolve all wildcard imports and sort
Expand Down

0 comments on commit d1e9c9e

Please sign in to comment.