mavenbuild-dependencies

How to get Maven dependencies printed to a file in a readable format?


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.


Solution

  • This can (at least now) be done with command line options to the dependency:tree plugin.

    Try:

    mvn dependency:tree -Doutput=/path/to/file
    

    Reference: Maven Dependency Plugin Page

    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. 
    

    So, consider trying it with -DoutputFile=/path/to/file

    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.