maven-jar-plugin 和传递依赖项
我正在使用程序集和 jar 插件来部署我的应用程序。 我还使用 jar 插件来帮助我在清单文件中生成类路径,
<addClasspath>true</addClasspath>
虽然这似乎有效,但当我尝试执行 jar 时(它指定了正确的主类),问题就出现了 - 它将无法找到库实际上是一个传递依赖。 所以我的项目A依赖于项目B,项目B依赖于jar C。程序集插件将正确地压缩A、B和C,但jar插件没有在清单中包含C,从而导致ClassNotFoundException。
我在 maven-jar-plugin 中没有看到任何允许我指定需要传递依赖项的选项。
我的做法正确吗? 还有其他人设法将传递依赖项生成到清单中吗? 也许我做错了什么或者不按顺序做事。 任何帮助表示赞赏。
I'm using both the assembly and jar plugins to deploy my application. I'm also using the jar plugin to help me generate the classpath in the manifest file using
<addClasspath>true</addClasspath>
While that seems to work, the problem comes when I try executing the jar (it has a proper main class specified) - it will fail to locate a library that's actually a transitive dependency. So my project A depends on project B, and project B depends on jar C. The assembly plugin will correctly zip up A, B, and C, but the jar plugin did not include C in the manifest, causing a ClassNotFoundException.
I don't see any options in maven-jar-plugin that lets me specify that transitive dependencies are required.
Am I doing it the right way? Anyone else managed to get transitive dependencies generated into the manifest? Maybe I'm doing something wrongly or out of order. Any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我试图解决上述问题。 就我而言,它有效(maven-jar-plugin v2.2)。
我有一个名为 jarloading 的父项目,它有 3 个子项目:
调用发布它之后
它的部署脚本
在使用包含更改目录
并运行
工作正常。
但实际上重点是,类路径如何在清单文件中列出:
主项目的 pom.xml:
a 项目的 pom.xml:
b 项目的 pom.xml 没有什么特别的。
以及附加的源代码和二进制文件:
源代码
二进制文件
i tried to solve the mentioned problem. in my case it worked (maven-jar-plugin v2.2).
i've got a parent project called jarloading that has 3 childs:
after calling
publishing it using a deploy script containing
changing to directory
and running
it worked fine.
but actually the point is, how the classpath is listed in manifest file:
pom.xml of main project:
pom.xml of a project:
pom.xml of b project contains nothing really special.
and attached source code and binaries:
source code
binaries
我无法让 maven-jar-plugin 工作,我不得不使用 maven-assemble-plugin。
示例:
I couldn't get the maven-jar-plugin to work, I had to use the maven-assembly-plugin.
Examples:
我设法解决了...但实际上并没有解决它。 我仔细检查了一下,仍然不知道为什么一些传递依赖项没有被拾取——它似乎跳过了它们,并且它们最终没有生成到 MANIFEST 中。
我仔细研究了一下并使用了 maven-dependency-plugin。 令人惊讶的是,配置
true
并将其绑定到assembly: assembly
阶段解决了类路径问题。I kinda managed to resolve by... not actually resolving it. I checked closer and still don't know why some transitive dependencies aren't getting picked up - it seems to skip of them and they end up not getting generated into the MANIFEST.
I dug around a bit and played with the maven-dependency-plugin. Surprisingly, configuring
<attach>true</attach>
and tying it to theassembly:assembly
phase solved the classpath issue.