In Eclipse, how to copy an existing project to another project?
In Eclipse, I have one existing project, A. Right now, I have just created ano开发者_开发问答ther project, B, which is empty. Is it possible to copy all the files of project A, including its source code and related libraries to project B? There are a lot of involved libraries in project A. How to do this copying process correctly to ensure the copied files can still be compiled?
This question appears in Google search as top result for query "copy project in eclipse".
To copy project in Eclipse:
1) right click on project in Package Explorer view;
2) choose Copy;
3) right click on free place in Package Explorer view;
4) choose Paste;
5) enter new name in the prompt window.
To answer actual question, the best way is to delete project B and after -- copy project A as explained above and give it name B.
- Close Eclipse
- Copy the folder of existing project to anywhere on your disk.
- Start Eclipse. Turn off the automatically build.
- In the Eclipse do Refactor / Rename to the new project name. (If it connected to CVS/SVN disconnect before rename.)
- Import back the old project from place where you copied in the second step.
- Turn on the automatically build.
Enjoy them!
You can Import the project
OR
Assuming both project A and B are of same type:
You can copy the contents of src
folder as it is.
For the libraries, just go to the build path and add them in the ssame way you did for project A.
Since B is empty, you can just copy project A in the Package Explorer and name the copy B.
- Create a duplicate/copy of an existing project (in the workspace).
- Then in Eclipse, click file->import
- Select import existing projects into workspace
- Check the radio button "Select root directory"
- Browse your project (the new file you copied in workspace in step 1)
- Done!
In the project Explorer, right click your old project, click "Copy", right click again click on "Paste" this time, change the default given name "Copy of My_Old_Project" to any of your choice, after the copy is done, go to the "Search" tab in Eclipse, then to --> "Search", on the File Search, type the old name of your project, make sure that your scope is only "Enclosing project", change all occurrences into the new name, run the project, you are all set...
only thing I noticed about this is that the url will still be of the old project.
For a Gradle project, I had to add two extra steps to mOna's answer, which I will copy for completeness.
- Create a duplicate/copy of an existing project (in the workspace).
- Then in Eclipse, click file->import
- Select import existing projects into workspace
- Check the radio button "Select root directory"
- Browse your project (the new file you copied in workspace in step 1)
- Edit .project file and change the and the to match the new project.
- Edit settings.gradle and change rootProject.name to match the new project.
I assume that the renaming in some of the above answers does step 6, but I couldn't get it to work. No matter what I tried, without those extra steps the code looked ok but dependencies were not handled correctly and errors appeared everywhere. I was even able to run gradle on my project from the command line and it "built", but was actually building the old project.
Eclipse has a option in file menu like import existing projec.From that you can import the existing project with all content.I hope this is the solution that you are looking for.
精彩评论