I’m developing a Liferay application, consisting on 2 different portlets, an both have to make certain operations in common, so I decided to put that operations in static methods in an external Utils class.
I have to externalize that class to avoid duplicating the same code in both portlets, and I want to have the portlets in different WAR files.
I know I can package the Utils class in a JAR file, but we are still developing and we don’t want to regenerate the JAR and restart the Tomcat for every change.
Which is the best option and how can I perform it?
If you’re using the Liferay SDK, you can use the
clients(recently changed toshared) directory to put your common code.A good example is how deploy-listener-shared is used in conjunction with deploy-listener-hook.
From what it looks like, all the configuration you need to do is to modify your
build.xmlfiles that will use the client\shared classes. If you look at build file of deploy-listener-hook you can see all you need to add is the.For the new SDK:
For the older SDK:
Hope this helps!