如何使现有的目录成为一个 Eclipse 项目

我正在做一个项目。我决定尝试在 Eclipse 中使用它。在版本控制下,已经有一个目录,所有代码都驻留在该目录下。我遇到了一个很奇怪的问题。我找不到任何方法来开始使用现有的代码目录作为 Eclipse 项目。我所能找到的就是如何将现有源导入到新项目中,或者将源从版本控制中签出到新项目中。如何将现有目录转换为项目?

我的项目是一个 Django 网络应用程序,如果它有任何帮助

90989 次浏览

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.

In the New Java Project wizard, uncheck the checkbox that says Use default location and the use the Browse button to find your directory.

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

ln -s /path/to/source src

will do from your project directory.

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?

Use "import - existing projects into workspace". This works for my case.

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.

Once these things are ready you can select File > New > Other, then select PyDev Django Project from the PyDev sub directory.

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.

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.

Then you should be able to view and use your existing project in Eclipse!

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

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:

  1. In one of the navigation views, right-click the project or folder where you want to create the linked folder.

  2. From the pop-up menu, select command link New > Folder.

  3. 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.

  4. Click Advanced.

  5. Check Link to alternate location (Linked Folder).

  6. Enter a file system path, or click Browse to select a folder in the file system.

  7. Click Finish.

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

File Name: .project ( Use Notepad for make this file...select Save as type to ABC1 and write file name like: .project )

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Project-Name</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

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.

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.