Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU-22921 Document a way to remove unused includes from command line #3298

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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