Friday, August 23, 2013

Refactor package change on whole project (JAVA) or Change package/import of whole project

Some times in our application development we will come across situation like changing the package structure of the project. As all classes present in the project are having the old package and import statement declaration, we have to change it manually or by using some editor.
eclipse is not having any option to change the package/import statement dynamically on structure change, we have to write some code to do the job of converting or by script.
I have written Ant target which will to the job ;)

old package : xxx.yyy

new package :

after running below ant target it will change all java classes package/import statement to latest structure. Ant Script :