Maven中的依赖jar文件列表

2022-01-15 00:00:00 dependencies java maven-2 classpath

使用 Maven 2,有没有一种方法可以列出 jar 依赖项作为文件名?

Using Maven 2, is there a way I can list out the jar dependencies as just the file names?

mvn dependency:build-classpath 

可以列出 jar 文件,但这将包括它们在我的本地存储库中的位置的完整路径.我需要的基本上只是一个文件名列表(或复制依赖目标复制的文件名).

can list the jar files, but that will include the full path to their location in my local repository. What I need is essentially just a list of the file names (or the file names that the copy-dependencies goal copied).

所以我需要的列表是这样的

So the list I need would be something like

activation-1.1.jar,antlr-2.7.6.jar,aopalliance-1.0.jar etc...

理想情况下,作为一个 maven 属性,但我想,可以生成诸如 build-classpath 之类的文件.

ideally as a maven property, but I guess, a file such as build-classpath can generate will do.

我想要实现的是将 Bundle-ClassPath 写入 OSGi 捆绑包的其他手动维护的 MANIFEST.MF 文件.(你不需要理解这一点来回答这个问题.)

What I am trying to achieve is writing a Bundle-ClassPath to an otherwise manually maintained MANIFEST.MF file for a OSGi bundle. (You shouldn't need to understand this bit to answer the question.)

澄清一下:问题不是关于如何将清单标头写入 jar 中的 MANIFEST.MF 文件(这很容易 googleble).我在问如何获取我要写入的数据,即上面显示的列表.

To clarify: The question is not about how to write manifest headers into the MANIFEST.MF file in a jar (that is easily googleble). I am asking about how to get the data I want to write, namely the list shown above.

推荐答案

这个命令会生成你的maven项目的依赖树:

This command will generate the dependencies tree of your maven project:

$ mvn dependency:tree

我相信你会喜欢这个结果:-)

I am sure that you will like the result :-)

相关文章