主要就是将已存在的源代码放到liferay sdk下的portlets目录下,比如C:\work\liferay-plugins-sdk-6.1.0-ce-ga1-20120106155615760\portlets下,然后new-->liferay porject from existing source.然后在接下来的对话框中的browse 选择目录中要导入的工程即可。
下面的文章转载自liferay官网http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/importing-existing-projects-into-liferay-ide
If you have been following the examples of this guide using the Plugins SDK or have previous plugins developed with it that you want to keep developing with Liferay IDE then this section is for you. It also shows other options to import. Specifically it shows how to import from:
Existing Liferay projects that are not in Eclipse workspace
Projects already in Eclipse but not Liferay IDE (don't have Liferay facet or target runtime)
Existing Liferay IDE projects from another version of Liferay IDE or workspace
The following subsections describe the steps for each of them with more detail.
An existing Liferay project that has been created by the Plugins SDK but has not yet been added to an Eclipse workspace or have not been added to the current workspace open in Eclipse/Liferay IDE. These projects may or may not have .project or .classpath files. Whether they do or don't we will follow the same steps and use the same wizard.
There are two options to create projects from existing sources, depending on whether you want to create one single project or multiple projects from the same SDK. Let's see both in detail.
Note: The two next sections assume that you have Liferay plug-ins SDK directory structure and you have previously created projects inside of that directory structure
This option will create one project for a single plugin that already exists inside a Plugins SDK.
In Eclipse, go to File > New > Project... > Liferay > Liferay Project from Existing Source
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project-wizard-shortcut.png
Or you can invoke the same wizard from the Liferay shortcut bar
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project-wizard-shortcut-toolbar.png
Browse to the location of the project folder. Note: the project folder should be a sub-directory of one of the plugin types, e.g. portlets, hooks, themes, etc. If not it will not be able to be imported correctly. Once you select the plugin project folder you should see the plugin type and SDK version values get updated to correct values. If the SDK is not recent enough or project type is not correct it will be marked with an error.
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project-browse.png
Once you select the plugin project folder you should see the plugin type and SDK version values get updated to correct values. If the SDK is not recent enough or project type is not correct it will be marked with error
Next you will need to select a Liferay Runtime to configure on the project once it is imported. If you don't have a Liferay Runtime, use the New... button to create a new Liferay portal runtime (tomcat bundle only supported).
Click Finish to perform the import
Read the section below on verifying the success of an import process to make sure that your project was configured correctly as a Liferay IDE project.
This option will transverse an existing Plugins SDK and will allow creating one project for each of the plugins it finds inside in one single step.
In Eclipse go to File > Import... > Liferay > Liferay Plugin SDK projects
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project-sdk-projects.png
First you must select the Plugins SDK that you want to import projects from in the combo box at the top of the wizard.
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project-sdk-projects-wizard.png
If you don't have any SDKs configured in Liferay IDE use the "configure" link to add a setting that points to the Plugins SDK that you want to import projects from.
To configure a Plugins SDK on the Installed SDKs on the pref page just click "Add" and then Browse to the directory of the Plugins SDK root directory.
Once you have a configured Plugins SDK, you can select it in the Combo box and then the SDK location and version will be filled in. If either are not valid it will be marked with an error.
After the SDK is selected the list of projects that are available for import will be shown in the table. If the projects are already in the workspace they will be disabled. If the project is available for import it will have a empty checkbox that can be selected.
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project-sdk-projects-wizard-3.png
Select which projects that you wish to import.
Select the Liferay runtime that you want to setup for the imported projects.
If you don't have a liferay runtime you can add one with the "New..." button.
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project-select-runtime.png
Click Finish.
Read the section below on verifying the success of an import process to make sure that your project was configured correctly as a Liferay IDE project.
If your project is not in your Eclipse workspace, you can use the first set of steps above. If your project is already in your workspace (see it in project explorer) but is not yet a Liferay IDE project, the following steps can be used to convert the project.
In Eclipse, right click the eclipse project that you want to convert, select Liferay > Convert to Liferay plug-in project.
Note: If you don't have a convert action available it means the project is either already a Liferay IDE project or it is not a faceted project with Java and Dynamic Web project facets configured and will need to be configured accordingly
When the convert dialog wizard opens your project should be auto-selected and the SDK location and SDK version should be auto-detected. If they are not valid an error message will be displayed.
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project-convert-wizard.png
Select the Liferay runtime that you wish to set on the project. If you don't have a Liferay Runtime define use the "New..." action to create one.
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project-select-runtime.png
Click Finish.
Read the section below on verifying the success of an import process to make sure that your project was configured correctly as a Liferay IDE project.
This section describes the steps that can be followed if you have previously created or converted a Liferay IDE project in your workspace but it is no longer in the current workspace there are a couple of options for importing this project.
Open Liferay IDE, go to File > Import ... > General > Existing Projects into Workspace
Use option Select root directory, then click Browse
Select the directory of the previous Liferay IDE project
Then in the list of projects you should see the one project you selected
Click Finish
Read the section below on verifying the success of an import process to make sure that your project was configured correctly as a Liferay IDE project.
If you have any errors, it may be that either the SDK name used in that project or the runtime id used doesn't exist in your new workspace. You can modify the SDK name in the Project Properties > Liferay page and you can modify the targeted runtime in the Project properties > Targeted Runtimes page.
Follow the following steps to verify that either of the previous import processes has been successful.
Once the project import process is finished, you should see a new project inside Eclipse and it should have a "L" overlay image to show its a Liferay project.
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project_overlay.png
Secondly, to make sure the project is now a "Liferay IDE" project is to check the target runtime project property (right-click project > properties > target runtimes) and also check the project facets to make sure both Liferay runtime and Liferay plug-in facets are properly configured.
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project_runtime.png
E:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project_facets.png