Mark all from java packages as @Depracated in eclipse

deprecated, eclipse, java

Solution

You could use `sed` to mark all classes in the current directory and below (tested in Cygwin). Navigate to the desired folder and run:

for file in $(find . -name *.java); do sed -i 's/\(public class\)/@Deprecated\n\1/g' $file; done

To also mark interfaces just add it like this:

for file in $(find . -name *.java); do sed -i 's/\(\(public class\|interface\)\)/@Deprecated\n\1/g' $file; done

EDIT

As @ŁukaszRzeszotarski points out, you can do this in Eclipse with the Search/Replace tool. Just mark the resources where you want to perform the operations, then press `Ctrl + h`. Fill it out like this:

Then, press `Replace`, and fill it out like this:

All done!

Problem

Is it a way to automatically mark the whole content of java package (subpackages, classes, methods, members) as `@Depracated` using eclipse (preferably) or any other tool if there is too many files to make it manually.

Original source