How to move the Liferay hooks into a directory inside webapps?

294 views Asked by At

I have created many hooks for Liferay with Eclipse Java EE IDE for Web Developers. The problem is that when I create a hook is deployed inside the webapps folder.

My webapps folder tree:

enter image description here

There are many hooks. How can how can I move them into a new folder inside webapps? in order to have something like this:

  • webapps
    • calendar-portlet
    • hooks
      • blogs-hook
      • breadcrumb-hook
      • dockbar-hook
      • login-hook
      • blogs-hook
      • sitepages-hook
      • truefalsetocheckbox-hook
      • userinfo-hook
      • wiki-hook
    • marketplace-portlet
    • my-theme
    • resources-importer-web
    • ROOT


Any help is greatly appreciated! Thank you so much!

2

There are 2 answers

0
rlegendi On

I suppose you're speaking about Tomcat's (or whatever appserver you're using) webapp folder. You cannot merge different apps into one folder: it has to keep the structure on deploy.

So what you can do is to aggregate those hooks on source level (i.e., create only one hook project in Eclipse with the Liferay IDE so you can put everything there). So you could put them into the same plugin.

Btw I would discourage using several hooks, because they might occasionally overwrite each other's behaviour. Imagine you have some sort of property defined in a-hook and b-hook in a properties file. You cannot tell which one will be used after the deployment.

1
Olaf Kock On

Adding a bit of reasoning to rlegendi's answer, here's what you might consider:

If you use Liferay's auto-deploy mechanics, e.g. through the plugins-sdk deployment, Liferay places the hooks in tomcat's webapps folder (in case you use tomcat) and you'd also have to override this.

You might be able to configure tomcat to monitor different directories, even on the same virtual host (I've only tried this for different virtual hosts and don't know if this will work properly with Liferay), but the auto-deploy problem would persist, you'd basically have to change the whole deployment logic, or deploy manually to tomcat as you'd do with "big iron" appservers.

If you're happy about the development-time separation between the hooks, but would like some better runtime overview, you might want to merge different hooks into one for deployment. However, you'd have to do this on your own.

But my final recommendation is to not care too much about what's in the webapps directory anyway - you shouldn't rely on directory listings of this directory for knowing what's running on your appserver. Rather use proper deployment techniques that monitor your implementations, and limit access for manual changes. E.g. deploy your applications scripted and install a system that alerts you should required components not be available and running.