java_remove_imports - Man Page
remove import statements from Java source files
Synopsis
%java_remove_imports [optional flags] <matcher>... [file path]...
Description
This macro removes import statements from Java source files. The script matches all non-whitespace content following the 'import [static]' statement against all patterns provided via the -p flag and all simple class names against names provided by the -n flag.
File path arguments are handled the following way:
- Symlinks are ignored.
- Regular files are handled regardless of the file name.
- Directories are traversed recursively and all
.java
files are handled.
Arguments can be specified in arbitrary order.
Matcher is one of:
- -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.
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.
Reporting Bugs
Bugs should be reported through the issue tracker at GitHub: https://github.com/fedora-java/jurand/issues.
Author
Written by Marián Konček.