简体   繁体   English

为什么我的 jar 库中有未解析的符号?

[英]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.jarother-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.

相关问题 为什么要签署我的 JAR 文件? - Why should I sign my JAR files? Netbeans我添加的库JAR /文件夹在哪里? - Netbeans Where is my Library JAR/Folder that I have added 是否应该将doclet和taglet与其余共享库类放在单独的jar中? - Should I put my doclet and taglet in a seperate jar from the rest of my shared library classes? 如果我的android项目依赖于具有其他依赖项的.jar,我是否必须在项目中包含这些依赖项? - If my android project depends on a .jar that has additional dependencies, should I have to include those in my project? TDD:我必须定义我的代码不应该做的所有事情吗? - TDD: Do I have to define everything my code should NOT do? 我怎么知道为什么某个Jar被添加到我的项目中? - How do I know why a certain Jar was added to my project? 为什么我的BaseGameUtils库有很多错误? - Why do I have so many errors from the BaseGameUtils library? 我有一个可以在所有项目中重用的类。 我应该把它变成一个库组件吗? - I have a single class that I reuse in all my projects. Should I turn it into a library component? 为什么即使我在proguard-project.txt中添加了jar文件,也出现此错误? - Why i am getting this errors even i have added my jar files in proguard-project.txt? 如何从我的库中已有的jar文件导入? (Netbeans Java) - How do I import from a jar file that is already in my library? (Netbeans Java)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM