eclipse 如何将现有目录变成eclipse项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4170963/
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
How to make an existing directory into an eclipse project
提问by Mad Wombat
I have a project I am working on. I have decided to try working with it in Eclipse. There is already a directory, under version control where all the code resides. I am having a rather strange problem. I cannot find any way to just start using an existing code directory as an eclipse project. All I can find is how to import existing source into a new project or check out source from version control into a new project. How do I make an existing directory into a project?
我有一个正在做的项目。我决定尝试在 Eclipse 中使用它。已经有一个目录,在所有代码所在的版本控制下。我有一个相当奇怪的问题。我找不到任何方法来开始使用现有代码目录作为 Eclipse 项目。我所能找到的就是如何将现有源代码导入新项目或从版本控制中检出源代码到新项目。如何将现有目录转换为项目?
My project is a Django web app if it is any help
如果有帮助的话,我的项目是一个 Django 网络应用程序
回答by aptwebapps
In the New Java Project
wizard, uncheck the checkbox that says Use default location
and the use the Browse button to find your directory.
在New Java Project
向导中,取消选中显示的复选框,Use default location
然后使用“浏览”按钮查找您的目录。
回答by akf
It is pretty easy to do. Go to File->New-> Project. In the Project wizard, choose the type of project you want and then be sure to unclick the 'Use default location` checkbox. Browse for your folder in the widget that then becomes enabled. Click finish after that.
这很容易做到。转到文件->新建->项目。在项目向导中,选择您想要的项目类型,然后确保取消单击“使用默认位置”复选框。在小部件中浏览您的文件夹,然后启用。之后点击完成。
Alternatively, you could create a brand new project workspace in a new location. Then, assuming Java as your project type, you can open up your project properties and add as a source folder your existing directory. To do this, use the 'Link Source' button on the Java Build Path -> Source tab of your Project Properties dialog.
或者,您可以在新位置创建一个全新的项目工作区。然后,假设 Java 作为您的项目类型,您可以打开项目属性并将现有目录添加为源文件夹。为此,请使用“项目属性”对话框的“Java 构建路径”->“源”选项卡上的“链接源”按钮。
回答by Mostafa
My Method:
我的方法:
I clone this file to new project directory , and rename Project-Name to my project name, after that i import new files and directory from Eclips
我将此文件克隆到新项目目录,并将 Project-Name 重命名为我的项目名称,然后我从 Eclips 导入新文件和目录
File Name: .project
( Use Notepad for make this file...select Save as type to All Files (*.*)
and write file name like: .project
)
文件名:.project
(用记事为使此文件...选择保存类型为All Files (*.*)
和写文件名,如:.project
)
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Project-Name</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
回答by chaben
Hope this link answers the original question of this thread.
希望这个链接能回答这个线程的原始问题。
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-45.htm
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-45.htm
Creating linked resources
创建链接资源
Folders and files can be linked to locations in the file system outside of the project's location. These special folders and files are called linked resources.
文件夹和文件可以链接到文件系统中项目位置之外的位置。这些特殊的文件夹和文件称为链接资源。
To create a linked folder:
要创建链接文件夹:
In one of the navigation views, right-click the project or folder where you want to create the linked folder.
From the pop-up menu, select command link New > Folder.
Specify the name of the folder as it will appear in the workbench. This name can be different from the name of the folder in the file system.
Click Advanced.
Check Link to alternate location (Linked Folder).
Enter a file system path, or click Browse to select a folder in the file system.
Click Finish.
在其中一个导航视图中,右键单击要在其中创建链接文件夹的项目或文件夹。
从弹出菜单中,选择命令链接新建 > 文件夹。
指定文件夹的名称,因为它将出现在工作台中。该名称可以与文件系统中文件夹的名称不同。
单击高级。
选中链接到备用位置(链接文件夹)。
输入文件系统路径,或单击浏览选择文件系统中的文件夹。
单击完成。
回答by wilbbe01
Probably not the way most people would go about this, but I like all of my eclipse projects in one place but don't necessarily have my source in my workspace directory. Maybe there is a built in way to "symlink" in eclipse, but I sometimes end up with the project folder in the workspace, with the "src" symlinked to the actual source directory somewhere totally different. That's my personal preference anyway. If you too are on a *nix machine a simple
可能不是大多数人会采用的方式,但我喜欢将所有 eclipse 项目放在一个地方,但不一定在我的工作区目录中有我的源代码。也许在 eclipse 中有一种内置的“符号链接”方式,但我有时会在工作区中得到项目文件夹,“src”符号链接到完全不同的地方的实际源目录。反正这是我个人的喜好。如果你也在 *nix 机器上,一个简单的
ln -s /path/to/source src
will do from your project directory.
将从您的项目目录中执行。
回答by Gábor Lipták
You know, it is not so simple question. Depending on your project type (jar, web module, ear and so on) different structure and configuration files are used by eclipse. So the first really interesting question is that what is your project type? The basic solution after it to create a new project, and define the directory of your source code as project root. Then you will see what else to change (for example source path settings, classpath and so on). So how does your project look like? Can you proide structure tree of folders?
你知道,这不是那么简单的问题。根据您的项目类型(jar、web 模块、ear 等),eclipse 使用不同的结构和配置文件。所以第一个真正有趣的问题是你的项目类型是什么?之后的基本解决方案是创建一个新项目,并将您的源代码目录定义为项目根目录。然后你会看到还有什么需要改变(例如源路径设置、类路径等)。那么你的项目是什么样子的呢?你能提供文件夹的结构树吗?
回答by e.thompsy
Since you are using Django you should first set up PyDev in Eclipse. You can install it from the market. Then you want to configure the PyDev Python interpreters to find your installation of Django (http://pydev.org/manual_101_interpreter.html). Make sure to provide the explicit path to the Django folder if your Django is not installed in the default location.
由于您使用的是 Django,您应该首先在 Eclipse 中设置 PyDev。您可以从市场上安装它。然后你想配置 PyDev Python 解释器来找到你安装的 Django ( http://pydev.org/manual_101_interpreter.html)。如果您的 Django 未安装在默认位置,请确保提供 Django 文件夹的显式路径。
Once these things are ready you can select File > New > Other, then select PyDev Django Project from the PyDev sub directory.
准备好这些东西后,您可以选择 File > New > Other,然后从 PyDev 子目录中选择 PyDev Django Project。
Click next and here is the sweet part: Uncheck 'Use default' (as previously stated) and then find your Django project directory. Be sure to select the right project folder (ie: the folder that contains manage.py
). When you have the right folder selected Eclipse/PyDev will recognize that a project already exists and make mention that it will use those files. Click Finish.
单击下一步,这里是甜蜜的部分:取消选中“使用默认值”(如前所述),然后找到您的 Django 项目目录。请务必选择正确的项目文件夹(即:包含 的文件夹manage.py
)。当您选择了正确的文件夹时,Eclipse/PyDev 将识别出一个项目已经存在并提到它将使用这些文件。单击完成。
Then there is a DB form that asks about your DB settings. If you already have a settings.py
file then this seems to make no changes (as it should not). So fill it in or don't. But this is the last step.
然后有一个数据库表单询问您的数据库设置。如果您已经有一个settings.py
文件,那么这似乎不会进行任何更改(因为它不应该)。所以填写或不填写。但这是最后一步。
Then you should be able to view and use your existing project in Eclipse!
然后您应该能够在 Eclipse 中查看和使用您现有的项目!
回答by Hubert Grzeskowiak
I just created a pom.xml by hand and imported the project as an existing Maven project in Eclipse. It even works for nested projects without problems.
我只是手动创建了一个 pom.xml 并将该项目作为现有的 Maven 项目导入到 Eclipse 中。它甚至适用于嵌套项目而没有问题。
回答by Notoc
Right click on a project -> Properties. Open project location in explorer, there's a little icon next to path. Put your folder/file structure in there and refresh the project in eclipse.
右键单击项目 -> 属性。在资源管理器中打开项目位置,路径旁边有一个小图标。将您的文件夹/文件结构放在那里并在 eclipse 中刷新项目。
回答by tjuwayne
Use "import - existing projects into workspace". This works for my case.
使用“导入 - 现有项目到工作区”。这适用于我的情况。