在 Eclipse 中,如何将现有项目复制到另一个项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6133270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
In Eclipse, how to copy an existing project to another project?
提问by bit-question
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?
在 Eclipse 中,我有一个现有项目 A。现在,我刚刚创建了另一个项目 B,它是空的。是否可以将项目 A 的所有文件,包括其源代码和相关库复制到项目 B?项目A中涉及的库比较多,如何正确进行这个复制过程,保证复制出来的文件仍然可以编译?
采纳答案by Bhushan
You can Import the project
您可以导入项目
OR
或者
Assuming both project A and B are of same type:
假设项目 A 和 B 的类型相同:
You can copy the contents of src
folder as it is.
您可以src
按原样复制文件夹的内容。
For the libraries, just go to the build path and add them in the ssame way you did for project A.
对于库,只需转到构建路径并以与项目 A 相同的方式添加它们。
回答by yurin
This question appears in Google search as top result for query "copy project in eclipse".
此问题出现在 Google 搜索中,作为查询“在 eclipse 中复制项目”的最高结果。
To copy project in Eclipse:
在 Eclipse 中复制项目:
1) right click on project in Package Explorer view;
1) 在 Package Explorer 视图中右键单击项目;
2) choose Copy;
2)选择复制;
3) right click on free place in Package Explorer view;
3) 在包资源管理器视图中右键单击空闲位置;
4) choose Paste;
4)选择粘贴;
5) enter new name in the prompt window.
5) 在提示窗口中输入新名称。
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.
要回答实际问题,最好的方法是删除项目 B,然后按照上述说明复制项目 A 并将其命名为 B。
回答by m_and_m
- Close Eclipse
- Copythe folder of existing projectto anywhere on your disk.
- Start Eclipse. Turn off the automatically build.
- In the Eclipse do Refactor / Renameto the new project name. (If it connected to CVS/SVN disconnect before rename.)
- Importback the old projectfrom place where you copied in the second step.
- Turn on the automatically build.
- 关闭日食
- 将现有项目的文件夹复制到磁盘上的任何位置。
- 启动日食。关闭自动构建。
- 在 Eclipse 中执行 Refactor/ Rename为新的项目名称。(如果它连接到 CVS/SVN 在重命名之前断开连接。)
- 导入回旧的项目从地方,你在第二步中复制。
- 打开自动构建。
Enjoy them!
享用它们!
回答by astay13
Since B is empty, you can just copy project A in the Package Explorer and name the copy B.
由于 B 是空的,您只需在 Package Explorer 中复制项目 A 并将副本命名为 B。
回答by mOna
- 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!
- 创建现有项目的副本/副本(在工作区中)。
- 然后在 Eclipse 中,单击文件->导入
- 选择将现有项目导入工作区
- 检查单选按钮“选择根目录”
- 浏览您的项目(您在步骤 1 中在工作区中复制的新文件)
- 完毕!
回答by Ahmad Merghany
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 occurrencesinto the new name, run the project, you are all set...
在项目资源管理器中,右键单击您的旧项目,单击“复制”,这次再次右键单击“粘贴”,将默认名称“My_Old_Project 的复制”更改为您选择的任何名称,复制完成后,转到到Eclipse 中的“搜索”选项卡,然后到 --> “搜索”,在文件搜索中,输入项目的旧名称,确保您的范围仅为“封闭项目”,将所有出现的项更改为新名称, 运行项目, 你都准备好了...
only thing I noticed about this is that the url will still be of the old project.
我唯一注意到的是,该网址仍将属于旧项目。
回答by Wallace Mann
For a Gradle project, I had to add two extra steps to mOna's answer, which I will copy for completeness.
对于 Gradle 项目,我必须在 mOna 的答案中添加两个额外的步骤,为了完整起见,我将复制这些步骤。
- 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.
- 创建现有项目的副本/副本(在工作区中)。
- 然后在 Eclipse 中,单击文件->导入
- 选择将现有项目导入工作区
- 检查单选按钮“选择根目录”
- 浏览您的项目(您在步骤 1 中在工作区中复制的新文件)
- 编辑 .project 文件并更改 和 以匹配新项目。
- 编辑 settings.gradle 并更改 rootProject.name 以匹配新项目。
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.
我假设上述某些答案中的重命名执行了第 6 步,但我无法使其正常工作。无论我尝试什么,如果没有这些额外的步骤,代码看起来还可以,但是依赖项没有得到正确处理,错误无处不在。我什至能够从命令行在我的项目上运行 gradle 并“构建”它,但实际上是在构建旧项目。
回答by jayavardhan
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.
Eclipse 在文件菜单中有一个选项,如导入现有项目。从中您可以导入包含所有内容的现有项目。我希望这是您正在寻找的解决方案。