liferay6.1 将开发的plugin源代码导入到liferay ide

来源:互联网 发布:2017森林资源调查数据 编辑:程序博客网 时间:2024/06/05 10:59

        主要就是将已存在的源代码放到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

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.

Importing existing Liferay Project from a Plugins SDK

    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

Create one single project from one plugin in an existing sources

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

    100002010000012D000000CFA0E8BAB9.pngE:\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

    10000201000001370000006321D4E999.pngE:\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.

    1000020100000212000000DAA6B55D13.pngE:\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

    100002010000021000000059BC609466.png

  • 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).

    100002010000023500000040F91BF691.png

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

Create multiple projects for all plugins in a Plugins SDK

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

    10000201000001B9000000D79742052C.pngE:\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.

    100002010000027D000000DED98E5E4E.pngE:\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.

100002010000022200000072EF2B3D54.png

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

    100002010000026F0000007FDCC74D8F.pngE:\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.

    10000201000002120000004FDDC09802.pngE:\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.

Importing an existing Eclipse Project that is not aware of the Liferay IDE

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

10000201000002790000002855640F04.png

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

    1000020100000212000000AAA5D907F2.pngE:\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.

    10000201000002120000004FDDC09802.pngE:\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.

Importing an existing 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.

Verifying that the import has succeeded

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.

    10000201000000B5000000367B76626B.pngE:\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.

    10000201000000D30000005AAA73C225.pngE:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project_runtime.png

    100002010000021900000069FA6C4738.pngE:\src code\tools\trunk\ide\eclipse\common\plugins\com.liferay.ide.eclipse.doc\help\tasks\images\existing-project_facets.png