Get clean machine-friendly Maven lines/xml/json output parseable by scripts in STDOUT?

前端 未结 2 1497
南旧
南旧 2021-01-21 14:23

For example, run this command with for a maven project:

mvn dependency:list

What I need from Maven is only these two lines (cut out fr

相关标签:
2条回答
  • 2021-01-21 14:54

    Maven uses standard slf4j logging, wrapped in a plexus container. https://maven.apache.org/maven-logging.html

    You should be able to configure the slf4j bindings to provide different output formats as detailed here http://logback.qos.ch/manual/layouts.html#log4jXMLLayout

    I'm not familiar with the cleanlines and json logging formats; however, slf4j is probably one of the more adaptable logging packages, so look around for a Formatter and you have a chance at finding one. However, if you don't the last link above also covers the pages on how to write your own logging layout.

    0 讨论(0)
  • 2021-01-21 15:02

    I was able to supply a property to save required clean output into a file.

    For example, -DoutputFile or -Doutput:

    mvn dependency:list     -DoutputFile=dependencies.output.txt
    mvn help:effective-pom  -Doutput=effective.pom.xml
    

    If STDOUT is required, cat the file.

    Even though it's not generic, so far, the workaround solves all cases for me.

    0 讨论(0)
提交回复
热议问题