What does mvn sonar:sonar do?

2020-07-13 07:55发布

问题:

What are the maven lifecycle phases does the command mvn sonar:sonar execute?

While I see the logs that run over the screen, at a very high level test, install that I spotted out.

Consider the following example,

I have a maven project like the following

maven-root

 maven-child-1

 maven-child-2

Consider the following scenario, I have done them sequentially at root level

  1. mvn clean install
  2. mvn sonar:sonar -- See the report
  3. Modified child-2 by adding some test cases to increase the code coverage
  4. Run mvn sonar:sonar

My changes for the test cases are not reflecting in the report.

  1. I have deleted the report from sonarqube
  2. mvn sonar:sonar

Still that generates me the old report.

In brief, Do I need to perform mvn clean install and then mvn sonar:sonar ?

If mvn sonar:sonar covers executing the mvn clean install, why the report gives me old numbers?

回答1:

mvn sonar:sonar does not trigger a mvn clean install execution. It triggers a Maven Surefire plugin execution only.

This is why you need to perform a mvn clean install before each analysis - otherwise your compiled classes won't be up-to-date and therefore the Surefire execution won't include recent modifications.



回答2:

Run the below cammand

mvn clean install sonar:sonar