In Eclipse, how to copy an existing project to another project?

天涯浪子 提交于 2021-01-21 06:21:05

问题


In Eclipse, I have one existing project, A. Right now, I have just created another 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?


回答1:


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.




回答2:


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.




回答3:


  1. Close Eclipse
  2. Copy the folder of existing project to anywhere on your disk.
  3. Start Eclipse. Turn off the automatically build.
  4. In the Eclipse do Refactor / Rename to the new project name. (If it connected to CVS/SVN disconnect before rename.)
  5. Import back the old project from place where you copied in the second step.
  6. Turn on the automatically build.

Enjoy them!




回答4:


Since B is empty, you can just copy project A in the Package Explorer and name the copy B.




回答5:


  1. Create a duplicate/copy of an existing project (in the workspace).
  2. Then in Eclipse, click file->import
  3. Select import existing projects into workspace
  4. Check the radio button "Select root directory"
  5. Browse your project (the new file you copied in workspace in step 1)
  6. Done!



回答6:


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.




回答7:


For a Gradle project, I had to add two extra steps to mOna's answer, which I will copy for completeness.

  1. Create a duplicate/copy of an existing project (in the workspace).
  2. Then in Eclipse, click file->import
  3. Select import existing projects into workspace
  4. Check the radio button "Select root directory"
  5. Browse your project (the new file you copied in workspace in step 1)
  6. Edit .project file and change the and the to match the new project.
  7. 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.




回答8:


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.



来源:https://stackoverflow.com/questions/6133270/in-eclipse-how-to-copy-an-existing-project-to-another-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!