Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hot deploy Liferay Maven portlet from Intellij Idea to Liferay Tomcat bundled

Tags:

I'm developing a Liferay portlet and I can't stand waiting for Maven to build the .war file and then copy that .war to LifeRay's auto-deploy directory to finally wait (again) till LifeRay finishes deploying it. That's why I want to build, start Tomcat (bundled with LifeRay) and deploy my portlet with everything through Intellij IDEA, with hot-deployment enabled.

I tried with Running Liferay from IntelliJ (from Liferay Wiki) but can't get it to work.

I also tried with the following questions but no result:

  • Deploy .war file on a server (Liferay+Tomcat Bundle) --> Talks about droping .war file into liferay deploy directory and that's not hot-deploy.
  • How to program portlets efficiently using Liferay and Maven? --> I want to configure Intellij IDEA, don't want to use another IDE. I Didn't try with JRebel.
  • how to build .war file in IDEA to deploy to Liferay --> Checked.

Environment:

  • Liferay CE 6.1.1 (Tomcat bundle).
  • Maven project using archetype: liferay-portlet-archetype.
  • Intellij IDEA 12.1.2.
  • JDK 6.

Does anyone know how to do it?

like image 873
Nahuel Barrios Avatar asked May 10 '13 20:05

Nahuel Barrios


1 Answers

Deploy .war file on a server (Liferay+Tomcat Bundle) --> Talks about droping .war file into liferay deploy directory and that's not autodeploy.

Technically this is autodeployment, because it's handled by your application server's AutoDeploy Scanner, but it's probably not what you mean by automatic deployment or hot-deploy.

How to program portlets efficiently using Liferay and Maven? --> I want to configure Intellij IDEA, don't want to use another IDE. I Didn't try with JRebel.

IDEA rocks, don't change it. However, even though I don't use JRebel personally I've heard a lot of positive reactions from colleagues who are using it.. Don't discard this option - you might want to check out this tutorial or maybe this one.

Now for the answer-ish part: This may be more of a tip, than an exact solution, but I have been using this for a long time. If you don't want to redeploy the whole module which needs to be built you can hot-deploy it with IDEA if you have your server configured to allow remote debugging.

When you do some changes in your code and you want to test it just connect to your running application server as if you were going to debug it remotely and compile the class you changed. It will automatically do a hot-deploy. Afterwards disconnect/end the debugging and go check your changes!

This doesn't work if you change the structures of your classes too much, or change the arguments of the method, but it is a great help when your trying to fix for example a null pointer inside your methods body. Just connect and compile.

Hope it helps you a bit if you don't want to use JRebel.

Tip: If you want to simplify your doployment using the auto-deploy method (folder "deploy") then you can speed it up by specifying only the modules that you want to build, by creating a profile:

In your main (top-level) pom.xml there's a tag called profiles. You can add a new profile there with the modules specified. For example:

<profile> <id>dev</id> <modules>     <module>your-module</module>                     <module>ejbs-for-your-module</module>                </modules>   </profile> 

After that you can build your project using the profile with Maven. For example if you want to use the "dev" profile:

mvn clean install -Pdev

Or you can you can write a deployment script which will do the necessary manual tasks for you. It is quite common that developers write bash/batch scripts which clean the targets, build the necessary stuff, pick up the wars and copy them to the deploy folder.

like image 177
Dropout Avatar answered Sep 18 '22 12:09

Dropout