开发者社区 问答 正文

项目中怎样deprecate整个java 包

老板要求把整个 java包 deprecate掉. 这个以前没弄过. 我想要做的是: 把包下的所有 class, interface deprecate掉; 在package.html里加说明.还有别的要注意的么, 或者还有别的方式? 谢谢

展开
收起
蛮大人123 2016-02-29 15:26:33 2460 分享 版权
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪

    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
    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:
    screenshot
    Then, press Replace, and fill it out like this:
    screenshot

    2019-07-17 18:50:22
    赞同 展开评论
问答分类:
问答标签:
问答地址: