Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capturing standards out of a class run by mvn exec:java

Tags:

java

stdout

maven

I would like to run a main method using Maven's exec command. I can set it up to run just fine, but the output of my class is surrounded by Maven's text.

[INFO] Error stacktraces are turned on. 
[INFO] Scanning for projects...
[WARNING] 
...
(actual program output)
...
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.351s
[INFO] Finished at: Fri Apr 01 11:38:15 PDT 2011
[INFO] Final Memory: 50M/452M
[INFO] ------------------------------------------------------------------------

Is there a way to just capture just the program output and not the Maven output? Or do I need to rewrite my software to write to a file (not ideal)?

like image 593
schmmd Avatar asked Apr 01 '11 18:04

schmmd


2 Answers

Execute mvn with the -q flag to silence Maven's output.

like image 155
matt b Avatar answered Oct 13 '22 09:10

matt b


There's no good solution to this. It's just how the exec plugin works. You could use the exec goal and run a shell script that redirected the output.

like image 35
bmargulies Avatar answered Oct 13 '22 09:10

bmargulies