Tuesday, August 7, 2012

Including External jars in your Liferay Extension

This is one that I've seen asked about a lot online, and the solution is so painfully simple that I can only conclude that the people who know the answer aren't bothering to help out those who are asking.

That's what this blog is for.

The environment:

Liferay 6.0
Apache Ant

You're trying to use the ant deploy command either from within Eclipse or on the command line but you have a dependency on another .jar file you need to include in the compilation.  If you do this in Eclipse, and include the .jar file in your project build path in Eclipse, the IDE will add a line to your any .classpath file pointing to this dependency.

The problem is that doesn't help your ant find the file.

If you need to include external .jar resources in your Ext, just drop a copy of the .jar you need in your Project/docroot/ext-lib/global folder.  Your ant deploy target should now be able to use it fine.