renaming all packages using eclipse:
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.
renaming all packages using a custom java program:
i wrote a java program which performs following steps:
- in the first iteration through all directories it copied all folders to a new directory with only lowercase names (the first subpackage was completely renamed to prevent problems on windows hosts).
- then the program started a second iteration through the new directory and renamed all import packages in java files. for most imports this is quiet simple but i needed to use reflection to correctly rename static imports and imports of enums in java classes e.g
- the next step of the program was to rename all other occurrences of the old package names found in eclipse e.g. testng xml files, ...
- the last step was to delete the old folders.
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.
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
this can be performed with two steps using an intermediate package name:
- right-click on the package
main.mypackages.utilsand select refactor -> rename...
rename subpackagesif you have subpackages) and click ok
now repeat the same and rename
- How to rename all package names to lowercase
- How to rename entire java package name in Eclipse so that its all occurences gets renamed?
- In Eclipse, how do you rename / refactor all names that occur AFTER the current one
- How to rename a package in all source folders with Eclipse?
- In Eclipse, how can I export a package and all sub-packages as a jar?
- How to rename a package in Eclipse with Subversive correctly?
- How to show shortened project names in the Eclipse package explorer?
- How can I run all junit tests in a package and below (recursively) by right clicking the package on eclipse and selecting "Run as JUnit test"
- how to change all package name in Eclipse?
- How do you get the Eclipse Package Explorer to show files whose names begins with a . (period)?
- How to run all TestNG test in a package in Eclipse?
- How to rename 1000 class names in a Java project (Eclipse or others)?
- How can I handle package names better while building a suite of android applications
- How can I rename package name without getting any errors/conflicts, if using the android tools to do it
- How to compare all file names from a given directory java?
- How to package all resources into runnable JAR in Eclipse
- Rename all Java classes in a package (In Eclipse)
- How do I get all the class names and method names of a project?
- How do I rename all Scanners or object?
- How to view hierarchical package structure in Eclipse package explorer
- How do I show an open file in eclipse Package Explorer?
- How to format all Java files in an Eclipse project at one time?
- How to change package name of Android Project in Eclipse?
- How can I configure the font size for the tree item in the package explorer in Eclipse?
- How to stop Eclipse formatter from placing all enums on one line
- In Eclipse, what can cause Package Explorer "red-x" error-icon when all Java sources compile without errors?
- What does the > (greater than bracket) mean beside file names in Eclipse's Package Explorer?
- How to get current class name including package name in Java?
- eclipse workspace: how to rename workspace
- How to view all the breakpoints in eclipse?
More Query from same tag
- "paste" listener on a SWT widget
- Mylyn Redmine Connector Zend Studio 9.x/Eclipse where is it?
- classNotFoundException: com.hp.hpl.jena.ontology.OntModelSpec
- Reduce Phonegap project size (Android)
- Exported JAR file does not show images
- Zend Studio/Eclipse shows expanded folder names
- Syntax error on token(s), misplaced construct(s)
- How to test our chrome extention with selenium tool?
- Android Eclipse Juno or ADT from Android developers site Ubuntu 12.04
- AngularJS-Eclipse : My controllers not found
- error while giving maven clean. working on git plgin
- Global Variables Android
- Eclipse Android project SVN checkout: folder locked
- Eclipse plug-in popup's action initial availability
- How to properly use malloc() to store many integer values?
- File > Open file is not working with me or I dont know how
- startActivityForResult with an enum
- Opening log4j Debug console in Eclipse
- exception in thread "main" java.lang.NoSuchMethodError scala.collection.immutable.hashset$
- What do the egit merge modes mean?
- Checking out Maven project from SVN in Eclipse
- Referenced Java Project Compiled Update Doesn't Update Android Library Project
- Phonegap - Upgrade to 3.0 with Eclipse?
- Can't increase Scala Eclipse heap size
- GNU make stops without error before makefile is finished
- Eclipse dll breakpoint
- Why doesn't linking work in my Xtext-based DSL?
- 'API Tools Javadoc Proposals' issue in eclipse
- Eclipse not generating files in new Android Project
- Passing database data to another activity