[英]Why do I have unresolved symbols that should be in my jar library?
Gradle v2.9 (old I know, but upgrading is another project) Gradle v2.9(旧的我知道,但升级是另一个项目)
I see How to create my own java library(API)?我看到了如何创建自己的 java 库(API)? and I'm doing something similar.
我正在做类似的事情。
I'm pretty familiar with JARs and compiling Java code.我对 JARs 和编译 Java 代码非常熟悉。 I also have Maven experience, and I'm trying to do this in Gradle, but the fundamentals should be the same.
我也有 Maven 的经验,我正在尝试在 Gradle 中做到这一点,但基本原理应该是一样的。
I want to create a library, which includes other libraries.我想创建一个包含其他库的库。 So I have this
build.gradle
file所以我有这个
build.gradle
文件
myLib/build.gradle:
dependencies {
compile "com.someDomain:other-lib:1.0.0"
}
I can build myLib-1.1.0.jar
with no issues, and deploy it to my repo as我可以毫无问题地构建
myLib-1.1.0.jar
,并将其部署到我的仓库中
artifactId: myLib
groupId: com.myDomain
version: 1.1.0
Now I want to use myLib.jar
to build another component, myComp.war
, so I have this现在我想使用
myLib.jar
来构建另一个组件myComp.war
,所以我有了这个
myComp/build.gradle:
dependencies {
compile "com.myDomain:myLib:1.1.0"
}
So my dependency tree is as follows, meaning, myComp
uses the myLib
library, which in turn uses the other-lib
library.所以我的依赖树如下,意思是
myComp
使用了myLib
库,而myLib又使用了other-lib
库。 Straight-forward enough.够直截了当。
com.myDomain:myComp:1.2.0
+--- com.myDomain:myLib:1.1.0
| +--- com.someDomain:other-lib:1.0.0 <---- the symbol is in this library
and when I run ./gradlew build
for myComp
I see both the myLib-1.1.0.jar
and other-lib-1.0.0.jar
artifacts being downloaded from my central repo, and stored in my ~/.gradle
cache.当我为
myComp
运行./gradlew build
时,我看到myLib-1.1.0.jar
和other-lib-1.0.0.jar
工件正在从我的中央仓库下载,并存储在我的~/.gradle
缓存中However, I get an symbol not found
error for a symbol that's in other-lib.jar
which was included in the myLib.jar
file.但是,对于
myLib.jar
文件中包含的other-lib.jar
中的符号,我收到symbol not found
错误。 Makes sense?说得通?
What am I missing?我错过了什么?
Because building a jar only archives the files in that project's source tree, it does NOT include jars that it depends on for compilation.因为构建 jar 仅归档该项目的源代码树中的文件,所以它不包括编译所依赖的 jars。 To package other jars within a jar, like I want to do, follow How to include dependencies in a jar?
到 jar 中的 package 其他 jars ,就像我想做的那样,请按照如何在 Z68490Z4? from the Gradle forum.
来自 Gradle 论坛。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.