For all interested people which participated this years Unconference, here you have the information of my session:
Sometimes one have the requirement to load a certain plugin before another. It's a typical use case, which Liferay covers with the required-deployment-contexts setting in the "liferay-plugin-package.properties" file. So if you have a plugin, which is mandantory for other plugins, you have to add it to all of these other plugins as required deployment context. If it's just your own plugins, sure, it's possible. But having also third party plugins may lead to a problem of updating the files.
Another related issue is the deploy order of all plugins. Of course one can use required-deployment-contexts again to get an order for some plugins, but maybe you need to have your portlet to deploy first. What can we do here?
Since Liferay 6.1 we have the marketplace-portlet and since Liferay 6.2 you may have noticed, that it always deploys first, because every other plugin is "magically" waiting for it to deploy. It's not in the required-deployment-contexts of all other plugins, so there must be a hidden mechanism to do this. And guess what, there is a mechanism!
Since Liferay 6.2 there is a plugins1 folder in a certain package of the portal-impl. In this folder we have the marketplace-portlet WAR file and a "wars.txt" file with just the name of the WAR file in it. This is all they have and all you need. So let's do it.
Adding global plugin dependencies
First step is to create an EXT, then create a new package in "ext-impl/src" called "com.liferay.portal.deploy.dependencies.plugins2" with an empty "wars.txt" file in it. Now add your plugin WAR file into the package, for example solr4-web-22.214.171.124.war, and add the name of the file, again solr4-web-126.96.36.199.war, into the "wars.txt". After deploying the EXT, your plugin is mandantory for all other plugins. It's also possible to add more than just one WAR file. Just add another into the package and add the name to the "wars.txt". Note, that the list of names have to be a comma separated list without whitespaces.
Adding an order
Adding plugins into the package will make sure, that these will load before other plugins, but the order within the package cannot be assured.
For this purpose have a look at the package name. Why is it "plugins2"? Because here we have the answer! "plugins1" is the package containing the marketplace-portlet. Besides, you can use "plugins2" to "plugins8" (it's hardcoded in Liferay) for ordering your plugins. So in my example the marketplace-portlet will deploy always first and afterwards solr4-web, then everything else.
When the EXT is deployed, you don't have to deploy the contained WAR files by hand, it will happen automatically. But to prevent errors on first startup, I recommend to deploy them with the EXT together.
If you make changes to your plugin, just deploy it the normal way, you don't have to redeploy the whole EXT, as long as the name stays the same. The version that is deployed inside the EXT won't overwrite the later version.
When a plugin, that is deployed inside the EXT in plugins1-8, is undeployed, the plugin will be redeployed by the EXT within one minute.
As OSGi is coming, this method will be unsupported as OSGi modules will automatically deploy only if all dependencies are given. Until then (like until Q4 2015) you can use the abovementioned.
This information was originally posted at Ancud Blog so check it out for this and other topics. :)