Liferay 7 gradle workspace: How to add jars in liferay-plugin-package

thumbnail
MOHSIN m, modified 7 Years ago. New Member Posts: 17 Join Date: 6/1/15 Recent Posts

I have a liferay 7 workspace created and a spring mvc project which reside in WAR folder(not a module).

I need to add my jars which are present inside WEB-INF/lib of project to get rid of build errors.

HOW CAN I DO THAT AND WHAT IS THE GOOD APPROACH FOR SPRING MVC PROJECT WHICH RESIDE IN WAR DIR.

thumbnail
David H Nebinger, modified 7 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

So first, under Liferay 7, the liferay-plugin-package.properties file list of dependency jars is no longer supported.

Instead, you should just list your dependencies in your project build file (either build.gradle or pom.xml) and let the build process create the war w/ the dependencies downloaded and pulled in like a regular war project.

thumbnail
MOHSIN m, modified 7 Years ago. New Member Posts: 17 Join Date: 6/1/15 Recent Posts

Thank you David,

 I know portal dependency jar is depricated in liferay 7 but how about bnd attribute like Export-Package,Import-Package,.. that I guess we can specify.

I have a WAR project where in all my jars are pulled in gradle file, while building it is giving me "Unresolved requirement: Import-Package: bsh" issues which I can handle in liferay-plugin-package.prop file by specifing

Import-Package= !bsh -is that right?

 

And how about jar which is not avaialbe in any repo(Custom jar); how can I make it available to my war portlet.

 

thumbnail
David H Nebinger, modified 7 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
MOHSIN m:

I know portal dependency jar is depricated in liferay 7 but how about bnd attribute like Export-Package,Import-Package,.. that I guess we can specify.

Yes, you can add any of the bnd.bnd directives into the liferay-plugin-package.properties and they'll get picked up.

MOHSIN m:

I have a WAR project where in all my jars are pulled in gradle file, while building it is giving me "Unresolved requirement: Import-Package: bsh" issues which I can handle in liferay-plugin-package.prop file by specifing

Import-Package= !bsh -is that right?

Almost, it is actually like:

Import-Package=!bsh,\
   *

The last line is important; the previous lines tell OSGi what you aren't going to import, but you need the last line to say it's okay to import everything else.

MOHSIN m:

And how about jar which is not avaialbe in any repo(Custom jar); how can I make it available to my war portlet.

So for those, you want to use the compileOnly Gradle directive.  This will allow your code to build, but will not be included in the war.

When deployed, as long as the dependency is satisfied within the OSGi container, OSGi will happily wire it in for your WAR-based module.

thumbnail
MOHSIN m, modified 7 Years ago. New Member Posts: 17 Join Date: 6/1/15 Recent Posts

Hi David,

 

There is a jar "ccavutil" which is used for ccavenue payment gateway, How can I have this in my WAR project?

I have theses /images, /css, /js mulitple files inside 

"Workspace\wars\Sample\src\main\webapp\" , in my jsp I also have "request.getCOntextPath() "+ /js/jsfile.js. But I am seeing code 404 which says it is unable to detect the path. Any idea on this.

thumbnail
David H Nebinger, modified 7 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts

You can't rely on the request context path because that is relative to the portal, not relative to your app.

Switch to an "/o/my-war-name/js/jsfile.js" sort of path instead.  Replace "my-war-name" with the actual name of your built war.

thumbnail
MOHSIN m, modified 7 Years ago. New Member Posts: 17 Join Date: 6/1/15 Recent Posts
Thank you David for your kind attention on my concerns.

I have migrated from Liferay 6.2 plugin to Workspace of about 80%.
I only left with the hooks(specially the jsp's) and EXT(struts action files), Any suggestion would be appreciated.