How to extract output of retire.js into a file from maven execution

283 views Asked by At

I am using retire.js plugin in maven pom file. The vulnerability details are listed along with the build output.

I would like to extract the retire.js output into a separate file.

Can you please suggest some ways to extract only retire.js data into a file.

1

There are 1 answers

0
Antot On BEST ANSWER

Looking into the source code of retire.js Maven plugin we can notice that the log output from retirejs is redirected into Maven's stream (in initMiniLog()). And there seem to be no specific configuration for it.

However, with a bit of tweaking we can set up Maven to gather these logs. So I can suggest the following:

1) By default Maven uses slf4j-simple logger, remove its jar from {M2_HOME}/lib.

2) Place in the same folder a logging library that supports output into files, for example Logback: logback-classic-*.jar and logback-core-*.jar.

3) Define a configuration that will output everything into stdout and only the things that you are looking for into the file. logback.xml should be placed into {M2_HOME}/conf/logging. For example, I used the following draft configuration to extract the output of maven-compiler-plugin into maven.log in the current folder:

<configuration>

  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>./maven.log</file>
    <encoder>
      <pattern>%message%n</pattern>
    </encoder>
  </appender>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%level - %message%n</pattern>
    </encoder>
  </appender>

  <!-- 
     specify the package of retirejs: com.h3xstream.retirejs
  -->
  <logger name="org.apache.maven.plugin.compiler" level="TRACE">
    <appender-ref ref="FILE" />
  </logger>

  <root level="INFO">
    <appender-ref ref="STDOUT" />
  </root>

</configuration>

4) Execute your build command...