gpt4 book ai didi

java - Gradle + OSGi Liferay7 模块,包括传递依赖

转载 作者:行者123 更新时间:2023-11-30 06:51:19 25 4
gpt4 key购买 nike

我构建了一个具有以下结构和依赖项的示例模块:

osgi-lfr-module
+--- module0
| \--- org.apache.commons:commons-lang3:3.5
+--- module1
| \--- module0
\--- module2
+--- module1
\--- org.apache.commons:commons-collections4:4.1

我想构建一个 jar 以部署在包含模块 0、1 和 2 以及第 3 方依赖项的 Liferay 7 中。我知道这不是推荐的方法,但我想知道如何实现它。

module2/build.gradle 文件是:

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'
}

我已按照 OSGi Module Dependencies 中的步骤操作.到目前为止,我能够在 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

但是如果我尝试添加可传递的依赖项,比如 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

构建失败并出现以下错误:

:module2:jar
[Input file does not exist: module0-1.0.0.jar]
[No sub JAR or directory lib/module0.jar]

谁能帮我找出我做错了什么?还有,有什么方法可以减少手动添加传递依赖项吗?

预先感谢您的帮助。

最佳答案

com.liferay.plugin 适用 gradle-bundle-plugin调用 Bnd 并创建 JAR,因此您可以使用它的所有选项。 This是你需要的,请将它添加到你的 module2build.gradle:

bundle {
includeTransitiveDependencies = true
}

关于java - Gradle + OSGi Liferay7 模块,包括传递依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40303512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com