Send maven output to file

MavenWindows 7DependenciesMaven PluginMaven 3

Maven Problem Overview


On Windows 7, I am trying to send the output of a maven-3 command to a text file.

I call the command from the root of the project I am trying to analyze.

The command is:

mvn dependency:tree -Dverbose -Dincludes=commons-collections -DoutputFile=C:\Users\myname\Documents\output.txt

When I run the command without the outputFile parameter, I see the output sent to the console.

But when I use it with the outputFile parameter, the output file is empty.

Any idea what I am missing here?

Maven Solutions


Solution 1 - Maven

Try mvn -help

 -l,--log-file <arg>  Log file to where all build output will go.                               

mvn <your parameters> --log-file log.txt

Solution 2 - Maven

Just give it a try:

mvn dependency:tree -Dverbose -DoutputFile=resout.out

within the same folder where the pom file is located.

Solution 3 - Maven

Old school, but it's what I knew. One caveat is that the mvn command does not return when done to the cli, but for some purposes this is acceptable.

mvn "-Dexec.args=-classpath %classpath com.mycompany.test" -Dexec.executable=/Downloads/jdk1.7/bin/java exec-maven-plugin:1.2.1:exec > /tmp/Out

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionraptView Question on Stackoverflow
Solution 1 - MavenAndrzej JozwikView Answer on Stackoverflow
Solution 2 - MavenkhmarbaiseView Answer on Stackoverflow
Solution 3 - MavenPaulView Answer on Stackoverflow