在 Eclipse 中工作区的子文件夹中创建一个项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2714665/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:39:54  来源:igfitidea点击:

Create a project in Eclipse in a subfolder of the workspace

eclipse

提问by Bj?rn Pollex

I want to create a Java-project in a subfolder of the workspace-directory. The wizard either lets me create a project in the workspace-directory, or import an existing one. Is there any way to achieve this?

我想在工作区目录的子文件夹中创建一个 Java 项目。该向导可以让我在工作区目录中创建一个项目,或者导入一个现有的项目。有没有办法实现这一目标?

采纳答案by VonC

To my knowledge, no: the only "directory" under which you can create a project is the "working set" one.

据我所知,不:您可以在其下创建项目的唯一“目录”是“工作集”。

That special directory is visible by selecting the right top element:

通过选择右上方的元素可以看到该特殊目录:

http://img708.i_mageshack.us/img708/3899/eclipseworkingset.png

http://img708.i_mageshack.us/img708/3899/eclipseworkingset.png



PS: just to be complete, creating a project within a project (nested project) is also not possible (bug 43536)

PS:只是为了完成,在项目(嵌套项目)中创建项目也是不可能的(错误43536

回答by jldupont

Step 1)Create project X as usual (it will end-up in the root of your workspace)

第 1 步)照常创建项目 X(它将最终出现在您工作区的根目录中)

Step 2)Use a command-line shell of your OS to move the project X directory hierarchy under the desired target directory e.g. mv ~/workspace/abc ~/workspace/target/some_directory/

步骤 2)使用操作系统的命令行 shell 将项目 X 目录层次结构移动到所需的目标目录下,例如mv ~/workspace/abc ~/workspace/target/some_directory/

Step 3)Delete the original project X (do not select 'delete files')

Step 3)删除原来的项目X(不要选择'删除文件')

Step 4)Import project X using `File -> Import -> Existing project into workspace'

步骤 4)使用 `File -> Import -> Existing project into workspace' 导入项目 X

Project X will appear in the package explorer view as it normally would.

项目 X 将像往常一样出现在包浏览器视图中。

Hope this helps :)

希望这可以帮助 :)

回答by Chris Senior

If you are importing projects from SVN, and you want to preserve a parent folder that exists in SVN, you can preserve that project hiearachy in your workspace.

如果您从 SVN 导入项目,并且想要保留 SVN 中存在的父文件夹,则可以在工作区中保留该项目层次结构。

Say your SVN looks like this:

假设您的 SVN 如下所示:

svn://svn.acme.com/svn/trunk/team-a-projects/com.acme.a.stuff/...
svn://svn.acme.com/svn/trunk/team-a-projects/com.acme.a.more-stuff/...
svn://svn.acme.com/svn/trunk/team-b-projects/...

Then you can preserve the "team-a-projects" folder in your workspace. Follow these steps:

然后您可以在工作区中保留“team-a-projects”文件夹。按着这些次序:

  1. Browse your SVN repository in SVN repository exploring perspective and locate the "team-a-projects" folder.
  2. Right click on the folder and choose "Find/Check-out as..."
  3. Select the "Find projects in the children of the selected resource" option and click "Finish"
  4. Wait while Eclipse digs into the folder to find projects (.project files)
  5. On the "Check Out Projects" dialog choose the "Check out as projects into workspace" option. Note the projects it will create are shown in the table.
  6. Check the "Respect projects hierarchy" option. This will preserve the "team-a-projects" folder as a parent of the projects in the workspace.
  7. Click "Finish" (or next if you want to mess with working sets)
  1. 在 SVN 存储库探索透视图中浏览您的 SVN 存储库并找到“team-a-projects”文件夹。
  2. 右键单击该文件夹并选择“查找/签出为...”
  3. 选择“在所选资源的子项中查找项目”选项,然后单击“完成”
  4. 等待 Eclipse 深入文件夹以查找项目(.project 文件)
  5. 在“Check Out Projects”对话框中选择“Check out as projects into workspace”选项。请注意,它将创建的项目显示在表中。
  6. 选中“尊重项目层次结构”选项。这将保留“team-a-projects”文件夹作为工作区中项目的父级。
  7. 单击“完成”(如果您想弄乱工作集,则单击“下一步”)

Eclipse will then create projects in your workspace. Note that in the UI you will not see your parent folder (e.g. "team-a-projects") but if you right click on a project and look at the resources (or go and look in the filesystem) you will have projects in a subfolder of the workspace.

然后 Eclipse 将在您的工作区中创建项目。请注意,在 UI 中您不会看到您的父文件夹(例如“team-a-projects”),但是如果您右键单击一个项目并查看资源(或查看文件系统),您将在一个工作区的子文件夹。

I have not tested it with multiple levels of folders, only a single level. But I guess it would preserve those too? Good luck.

我没有用多个级别的文件夹测试过它,只有一个级别。但我想它也会保留那些吗?祝你好运。

回答by sub

It is possible to add a subfolder to a project, by right clicking on the project folder, going to new, and clicking on new folder.

可以通过右键单击项目文件夹,转到新文件夹,然后单击新文件夹,将子文件夹添加到项目中。