JAVA_REMOVE_IMPORTS(7)
π JAVA_REMOVE_IMPORTS π
okay bestie, welcome to java_remove_imports, part of the Java packaging support squad, section 7 of the manual. she's a macro, she's iconic, and she's about to yeet your import statements into the sun. let's get into it β¨
πΈ NAME πΈ
java_remove_imports β remove import statements from Java source files π§Ήβ¨
π SYNOPSIS π
%java_remove_imports [optional flags] <matcher>... [file path]...
π DESCRIPTION π
so this macro removes import statements from Java source files. that's the whole vibe. π
here's the tea on how she decides what to delete: the script takes all the non-whitespace content that comes after the import [static] statement and matches it against every pattern you handed over with the -p flag. meanwhile, all the simple class names get matched against the names you gave with the -n flag. two lanes, both working at the same time. slay. π
π¦ how file paths get handled π¦
file path arguments are handled the following way, no cap:
- symlinks are ignored. we simply do not see them. π
- regular files are handled regardless of the file name. doesn't matter what you called it, she's gonna look.
- directories get traversed recursively and all
.javafiles are handled. all of them. every single one. π
and yes, arguments can be specified in arbitrary order. you do you, boo. π«Ά
β matcher (one of these) β
-n<name> β simple class name to be matched against the simple names of imported symbols. names are matched for exact equality. can be specified multiple times. π«-p<pattern> β regex patterns to be matched against imported symbols. each imported symbol found in the code is matched against each pattern. can be specified multiple times. π₯
β¨ optional flags β¨
-s,--strictβ fail if any of the user provided arguments were redundant. she's checking your work, bestie. don't waste her time. π
π EXAMPLES π
example of usage in a .spec file:
%java_remove_imports src -n Nullable
examples of patterns:
- import statements present in Java source file:
1) import java.lang.Runnable;
2) import java.util.List;
3) import static java.util.*;
4) import static java.lang.String.valueOf;
5) import com.google.common.util.concurrent.Service;
- names used to match:
Name 'Runnable' matches 1)
Name 'String' matches 4)
Name 'util' does not match anything.
Name '*' does not match anything.
Name 'valueOf' does not match anything.
- patterns used to match:
Pattern 'Runnable' matches 1).
Pattern '[*]' matches 3).
Pattern 'java[.]util' matches 2), 3).
Pattern 'util' matches 2), 3), 5).
Patterns 'java', 'java.*' match 1) - 4).
Pattern 'static' does not match anything.
see how 'Runnable' and 'String' pulled their weight but 'util', '*' and 'valueOf' did absolutely nothing? that's the exact energy --strict is gonna clock. π
π REPORTING BUGS π
found a bug? bugs should be reported through the issue tracker at GitHub:
https://github.com/fedora-java/jurand/issues
please do it there, not in my DMs. π
π AUTHOR π
written by MariΓ‘n KonΔek. king behavior, fr fr. π
π«Ά SEE ALSO π«Ά
okay that's the whole page bestie, go forth and de-import β¨
this has been JAVA_REMOVE_IMPORTS π from 2025-07-24 π filed under JAVA_REMOVE_IMPORTS(7) π mwah, take care of her π
π¦ where this page comes from
- fedora 43: jurand 1.3.5-2.fc43 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms