Creating Your First EXT Plugin

Update: Please see the official documentation here:

www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/ext-plugins

The first step that we need to take is to "Check Out" or download the Plugins SDK here:
svn://svn.liferay.com/repos/public/plugins/trunk

You'll have to know how to use an SVN client to check out the latest Plugins SDK, but you'll be able to download it from our website once we release 6.0.

I'll include some screenshots in case you just want a general idea of how it works before it's released.

After checking out the new Plugins SDK, you'll notice that there's a new "ext" directory available:

- We can create a hello-world-ext plugin using the the following command for Unix:
./create.sh hello-world "Hello World"

Or the following command for Windows:
create hello-world "Hello World"

This will create a hello-world-ext plugin which should look like this:

Notice the similarities with the EXT Environment:

- Now let's run an "ant clean":

We get this error message because we haven't defined any of the properties:

app.server.zip.name is the location of the zipped server bundle
ext.work.dir is the location where you want to unzip your server
app.server.dir is the location of your server directory

We'll need these properties so that ant knows the location of the app.server.dir (server directory), the location of the app.server.zip.name (zipped server bundle) and the ext.work.dir (location where you want to unzip your server).

- You can create your own zipped Tomcat bundle by reading my blog post here:
Building a Tomcat Bundle from Liferay trunk

- Once you've created your zipped Tomcat bundle, you can point your "app.server.zip.name" property to it like this:
app.server.zip.name=/Users/ed/liferay/portal/dist/liferay-portal-tomcat-6.0.0.zip

- Create your build.${user.name}.properties file here:

- Set the location of your properties. I've set mine as follows:

 

That's all you need to do to set up the environment!

To recap, all we've done so far is set up 3 properties for the location of our server, the location of our zipped server bundle and the directory that we want to unzip the bundle to.

Now we can see how this works in action:

Running "ant clean" will now delete the server directory and unzip a clean copy of our zipped server bundle:

Running "ant compile" will compile all the necessary ext code.



Running "ant war" will create /plugins/dist/hello-world-ext-5.3.0.1.war

You can hot deploy this war to a running Liferay bundle. It'll tell you to reboot after the ext plugin has been deployed (since you're changing core classes):

After creating your own hello-world-ext plugin, you'll now see how much lighter EXT Plugins is compared to the EXT Environment. Try modifying a few classes to see how it works in practice.

(Keep in mind that EXT plugins are designed to override the portal's core code that cannot be done with hooks, layout templates, portlets, or themes. EXT plugins are not meant to contain new custom services.)

ブログ
"Keep in mind that EXT plugins are designed to override the portal's core code that cannot be done with hooks, layout templates, portlets, or themes. EXT plugins are not meant to contain new custom services"

If I understand correctly that EXT plugins replace the native 5.x EXT framework, why would they not also support new custom services? For example, we use Service Builder in 5.2 EXT to create new custom services in addition to extending the DB.
EXT plugins do support custom services. I've tested that this works when I migrated custom services from my 5.2 EXT environment to an EXT plugin.

However, EXT plugins are part of a design shift that we've been making since 4.x. Instead of having monolithic structures, we've slowly been extracting out portlets from core to make it more light weight and customizable, and we've been promoting the use of plugins.

Unlike the EXT environment which is another monolithic structure, EXT plugins are only meant to override core classes.

We realize that people who are migrating from the EXT environment will still need to use custom services in EXT plugins, but new services should be created within portlet plugins and existing services should be migrated to portlet plugins since support for custom services in EXT plugins will eventually be removed.

We realize that this is a big change, but it's a necessary one. If we didn't make these types of changes, things like portlet plugins wouldn't exist which have been very useful for the community as a whole.

We'll continue to support customers that have existing EXT environments as much as we can. Let's continue this discussion on the forums here:
http://www.liferay.com/community/forums/-/message_boards/message/4533829
Is the EXT plugin method to be used only with 6.0? Do you recommended that 5.2.3 users continue using the existing EXT environment method?
EXT plugins are only available in 6.0 so can't use them for 5.2.
How would i able to make JSON call for the plugin environment custom services, if i'm creating outside plugin ext ? I was able to do this in ext environment ? Does this feature still supported ? How to generate code for JSON interface ?
Hi Edward,

Do you have any reference link that provides step for changing java files (action file) of an existing functionality. Say if I want to change action file for calendar portlet using ext in plugin.

Thanks,
Tarun
Hey Edward,

I am starting with Liferay 6.02 so no upgrading issues. When I ran through your example, clean compile and war all worked but when I ran deploy I received the same error as William Chu is the previous post.

I copied the /ROOT/WEB-INF/web.xml to web.xml.merged and the script proceeded until I received:

21:20:24,757 ERROR [PropsUtil:107] Unable to initialize PropsUtil
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:394)
at java.util.Properties.setProperty(Properties.java:143)
at java.lang.System.setProperty(System.java:729)
at com.liferay.util.SystemProperties.set(SystemProperties.java:60)
at com.liferay.portal.util.PropsUtil.<init>(PropsUtil.java:94)
at com.liferay.portal.util.PropsUtil.<clinit>(PropsUtil.java:231)
at com.liferay.portal.util.PropsValues.<clinit>(PropsValues.java:29)
at com.liferay.portal.spring.util.SpringUtil.loadContext(SpringUtil.java:46)
at com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:132)
at com.liferay.portal.tools.WebXMLBuilder.main(WebXMLBuilder.java:43)
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.liferay.portal.spring.util.SpringUtil.loadContext(SpringUtil.java:46)
at com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:132)
at com.liferay.portal.tools.WebXMLBuilder.main(WebXMLBuilder.java:43)
Caused by: java.lang.NullPointerException
at com.liferay.portal.util.PropsValues.<clinit>(PropsValues.java:865)

Where the missing property is "liferay.home" which I added to properties and now the script is complaining about "portlet.event.distribution":

Loading jar:file:/C:/Liferay/servers/liferay-portal-6.0.2/tomcat-6.0.26/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.liferay.portal.spring.util.SpringUtil.loadContext(SpringUtil.java:46)
at com.liferay.portal.util.InitUtil.initWithSpring(InitUtil.java:132)
at com.liferay.portal.tools.WebXMLBuilder.main(WebXMLBuilder.java:43)
Caused by: java.lang.NullPointerException
at com.liferay.portal.util.PropsValues.<clinit>(PropsValues.java:865)
... 3 more

Is there something that I am missing? It seems that there should not be this many snags to deploying a basic ext plugin...

Thanks in advance
Hi everyone,

This post was created on the latest revision of trunk back in March. A lot of changes have been made in order to get ready for 6.0 GA, and it looks like the instructions may or may not work as is for all environments. We'll be coming out with new instructions on how to use EXT plugins that won't require as many steps because we'll have everything packaged and downloadable. This post was mainly to pique the interest of anybody that was on the cutting edge, and wanted to check the latest status of EXT plugins at that time. Again, we'll have more streamlined instructions available soon on our wiki or in the documentation section of our website.
Please note that this is NOT supported for the 5.2 product line. This will be supported in the 6.0 product line
We use Enterprise product line, and in 5.2.7. there IS an ext sdk.
Are you recommended to use it or we need to wait till 6.0. is coming?
EXT Plugins will be supported in 6.0 EE. For 5.x line, it is experimental.
Ed,

Has the EXT Plugins been tested with jboss? I am trying to migrate a 5.x ext environment to 6.x ext plugin, so far with no success. I have some more concrete questions, but I don't know if this blog is the proper place.

Regards,
Ken
I also am having issues with creating a 6.0.2 ext plugin. I'm getting the following error.

/Users/biuniu/Documents/SVNROOT/liferay-plugins-sdk-6.0.1/ext/build-common-ext.xml:309: Warning: Could not find file /Users/biuniu/Documents/SVNROOT/ext-work/liferay-portal-6.0.2/jboss-5.1.0/server/default/deploy/ROOT.war/WEB-INF/web.xml.merged to copy.
Hi Edward: I am new to using Liferay as I find it very interesting. I'm investigating, I would modify the sources to add little feature. We have made a modification in the jsp and then as you indicate in your manual we have generated. WAR and we have placed in the "deploy" start the tomcat but the changes are not reflected in the portal. What additional configuration must be performed to be able to see the changes we have made in the EXT (we are using Liferay 6.0)
Hi,
Thanks for sharing the great details of ext plugin. My team is using Liferay-Jboss bundle 6.0.6.
We have use case for update password portlet. On the update page, user is asked to put the the old password and validation is performed. Once user clicks on "Save" button he/she is redirected to Homepage of the organization and not the community.
Can I use EXT Plugin to develop new custom action class to fullfil this use case?
This is a very useful article. thank you Ed.
I have a query reg ant clean cmd.
When Im running ant clean cmd:
all it does is delete my example-ext-6.0.5.1.war from the dist folder Is this all that the cmd does? should it not behave the way as mentioned in this article?
again when i run ant war cmd, it re creates the war under dist folder with my changes implemented in the new war.

Please let me know if I'm missing anything and guide me accordingly.

thanks.
i try to implement ext plugin as per docs it removes all my communities and data....nd remove my portal-properties.ext.?can anyone help me how to revert back my data now?
Hi,

I am new for liferay development.I want to customize document library part .Please help us how I change Document- library -structure.xml and DLFILEentrytypeconstant.java.