Skip to content

Commit 0295105

Browse files
committed
ICU-22921 Document a way to remove unused includes from command line
1 parent 494e8cd commit 0295105

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/processes/release/tasks/healthy-code.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,37 @@ the UTF-8 signature byte sequence ("BOM").~~
126126
127127
## Clean up import statements
128128
129+
### From command line
130+
131+
This can be done from command line using the
132+
[Google Java Format](https://github.com/google/google-java-format) tool.
133+
134+
**WARNING:** requires JDK 17 or newer (December 2024)
135+
136+
Download the latest Google Java Format from Maven Central:
137+
```sh
138+
mvn dependency:copy -Dartifact=com.google.googlejavaformat:google-java-format:LATEST:jar:all-deps \
139+
-DoutputDirectory=/tmp \
140+
-Dmdep.stripVersion=true \
141+
-q -ntp
142+
```
143+
144+
Cleanup all Java files (only imports, nothing else):
145+
```sh
146+
find . -type f -name '*.java' | xargs java -jar /tmp/google-java-format-all-deps.jar -i --aosp --fix-imports-only --skip-sorting-imports
147+
```
148+
149+
Remove the Google Java Format artifact from the temporary folder:
150+
```sh
151+
rm /tmp/google-java-format-all-deps.jar
152+
```
153+
154+
You can (of course) download it from
155+
[GitHub Releases](https://github.com/google/google-java-format/releases). \
156+
Or save it in a personal tools folder and keep it around.
157+
158+
### From Eclipse
159+
129160
The Eclipse IDE provides a feature which allow you to organize import statements
130161
for multiple files. Right click on projects/source folders/files, you can select
131162
\[Source\] - \[Organize Imports\] which resolve all wildcard imports and sort

0 commit comments

Comments
 (0)