I have a large multimodule maven project that has a large number of dependencies. I would like to generate a complete, duplicate-filtered list of third-party dependencies (that is, all dependencies not using the group id of the project) this project has.
I have tried using mvn dependency:list -DexcludeGroupIds=org.example.projectx
for this purpose, but it seems unable to aggregate the output into a single list. When I run the command from the project root command line, I get output as follows:
[...]
[INFO] ------------------------------------------------------------------------
[INFO] Building ProjectX: ModuleA - Datatypes 4.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ projectx-moda-datatypes ---
[INFO]
[INFO] The following files have been resolved:
[INFO] org.slf4j:slf4j-api:jar:1.7.10:compile
[INFO] org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] junit:junit:jar:4.12:test
[INFO] com.google.guava:guava:jar:18.0:compile
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ProjectX: ModuleB - Binary 4.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ projectx-modb-binary ---
[INFO]
[INFO] The following files have been resolved:
[INFO] org.slf4j:slf4j-api:jar:1.7.10:compile
[INFO] com.google.guava:guava:jar:18.0:compile
..etc, for every single submodule. Not only is this not a single list (but a separate list for each submodule), but as you can see it contains duplicates. Moreover, the actual output I'm interested in is buried in a torrent of other Maven output (download messages, etc).
The -DoutputFile=<file.txt>
option does not offer a solution either. The result of running mvn dependency:list -DoutputFile=deps.txt
from my project root is not a single file listing all dependencies, but multiple separate files, one in each submodule-directory.
I can of course redirect the maven console output to a file (mvn [options] > output.txt
) and try some clever regexing in vi to filter it down to the list I want. However, I was hoping there was a way to get what I need using just Maven, either using the dependency plugin or some other reporting plugin that I'm not aware of.