Copy class + package context between projects in Eclipse

For several uninteresting reasons: we need to copy many classes from one project to another (preserving the package structure of the specified classes).

In other words, given:

origin/src/com/foo/bar/A origin/src/com/baz/qux/B dest/ <empty> 

We want to copy A and B so that in the end it turns out:

 dest/src/com/foo/bar/A dest/src/com/baz/qux/B 

Currently, we are forced to manually create packages in dest , and then Ctrl+C/Ctrl+V separate .java files between projects. We would like Eclipse to automatically copy files when automatically creating packages (hence preserving the package structure).

+4
source share
2 answers

There is currently no clean pre-prepared solution for this. The answer is to write a script using any language you choose.

This is exactly what I did: using Python.

+2
source

You can simply copy files between project folders using a shell script. Eclipse will collect copied java files, including the package structure.

If you select all the files in the source project on the panel of the Navigator window (not in the package explorer), you can have CTRL + C / V the whole file structure, saving the packages in the new project.

+4
source

All Articles