java_remove_annotations - Man Page
remove imports and annotations from Java source files
Synopsis
%java_remove_annotations [optional flags] <matcher>... [file path]...
Description
This macro removes import statements as well as usage of annotations from Java source files. The does the same as java_remove_imports and on top of that finds all uses of annotations and matches the content between the '@' symbol and either ending with whitespace or with an opening parethesis '(' (the annotation arguments).
In case of match, the script also removes the block of paretheses that follows the matched annotation, if it is present.
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_annotations src -n Nullable
Examples of patterns:
Annotations present in Java source file:
1) @SuppressWarnings 2) @SuppressFBWarnings(value = {"EI_EXPOSE_REP", "EI_EXPOSE_REP2"}) 3) @org.junit.Test 4) @org.junit.jupiter.api.Test
Names used to match:
Name 'SuppressWarnings' matches 1) Name 'Test' matches 3), 4).
Name 'junit' does not match anything.
Patterns used to match:
Pattern 'SuppressWarnings' matches 1). Pattern 'Suppress' matches 1), 2). Pattern 'org[.]junit[.]Test' matches 3). Pattern 'junit' matches 3), 4).
Pattern '@SuppressWarnings' does not match anything. Pattern 'EI_EXPOSE_REP' 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.