I've built a sample module with the following structure and dependencies:
osgi-lfr-module
+--- module0
| \--- org.apache.commons:commons-lang3:3.5
+--- module1
| \--- module0
\--- module2
+--- module1
\--- org.apache.commons:commons-collections4:4.1
I want to build a single jar
to deploy in Liferay 7 containing modules 0, 1 and 2 and 3rd party dependencies. I know it's not the recommended approach, but I'm would like to know how to achieve it.
module2/build.gradle
file is:
buildscript {
dependencies {
classpath 'com.liferay:com.liferay.gradle.plugins:2.0.10'
}
}
apply plugin: "com.liferay.plugin"
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
dependencies {
compile project(':module1')
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
}
I've followed the steps from OSGi Module Dependencies . Up until now, I'm able to add direct dependencies in module2/bnd.bnd
:
Bundle-Version: 1.0.0
Export-Package: com.test.module2, com.test.module1, com.test.module0
Bundle-ClassPath: \
.,\
lib/module1.jar,\
lib/commons-collections4.jar
-includeresource: \
lib/module1.jar=module1-1.0.0.jar,\
lib/commons-collections4.jar=commons-collections4-4.1.jar
But if I try to add transitive deps, like module0
:
Bundle-ClassPath: \
.,\
lib/module0.jar,\
lib/module1.jar,\
lib/commons-collections4.jar
-includeresource: \
lib/module0.jar=module0-1.0.0.jar,\
lib/module1.jar=module1-1.0.0.jar,\
lib/commons-collections4.jar=commons-collections4-4.1.jar
Build fails with the following error:
:module2:jar
[Input file does not exist: module0-1.0.0.jar]
[No sub JAR or directory lib/module0.jar]
Can anyone help me to find out what I'm doing wrong? And, is there any way less manual to add transitive dependencies?
Thanks in advance for your help.
com.liferay.plugin
applies gradle-bundle-plugin
to invoke Bnd and create the JAR, so you can use all its options. This is the one you need, please add it to your module2 's build.gradle
:
bundle {
includeTransitiveDependencies = true
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.