Some new to java web development folks can get stucked with their productivity and experience growth by unabaliability to setup environment that allows them to develop software just like with dynamic languages: without long time server restarting and project sources rebuilding. In this article I want to describe some techniquies that may help you to make development more cute and lightweight.
Maven build system allows you to develop liferay plugins with portlets or themes withouth manual installation of liferays' SDK or any dependency you want to use in your projects.
To create liferay's project you can call generate archetype task from directory you suppose will contain new project's folder.
and than choose by number something like "com.liferay.maven.archetypes:liferay-portlet-archetype (Provides an archetype to create Liferay portlets.)". Or choose this archetype from IDE's maven project creation wizard's choice that you may find easier as the total list contain hundrets of variants. Then you will have to choose apropriate version of liferay than must correspond to portal's version. You can download portal tomcat bundle from official website or sf.net (SourceForge repository that contain all versions and products). And complete generation with setting groupId (like com.mycompany, or net.myproject), artifactId (e.g. myproject) and version.
After project structure is created you can navigate project's and imediately build it with command. If haven't already unpacked downloaded portal's files by this moment, good time to do it just before building.
mvn install liferay:deploy -Dliferay.auto.deploy.dir=/path/to/portalfiles/liferay-portal-6.x.y-ce-ga2/deploy
As you can see we have a benefit that your portal and project files can be located anywhere and not forced to have particular folder structure here.
Use "Imort Project" and choose folder created by command line maven wizard or Create maven project with liferay's archetype to start.
Add properties section to project's pom.xml if this was not done before:
<properties> <liferay.version>6.1.1</liferay.version> </properties>
In case you want to build project from IDE you should navigate 'Run Configurations' and created new from Tomcat Local template
1. delete any tasks or artifacts from configuration and keep or add only mvn command 'Before launch' task with the same contents as we had for mvn command:
install liferay:deploy -Dliferay.auto.deploy.dir=/path/to/portalfiles/liferay-portal-6.x.y-ce-ga2/deploy
2. set VM options parameter to values from portals's bin/setenv.sh script:
-Xms128m -Xmx1024m -XX:MaxPermSize=128m -Dfile.encoding=UTF8 -Duser.timezone=GMT
3. add empty CATALINA_BASE parameter to environment variables, portal will not start from IDE properly without this
4. do this for run, and debug options and those are created by JRebel.
Create similar liferay:build-service taks configuration for cases you are changing persistence API. Modify you service.xml, model-hints.xml or *ServiceImpl files and run this command if functions, parameters or anything of public API has been changed.
If you haven't already installed JRebel you can do it with. This is commercial software that you will pay $365 every year but it allows to develop with most of triaditional JAVA techonoliges with just type and safe without full rebuilds and deployments.
1. installing IntelliJ's JRebel plugin
2. right click on project's folder and choose JRebel -> add Nature option to make your project ready for reloading
3. follow other possible options from official how'to if you have troubles but generally you should have it working after only 1 and 2. You will get more run & debug like startup/connection modes with sugnificant buttons to be used to run instead of defaults to enable hot code reloading.
If everything went fine you should have fully featured 'change and reload' development model by this moment. There are free alternatives and base possibilities of at least JSP or exploded model realoding can give you quite close experience if you don't want to pay for commerical software.