This website uses cookies to ensure you get the best experience. Learn More.
Mavenize Liferay Plugins SDK - Using Maven
When working with Liferay projects using Liferay IDE and Plugins SDK it becomes highly difficult to manage dependencies, as Liferay IDE or Plugins SDK by default uses Ant for building and deploying, though Liferay does support Maven based Plugins but as a seasoned Liferay Developer we will be inclined to use Ant preferred to Maven. The problem rather I call it a difficulty arises when,
In this article we will look at how we can use Maven dependency management in Plugins SDK by still using the default Ant based Liferay SDK build, you can use any of your existing Liferay Plugins SDK project which has external dependencies.
I have tested this application on the following technical platform, this works irrespective of Operating System.
Assuming that you have downloaded and installed the above mentioned softwares, for the sake of convenience we will use the following variable names for respective installation DIR’s,
Now copy the maven-ant-tasks-2.1.3.jar to $ANT_HOME/lib
Let’s use the Liferay IDE to create a new Portlet plug-in look at Using Liferay Maven SDK or you can import the attached Liferay Google Maps demo project in to your workspace, Open the build.xml of the project that has been created, by default the project build template looks like
Now to Mavenize the default ANT build.xml we do the following,
A example of build.xml with above configurations is available here
Observe the artifact:dependencies task portions those are important pieces of mavenizing our ant build. We add the dependencies to the project the same way we add them in Maven pom.xml with little bit of variation to the syntax.
After this once you execute the build in Portlets plug-in directory, it will first download the dependency jars if it does not exist in to the local Maven repository and they will added to the docroot/WEB-INF/lib directory when copy-dependencies target is called, which also includes call to the Liferay default deploy target
Voila! Now we are able to use the Maven dependency management with Liferay Plugins SDK default Ant build system. I hope this article has helped you, for further reading you can check the following links,