Maven插件工件过滤不重要的依赖项
我正在开发一个 Maven 插件,并使用 MavenProject
对象通过 project.getDependencyArtifacts()
访问我的依赖项,但这提供了我的所有 jar,甚至是仅测试的 jar。
有没有一些方法可以过滤所有非运行时 jar?如果我只是获取范围并比较 scope.equals("runtime")
我将抛出编译和其他重要的依赖项。
I'm developing a Maven plugin and using the MavenProject
object to access my dependencies with project.getDependencyArtifacts()
, but this gives my all jar, even the test only jars.
Is there some method to filter all non runtime jar? If I just get the scope and compare for scope.equals("runtime")
I will throw out the compile and other important dependencies.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也没有找到现有的方法,所以我使用以下逻辑。这是一个构建自定义 Ear 的插件,它将所需的依赖项添加到 xml 文件并将它们包含在存档中。它使用
getArtifacts
而不是getDependencyArtifacts
因为我也对传递依赖项感兴趣。I did not find an existing method for this either so I'm using the following logic. This is a plugin building a customized ear, which adds the needed dependencies to an xml file and include them in the archive. It is using
getArtifacts
instead ofgetDependencyArtifacts
since I'm also interested in transitive dependencies.