Build a Liferay portlet war via Maven
by Stanislav on Saturday Apr 18, 2015
Most posts on the internet regarding "How to build a war file of Liferay portlet" topic, cover only Ant tool. I find Maven as a next-gen project build tool and in this post I'll show how to use it to build Liferay portlet war.
There are 2 options to build portlet war: via command line or via eclipse liferay plugin.
To build portlet war via command line:
- Add new maven profile (maven settings.xml):
<profile> <id>life</id> <properties> <plugin.type>portlet</plugin.type> <liferay.version>6.2.1</liferay.version> <liferay.maven.plugin.version>6.2.1</liferay.maven.plugin.version> <!--liferay.auto.deploy.dir>c:\liferay\Tomcat\webapps\deploy2</liferay.auto.deploy.dir--> <liferay.app.server.deploy.dir>c:\liferay\Tomcat\webapps</liferay.app.server.deploy.dir> <liferay.app.server.lib.global.dir>c:\liferay\Tomcat\lib\ext</liferay.app.server.lib.global.dir> <liferay.app.server.portal.dir>c:\liferay\Tomcat\webapps\ROOT</liferay.app.server.portal.dir> </properties> </profile>
- Build usual war file using this command in project dir: mvn clean install
- Generated war needs to be modified according to the liferay portlet specification: mvn liferay:direct-deploy -DunpackWar=false -DappServerType=tomcat -DpluginType=portlet -P life
at this step war will be modified and placed to c:\liferay\Tomcat\webapps.
liferay:direct-deploy plugin makes some changes to war: adds information to web.xml, adds liferay files, etc.
To build portlet war via eclipse liferay plugin:
- Install liferay eclipse plugin.
- Project settings -> MAVEN -> Active Maven Profiles, set profile name that was specified for current project (for example "life", see upper part of this document).
- Invoke project's maven liferay:direct-deploy command that will copy unpacked war content to deploy.dir. War in this case not generated.
Tony Apr 18, 2015 at 10:02 #
Good post man!