For a number of uninteresting reasons: we need to copy many classes from one project to another (while preserving the package-structure of said 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 such that we end up with:
dest/src/com/foo/bar/A
dest/src/com/baz/qux/B
Presently, we are forced to manually create the packages in dest
and then Ctrl+C/Ctrl+V
the individual .java files between projects. What we would like to do is to have Eclipse automatically copy the files over while automatically creating the packages (hence, preserving the package structure).
Select the package in the project explorer, press Ctrl+C and then Ctrl+V, Eclipse will prompt with a package name conflict warning and ask you to enter a new package name. Just enter it and Eclipse will repackage all copied classes accordingly.
An Eclipse project has nothing to do with Java. It is a feature of Eclipse to organize and configure your different projects. A Java package is a language feature of Java. You can use them to structure your project and control visibility between different classes.
You can just copy the files between your project folders using a shell script. Eclipse will pick up the copied java files including the package structure.
If you select all the files in the source project in Navigator Window panel (not Package Explorer) you should be able to CTRL+C/V the whole file structure preserving packages to a new project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With