I am looking for ways to remove all the annotations from existing Java Source Code. I am looking for an ant task or any other approach. I have seen some solutions that do this at the class level, but I am looking to do this at the source code to source code level.
2 Answers
I ended up using JEdit which has brilliant regular expression support.
I wanted to replace specific annotations (I wanted to keep stuff like @Override). You can easily do that for all buffers or a directory tree.
Just write some simple expressions for the annotations you want to remove. For example
^\s*@NamedQueries\(\n\{[^\}]+\}\)\n
grep -vor some cleversed, but it would help to know what you are trying to achieve, because annotations are used for a lot of different things today, and to remove them all indiscriminately is potentially a bad idea...