如何使Maven依赖项以可读格式打印到文件? [英] How to get Maven dependencies printed to a file in a readable format?
问题描述
我正在处理具有许多pom.xml文件的大型项目,并且需要指定我使用的所有库.这意味着我需要递归读取pom.xml文件并获取groupId,artifactId,作用域和版本.我签出了mvndependency:tree,但是找不到以可读格式将其打印到文件中的方法.我看到了appendOutput,但是没有看到有关如何在cmd中使用它的示例.我看到一些解决方案是在Linux上完成的,但是我只能访问Windows XP.
I am working on a big projects with many pom.xml files and I need to specify all the libraries that I use. This means that I need to read pom.xml files recursively and get groupId, artifactId, scope and version. I checked out mvn dependency:tree but I can't find a way to print it to a file in a readable format. I saw appendOutput but I saw no example on how to use it in cmd. I saw some solutions done in Linux but I only have access to Windows XP.
推荐答案
这可以(至少现在)通过dependency:tree插件的命令行选项来完成.
This can (at least now) be done with command line options to the dependency:tree plugin.
尝试:
mvn dependency:tree -Doutput=/path/to/file
参考: Maven依赖插件页面
您只询问了可读"格式,但是您也可以将-DoutputType参数与各种选项一起传递.还请注意,我已经安装了该版本,我收到以下警告:
You only asked about "readable" format, but you can also pass the -DoutputType parameter with various options. Also note that the version I have installed, I get the following warning:
[WARNING] The parameter output is deprecated. Use outputFile instead.
因此,请考虑使用-DoutputFile =/path/to/file
So, consider trying it with -DoutputFile=/path/to/file
此外,我无法获得-DoutputType参数来给我除默认文本以外的任何内容,但没有机会使用它. YMMV.
Also, I was unable to get the -DoutputType paramater to give me anything other than the default text, but didn't have a chance to play around with it. YMMV.
这篇关于如何使Maven依赖项以可读格式打印到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!