掲示板

Gradle dependency not resolved issue

thumbnail
7年前 に Gaurav Jain によって更新されました。

Gradle dependency not resolved issue

Junior Member 投稿: 85 参加年月日: 16/07/12 最新の投稿
Hi everyone,

I am overriding MVCActionCommand for export-import portlet. This export-import portlet uses com.liferay.exportimport.web.portlet.action.ActionUtil class. I have following gradle dependencies defined for my module:


dependencies {
compile group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
compile group: "com.liferay", name: "com.liferay.exportimport.api", version: "2.1.0"
compile group: "com.liferay", name: "com.liferay.exportimport.web", version: "1.0.9"
compile group: "com.liferay", name: "com.liferay.exportimport.service", version: "3.0.1"
compile group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
compile group: "javax.portlet", name: "portlet-api", version: "2.0"
compile group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
compile group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
}


With these dependencies, I am able to use com.liferay.exportimport.web.portlet.action.ActionUtil class compile time.
But after deploying my module, it gets listed in modules as INSTALLED not ACTIVE and on using diag it shows error:

export.mvccommand.override.module [537]
Unresolved requirement: Import-Package: com.liferay.exportimport.web.portlet.action


I do not know, why I am getting this error?
please help!

Thanks,
Gaurav
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Gradle dependency not resolved issue

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
I'm not sure what version you're using, but in GA3 this class has been moved to an "internal" package, a clear indicator that it is not available for import/use.

I'm guessing that if you look at the bnd.bnd file for the module in the source for the version you're using, you will find that maybe some packages are marked as exported but the util package is marked as private.

Not all packages from source are available for you to use. Liferay uses the export/private package declarations to hide implementation details from external use.






Come meet me at the LSNA!
thumbnail
7年前 に Gaurav Jain によって更新されました。

RE: Gradle dependency not resolved issue

Junior Member 投稿: 85 参加年月日: 16/07/12 最新の投稿
David H Nebinger:
I'm not sure what version you're using, but in GA3 this class has been moved to an "internal" package, a clear indicator that it is not available for import/use.


Hi David,

Thanks for you reply. Yes you are right, this class has been moved to an "internal" package. In this scenario is there any alternative to implement rather reuse such functionality? Or we have to create a custom implementation for such functionality?

Thanks
Gaurav
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Gradle dependency not resolved issue

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Sorry, if it's private it will not be available outside of the bundle. If you need same or similar functionality in your own module, you'll need to add it yourself.

Note that OSGi modules don't really support a concept of module extension. You can have a module, you can replace a module (by using a higher version and matching meta), but you cannot "extend" a module. The JSP fragment bundles are an exception, but one that I believe Liferay coded specifically to support.









Come meet me at the LSNA!
thumbnail
7年前 に Gaurav Jain によって更新されました。

RE: Gradle dependency not resolved issue

Junior Member 投稿: 85 参加年月日: 16/07/12 最新の投稿
Hi David,

Thanks for this useful information.

Regards
Gaurav
thumbnail
7年前 に Gaurav Jain によって更新されました。

RE: Gradle dependency not resolved issue

Junior Member 投稿: 85 参加年月日: 16/07/12 最新の投稿
Hi David,

I have one more issue regarding gradle dependencies. In LR 6.2 I was using com.liferay.util.Encryptor for some encryption purposes. Same class I tried to use in LR 7, but no such class was present there to import. Then after bit of investigation I found that this utility class resides in [TOMCATE_HOME]/webapps/ROOT/WEB-INF/lib/util-java.jar, So I added this jar as an external JAR through Configure Build Path. I was able to import com.liferay.util.Encryptor. But when I deployed the module, it threw this error:

:modules:blog-mvccommand-override-module:compileJava/mnt/d/Liferay7EclipseBundleWorkspace/IDE workspaces/start-up-wokspace/lfr-worksapce/modules/blog-mvccommand-override-module/src/main/java/in/componence/override/mvccommand/blogs/OverrideBlogMVCActionCommand.java:26: error: package com.liferay.util does not exist
import com.liferay.util.Encryptor;
^
1 error
FAILED

FAILURE: Build failed with an exception.


Now I want to ask if I want to use this utility, which I could use in LR 6.2, then how can I use?


Thanks,
Gaurav
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Gradle dependency not resolved issue

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
util-java is not loaded as an OSGi bundle so it is not directly available for you to use. You'd have to include the dependency within your module.






Come meet me at the LSNA!
thumbnail
7年前 に Gaurav Jain によって更新されました。

RE: Gradle dependency not resolved issue

Junior Member 投稿: 85 参加年月日: 16/07/12 最新の投稿
David H Nebinger:
util-java is not loaded as an OSGi bundle so it is not directly available for you to use. You'd have to include the dependency within your module.


Hi David,
I tried to include the dependencies in my module's build.gradle file like this:

compile group: "com.liferay.portal", name: "com.liferay.util.java", version: "2.0.0"

I was able to import package com.liferay.util and use its Encryptor class. Then I deployed module. It got deployed successfully. But it was listed as INSTALLED when I did lb on gogo. On doing diag, it showed some dependencies issues:

Unresolved requirement: Import-Package: com.liferay.util; version="[7.0.0,8.0.0)"

How can I resolve these unresolved requirements?
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Gradle dependency not resolved issue

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Sorry, Gaurav, I didn't mean declare as a compile dependency, I meant include the dependency in the module itself.

Check my blog post: https://web.liferay.com/web/user.26526/blog/-/blogs/osgi-module-dependencies








Come meet me at the LSNA!