Reputation: 1734
I have a large project with many packages that are CamelCase. I want to rename all of them to lowercase e.g:
main.MyPackages.Utils
to main.mypackages.utils
What is the best/fastest way to do so?
Is there a better way than the two mentioned approaches? If not I will go with approach two. Maybe using a UNIX OS would be better.
Upvotes: 3
Views: 1614
Reputation: 1734
I tried to rename the packages using Eclipse. Soon enough I faced the problem with this approach. First merge of master branch in my local branch restored all old packages again. The idea was to rename the packages on a weekend when no one works on the project. But it still would have taken 5+ hours per branch and I had to change at least the master and the last release branch to prevent merge conflicts. I realized that this does not work in my case.
I wrote a Java program which performs following steps:
import my.package.MyClass.MyEnum
. The runtime of the program is about 2 minutes per branch. The updated project compiles and I did not face any issues.
I did not add any code because the program is only working for this project. Maybe it still helps someone.
Upvotes: 1
Reputation: 39536
This can be performed with two steps using an intermediate package name:
main.MyPackages.Utils
and select Refactor -> Rename...main.mypackages2.utils2
(check Rename subpackages
if you have subpackages) and click OKNow repeat the same and rename main.mypackages2.utils2
to main.mypackages.utils
.
Upvotes: 0
Reputation: 1
In my case i use IntelliJ Idea IDE and refactoring mentioned is lot easier. You just have to right click and change the package name as you mentioned, this will update package name every where this was being used. Let me know if it works. See the screenshot for reference
Upvotes: 0