There is another way to create a JAR file, but it does not require a server restart (at least for Tomcat).
Write a build script for your JAR file so that it compiles, creates the JAR, and finally copies it to the following location:
{tomcat}/webapps/ROOT/WEB-INF/lib
- Then in your portlet open "liferay-plugin-package.properties" (in Liferay Developer Studio / Liferay IDE this should open with a good graphical interface).
Then add the name of your JAR to the list of "portal-dependency-jars" in this file, so in the source that it would like (or just click the "Add" button in the GUI and select the JARs you want):
Dependency portal jar = my custom-lib.jar, my-other-order lib.jar
Save the file and reinstall the portlet, and the JAR will be copied when you deploy the portlet.
I used this method for custom JARs and third-party JARs that I need to use in my portlets.
source share