文档
Liferay提供丰富知识资源,协助我们的社区与我们的技术更好地结合、应用。
Importing Existing Projects into Liferay IDE
What if you have existing projects that you want to work on in Liferay IDE? This section shows you how to import your existing projects into Liferay IDE so you don’t have to recreate them.
We’ll cover the following import scenarios:
Importing existing Liferay projects from the Plugins SDK.
Importing Eclipse projects that aren’t in Liferay IDE (i.e., don’t have Liferay facet or target runtime).
Importing existing Liferay IDE projects from another Liferay IDE version or workspace.
Let’s start by learning how to import existing Liferay projects from Liferay Plugins SDK.
Importing Existing Liferay Projects from the Plugins SDK
You can import Liferay projects you created with the Plugins SDK, but aren’t yet in your Liferay IDE Eclipse workspace. These projects might already have .project or .classpath files in them; regardless, we’ll use the same procedure to import them.
Do you want to create one project, or multiple projects, from your Plugins SDK? You can do either, and we’ll show you how below. Regardless, any time you import a project into Liferay IDE, verify that it was successfully configured as a Liferay IDE project by using the process outlined in the section following the import instructions.
Note: The next two sections assume that you’ve created projects with the Plugins SDK and are familiar with the directory structure used by the Plugins SDK.
First let’s look at the import process for creating a single Liferay IDE project from a Plugins SDK project.
Creating a Single Liferay IDE Project from One Plugin in an Existing Source
If you want to create one project for a single plugin that exists inside a Plugins SDK, follow these steps:
In Liferay IDE, go to File → New → Project… → Liferay → Liferay Project from Existing Source.
You can invoke the same wizard from the Liferay shortcut bar; just click the Create a New Liferay Project button.
Figure 9.7: Alternate method of Importing a project
Browse to your project folder. It should be a subdirectory of one of the plugin types (e.g. portlets, hooks, themes, etc) or it won’t import correctly. Once you select the plugin project folder, its type and SDK version values are updated to the correct values. If the SDK isn’t recent enough or the project type is incorrect it gets marked with an error.
After you select the plugin project folder you should see the Liferay plugin type and Liferay plugin SDK version values updated. If your Plugins SDK is outdated or you entered an incorrect project type, its field gets marked with an error.
Select the Liferay target runtime to configure on the project once it’s imported. If you don’t have a Liferay Portal Runtime, use the New… button to create one now; Tomcat bundle is the only server runtime supported.
Click Finish to perform the import.
Remember to verify that your project was configured correctly as a Liferay IDE project. Verification is described right after our next topic, which is making multiple Liferay IDE projects from a single Plugins SDK.
Next we’ll show you how to import all your Plugins SDK into multiple Liferay IDE projects.
Create multiple projects for all plugins in a Plugins SDK
Does your Plugins SDK contain multiple plugins? You can easily batch import each plugin in your Plugins SDK as its own Liferay IDE project.
In Eclipse go to File → Import… → Liferay → Liferay Plugin SDK Projects.
Figure 9.8: Choosing the project type for import
In the Import Projects window, use the combo box to select the Liferay Plugins SDK you’re importing plugins from.
Note: If your SDK isn’t configured in Liferay IDE (i.e., it’s not in the dropdown list of the Import Projects window) 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 select your Plugins SDK in the combo box, the Liferay Plugin SDK Location and Liferay Plugin SDK Version fields are automatically filled in, as long as they’re valid. Invalid entries are marked with an error.
The list of projects that are available for import are displayed in a table. Any projects already in the workspace will be disabled. Projects available for import have an empty check box; select each project you’d like to import.
Select the Liferay runtime you want to set up for the imported projects.
If you don’t have a Liferay runtime, can add one now with the New… button.
Click Finish.
Your plugins are imported! Now skip to the end of this section to verify that they were configured correctly as Liferay IDE projects. Wwe’ll talk about a different import scenario next; importing existing eclipse projects into Liferay IDE.
Importing Existing Eclipse Projects into Liferay IDE
The steps we outlined above let you import projects not already in an Eclipse workspace. If you have a project in your Eclipse workspace (i.e., you can see it in Eclipse’s project explorer) that you’d like to import to Liferay IDE, follow the import steps below to convert your project.
In Eclipse, right click the project in your project explorer then select Liferay → Convert to Liferay plugin project.
Note: If you don’t have a convert action available it means either that the project is already a Liferay IDE project, or that it is not faceted (i.e., Java and Dynamic Web project facets are not yet configured). Configure accordingly before moving on.
In the Convert Project wizard, your project should be selected and the SDK location and SDK version should be detected automatically. If they aren’t valid an error message will be displayed.
Figure 9.9: Converting a project
Select the Liferay runtime to set up for the project. If you don’t have a Liferay Runtime defined, do so now by clicking New….
Click Finish.
Remember to verify that your import was successful and that your project was configured correctly as a Liferay IDE project; the last subsection in this topic will show you how. We have one more import scenario to cover–importing existing Liferay IDE projects into your Liferay IDE.
Importing an existing Liferay IDE project
What if you had a Liferay IDE project in your workspace, but it’s not there anymore? Here’s how you can import it into your current workspace:
Open Liferay IDE, go to File → Import … → General → Existing Projects into Workspace.
Choose the option Select root directory, then click Browse….
Select the directory of the Liferay IDE project to import.
In the Projects: list you should see your Liferay IDE project.
Click Finish.
Note: There are two common errors that occur when importing existing Liferay IDE projects into your workspace:
The SDK name used in that project doesn’t exist in your new workspace.
The runtime id used doesn’t exist in your new workspace.
You can modify the SDK name in Project Properties → Liferay dialog window; you can modify the targeted runtime in the Project properties → Targeted Runtimes dialog window.
Let’s verify the success of your imports and ensure that they’re properly configured as Liferay IDE projects.
Verifying that the import has succeeded
After importing projects into Liferay IDE, you’ll want to verify that they imported successfully, and that they’re properly configured as Liferay IDE projects. Here’s how you verify that your imports were successful:
Once the project is imported, you should see a new project inside Eclipse and it should have an “L” overlay image; the “L” is for Liferay!
Figure 9.10: Verifying that the import succeeded
Let’s check the project’s target runtime and facets to make sure it’s configured as a Liferay IDE project:
2.1. In the Package Explorer, right click
→ Properties → Targeted Runtimes. 2.2. In the Properties window, click Project Facets and make sure both Liferay runtime and Liferay plugin facets are properly configured.
Figure 9.11: Project Facets
Great! You’ve confirmed that your import was successful; you can now make revisions to your configured Liferay IDE project. Next, let’s explore Liferay IDE’s Remote Server Adapter feature.