|
| 1 | += java_remove(7) |
| 2 | +:doctype: manpage |
| 3 | +:mansource: JAVA_REMOVE |
| 4 | +:manmanual: Java packaging support |
| 5 | + |
| 6 | +== NAME |
| 7 | +java_remove - remove dependency declarations or annotations from Java source files |
| 8 | + |
| 9 | +== SYNOPSIS |
| 10 | +*%java_remove* [optional flags] <matcher>... [file path]... |
| 11 | + |
| 12 | +== DESCRIPTION |
| 13 | +This macro removes annotations, corresponding *import* statements and modular *requires* statements from Java source files. |
| 14 | + |
| 15 | +Annotations and import statements are matched using *-p* and *-n* flags. |
| 16 | +Modular requires statements are matched using the *-m* flag. |
| 17 | + |
| 18 | +The tool 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. |
| 19 | + |
| 20 | +In *module-info.java* files, all content following 'requires [static] [transitive]' is matched against all patterns provided via the *-m* flag. |
| 21 | + |
| 22 | +File path arguments are handled the following way: |
| 23 | + |
| 24 | +* Symlinks are ignored. |
| 25 | +* Regular files are handled regardless of the file name. |
| 26 | +* Directories are traversed recursively and all `.java` files are handled. |
| 27 | + |
| 28 | +Arguments can be specified in arbitrary order. |
| 29 | + |
| 30 | +Optional flags: |
| 31 | + |
| 32 | +*-s*, *--strict*:: |
| 33 | +Fail if any of the user provided arguments were redundant. |
| 34 | + |
| 35 | +*-a*:: |
| 36 | +Also remove annotations used in code. |
| 37 | +Annotations will be matched by the non-modular matchers. |
| 38 | + |
| 39 | +Matcher is one of: |
| 40 | + |
| 41 | +*-n <name>*:: |
| 42 | +Simple class name to be matched against the simple names of imported symbols. |
| 43 | +Names are matched for exact equality. |
| 44 | +Can be specified multiple times. |
| 45 | + |
| 46 | +*-p <pattern>*:: |
| 47 | +Regex patterns to be matched against imported symbols. |
| 48 | +Each imported symbol found in the code is matched against each pattern. |
| 49 | +Can be specified multiple times. |
| 50 | + |
| 51 | +*-m <pattern>*:: |
| 52 | +Regex pattern to match module name `requires` fields used in `module-info.java` files. |
| 53 | +Can be specified multiple times. |
| 54 | + |
| 55 | +== EXAMPLES |
| 56 | +Examples of usage in a *.spec* file: |
| 57 | + |
| 58 | +- *%java_remove module-api module-impl module-tests -s -a -n Nullable* |
| 59 | +- *%java_remove src -s -a -p org[.]jspecify[.]annotations -m org[.]jspecify* |
| 60 | + |
| 61 | +=== Import patterns: |
| 62 | +- Import statements present in Java source file: |
| 63 | + |
| 64 | + 1) import java.lang.Runnable; |
| 65 | + 2) import java.util.List; |
| 66 | + 3) import static java.util.*; |
| 67 | + 4) import static java.lang.String.valueOf; |
| 68 | + 5) import com.google.common.util.concurrent.Service; |
| 69 | + |
| 70 | +- Names used to match: |
| 71 | + |
| 72 | + Name 'Runnable' matches 1) |
| 73 | + Name 'String' matches 4) |
| 74 | + |
| 75 | + Name 'util' does not match anything. |
| 76 | + Name '*' does not match anything. |
| 77 | + Name 'valueOf' does not match anything. |
| 78 | + |
| 79 | +- Patterns used to match: |
| 80 | + |
| 81 | + Pattern 'Runnable' matches 1). |
| 82 | + Pattern '[*]' matches 3). |
| 83 | + Pattern 'java[.]util' matches 2), 3). |
| 84 | + Pattern 'util' matches 2), 3), 5). |
| 85 | + Patterns 'java', 'java.*' match 1) - 4). |
| 86 | + |
| 87 | + Pattern 'static' does not match anything. |
| 88 | + |
| 89 | +=== Annotations |
| 90 | +- Annotations present in Java source file: |
| 91 | + |
| 92 | + 1) @SuppressWarnings |
| 93 | + 2) @SuppressFBWarnings(value = {"EI_EXPOSE_REP", "EI_EXPOSE_REP2"}) |
| 94 | + 3) @org.junit.Test |
| 95 | + 4) @org.junit.jupiter.api.Test |
| 96 | + |
| 97 | +- Names used to match: |
| 98 | + |
| 99 | + Name 'SuppressWarnings' matches 1) |
| 100 | + Name 'Test' matches 3), 4). |
| 101 | + |
| 102 | + Name 'junit' does not match anything. |
| 103 | + |
| 104 | +- Patterns used to match: |
| 105 | + |
| 106 | + Pattern 'SuppressWarnings' matches 1). |
| 107 | + Pattern 'Suppress' matches 1), 2). |
| 108 | + Pattern 'org[.]junit[.]Test' matches 3). |
| 109 | + Pattern 'junit' matches 3), 4). |
| 110 | + |
| 111 | + Pattern '@SuppressWarnings' does not match anything. |
| 112 | + Pattern 'EI_EXPOSE_REP' does not match anything. |
| 113 | + |
| 114 | +== REPORTING BUGS |
| 115 | +Bugs should be reported through the issue tracker at GitHub: https://github.com/fedora-java/jurand/issues. |
| 116 | + |
| 117 | +== AUTHOR |
| 118 | +Written by Marián Konček. |
| 119 | + |
| 120 | +== SEE ALSO |
| 121 | +*jurand*(1). |
0 commit comments