22
votes

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:

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?

1
DId you found solution?MyTitle
No, and I stopped looking for. But for static resources like VM, CSS, JS, fonts and image files the "solution" I took was replacing its content manually by opening Tomcat's files from the IDE (not for image files, in that case just replace the files).Nahuel Barrios
Are you working with Windows or other OS? In all OS you could create a script with an endless loop to move files from one dir to another (SDK/dist -> Liferay autodeploy) together with a sleep 1 second instruction.erny
Oh that's better than my manual solution, thanks! I use Windows at work and Ubuntu at home.Nahuel Barrios
After working with Liferay and Maven for more than 1 year, i think the best way to really hot-deploy is using JRebel.guli

1 Answers

1
votes

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.