Liferay六年中持续被评为Gartner水平门户魔力象限领导者。 原因是
« 返回到 Development

Fast Plugin Development

Save time by allowing developers to work with exploded plugin WARs instead of having to package them for deployment.

Create a context file #

The first thing to do is create a context file for the plugin, pointing to the exploded WAR: Create an xml file called like your plugin. For example, if your plugin is a portlet called something-portlet your file must be called something-portlet.xml and the content will be the following:


Deploy context file #

Once created just drop this file into the Liferay autodeploy directory. Liferay will copy this file to TOMCAT_DIR/conf/Catalina/localhost and the plugins will be registered. If the WAR was previously deployed, a new copy of the context file to the autodeploy directory will cause a redeploy of the exploded WAR. (If you had deployed your plugin before, it is advised to remove the old deployed application in webapps folder and restart Tomcat).

Copy dependencies #

You may probably need some libraries and tlds that were previously copied from the core. In order to know which ones you need, go to the webapps/somthing-portlet/WEB-INF folder and copy the lib and tld folders to your plugin WEB-INF folder too.

Using Fast Development in Tomcat #

From now on, if you change jsp files, they are modified when you refresh the page in your browser. For java classes and xml files you need to do ant compile from the plugin folder and copy again the context file into the Liferay autodeploy directory unless the Tomcat's context property "reloadable" is set to true. To do so, open the $TOMCAT_LIFERAY/conf/context.xml file and replace the line <Context> by <Context reloadable="true">. Then restart Tomcat. You can now update any part of the webapp (JSP, JSF pages... Java beans, servlets.... and they will automatically be reloaded by the Tomcat class loader).

Automating the configuration for fast development #

The steps outlined in the previous sections are valid for one portlet. If you are working with many portlets you may want to automate it so that the configuration is easily applied to any new portlet.

The following subsections explain how to achieve this by customizing the build scripts of the Plugins SDK

1) Extend the 'create' target #

Add the following quoted with EXPLODEDWARTEMPLATE inside the create target in the pluginsSDK\portlets\build.xml file:

	<replace dir="${}-portlet">
		<replacefilter token="" value="${}" />
		<replacefilter token="" value="${}" />
		<antelope:stringutil string="${basedir}" property="pluginpath">
			<antelope:replace regex="\\" replacement="/" />
		<property name="plugincontextfile" value="${pluginpath}/${}-portlet/${}-portlet.xml" />
		<copy file="${pluginpath}/EXPLODEDWARTEMPLATE-portlet.xml" tofile="${plugincontextfile}" />
		<replace file="${plugincontextfile}">
			<replacefilter token="" value="${}" />
			<replacefilter token="@pluginpath@" value="${pluginpath}" />
	<mkdir dir="${}-portlet/docroot/WEB-INF/tld" />

2) Create a template Tomcat configuration file #

Create a file named EXPLODEDWARTEMPLATE-portlet.xml inside the pluginsSDK\portlets directory with the following content:

	<?xml version="1.0"?>

3) Done #

Now you can run ant create for creating new portlets as usual and they will be created with 'fast development' preconfigured.

Other useful customizations #

Deployment of exploded WAR using ANT #

Add the following new target inside the pluginsSDK\portlets\build-common-portlet.xml file:

	<target name="deploy-exploded" depends="compile">
			<antelope:stringutil string="${basedir}/${}.xml" property="plugincontextfile">
				<antelope:replace regex="\\" replacement="/" />
			<copy file="${plugincontextfile}" todir="${auto.deploy.dir}" />

Note that you also have to add the antelope prefix:


Now, you could do a deploy of the exploded WAR using: ant deploy-exploded

1 附件
65277 查看
平均 (0 票)
满分为 5,平均得分为 0.0。
讨论主题回复 作者 日期
Thanks for the tip. However, it does not run... Fabrice Clari 2008年12月5日 上午12:45
I've changed portal property:... Mariusz Nosiński 2009年3月11日 上午7:56
It is nice. It did run correctly on my side... Jonas Yuan 2009年2月24日 下午1:58
Yes. This task could be normally handled by... Jonas Yuan 2009年2月24日 下午2:35
I must be doing something wrong, I can't get... Seth Wallace 2009年12月1日 上午1:50
For the docBase parameter, I specified Tomcat's... Mike Harris 2011年4月1日 下午1:24
I need help for Jboss Fast... venkatesan shanmugasundaram 2014年10月29日 下午12:37

Thanks for the tip.
However, it does not run correctly on my side when copying context file to Liferay hot deploy directory, but it works when copying that file directly to $TOMCAT_LIFERAY/conf/localhost/Catalina.

I have opened a ticket since it is not the normal behaviour:

在 08-12-5 上午12:45 发帖。
It is nice. It did run correctly on my side when copying context file to Liferay hot deploy directory - at revision 26723.


Jonas Yuan
在 09-2-24 下午1:58 发帖。
Yes. This task could be normally handled by the Liferay hot deploy process: adding Ant target deploy-exploded in Plugins SDK - build-common-plugin.xml.

Add following lines in build-common-plugin.xml

// after <property name="plugin.file" value="${project.dir}/dist/${}-${lp.version}.${plugin.version}.war" />

<property name="context.file" value="${project.dir}/portlets/${}/${}.xml" />

// after <target name="deploy" depends="war">
// <copy file="${plugin.file}" todir="${auto.deploy.dir}" />
// </target>

<target name="deploy-exploded" depends="compile">
<copy file="${context.file}" todir="${auto.deploy.dir}" />

在 09-2-24 下午2:35 发帖以回复 Jonas Yuan
I've changed portal property: 'auto.deploy.tomcat.conf.dir=../conf/Catalina/localhost' to 'auto.deploy.tomcat.conf.dir=${catalina.base}/conf/Catalina/localhost', and portlets deploys correcty when context file is copied to autodeploy dir.
在 09-3-11 上午7:56 发帖以回复 Fabrice Clari
I must be doing something wrong, I can't get this to work with 5.2.3. Tomcat is correctly picking up my Context.xml file and trying to load the docroot I pointed to, but it's complaining about ClassNotFoundExceptions for com.liferay.portlet.StrutsPortlet.

I copied over the dependencies from the original, normal deployed tomcat\webapps\myPortlet directory as mentioned (TLD and LIB folders). Is the jar containing StrutsPortlet somewhere else?
在 09-12-1 上午1:50 发帖。
For the docBase parameter, I specified Tomcat's webapp folder of my project and it worked fine.
在 11-4-1 下午1:24 发帖以回复 Seth J Wingert
I need help for Jboss Fast developments(Hooks,Portlets,Ext... )
Please some one help on this..
在 14-10-29 下午12:37 发帖。