Eclipse - How to “Change package declaration to …” across an entire project

后端 未结 7 1003
暗喜
暗喜 2020-12-25 14:00

I\'ve just imported a large amount of source code into Eclipse and basically the package name is no longer valid (the code has been moved folders). Is there a way to select

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-25 14:45

    It is an old question, but I ran into the same problem and wrote a very simple bash script. Hope it will help someone.

    for i in *.java; do
        sed -i 's/.*package com.example.something;.*/package com.example.something_else;/' $i
    done
    

    Basically, the script traverses all java files inside a directory, and each occurrence of package com.example.something; replaces with package com.example.something_else;.

提交回复
热议问题