Importing Liferay portlet into Eclipse IDE

Juri picture Juri · Mar 4, 2009 · Viewed 15k times · Source

I have a question regarding the development of liferay portlets using the liferay plugin SDK. My question goes mainly in the setup of the development IDE. The suggested one would be to use Netbeans IDE which I also tried out, but it appears to run very slowly on my machine while Eclipse is quite performant. The setup for Netbeans IDE is the following

  1. Go to the directory \portlets
  2. Run the create.bat (or sh file depending on the OS) to create a new sample portlet
  3. Run Netbeans IDE, create a new "Java free form project" and point it to the directory of the created sample portlet

That's it, pretty simple.

For the mentioned reasons above (and because I'm a lot more familiar with Eclipse) I'd like to import the project into Eclipse the same way. Is there a way for doing it without having to change too much in the original structure of the created sample portlet and the according build.xml (ant file)?? I tried already to create a new project out of the build.xml ant file of the created sample portlet, however in this way it doesn't include me the source code.

I didn't also find great tutorials on the web... Could someone help me with this, pointing out online tutorials or give me some hints.

Thanks

Answer

Lorgarn picture Lorgarn · Jun 11, 2009

I know your pain. Starting to work with Liferay needs much time. I you do not want to edit the existing source, but only crate your own portlets, you can download the plugins SDK from the 'Additional Files' section on the Liferay website. This provides ant scripts, to create a simple JSR compliant portlet, and to create all necessary things, to create a sound Eclipse project, for example:

ant -Dportlet.name=<project name> -Dportlet.display.name="<portlet title>" create

Than cd into the directory of your created portlet an do:

ant setup-eclipse

After that you should be able to create a new project from the sources in that directory in Eclipse, which can then be deployed via another ant script to the running tomcat instance. If you already know somthing about portlet programming, you shoud be pretty much settled now. If not, try to find documentation about JSR portlet programming first, before looking into Liferay specifig portlet development.