In Sonar, we just download the sonar setup and if need, change the db credentials and run the command on maven project sonar:sonar
, our coding stats and bugs are are analyzed by sonar and make the good html reports. But for this we need to run sonar:sonar
command. Like findbugs, its possible to integrate with maven and create reports and time of maven:install
.In this LINK at 4th step explain. Is also possible with sonar for make the report on maven:install
command?
Asked
Active
Viewed 1,551 times
1

Harmeet Singh Taara
- 6,483
- 20
- 73
- 126
-
Have you been able to do that? Run sonar during maven:install command? Did it have any side effects? Did you have this side effect by any chance? http://stackoverflow.com/questions/29099614/how-to-make-sonar-module-analyze-the-project-only-once-when-sonar-analysis-is-bo – Zhenya Mar 18 '15 at 08:07
1 Answers
2
Like you can see on the SonarQube documentation, we strongly advise you to first run mvn clean install
and then mvn sonar:sonar
separately - otherwise you can have some side effects.
However, if you want to have all this in a single run, this is a Maven-related question. You just have to bind the "sonar" goal to the "install" phase in your POM, with something like:
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...

Zhenya
- 6,020
- 6
- 34
- 42

Fabrice - SonarSource Team
- 26,535
- 3
- 62
- 58
-
we need to setup other instructions like mention in this link http://java.dzone.com/tips/configuring-sonar-maven ? – Harmeet Singh Taara May 27 '14 at 11:54
-
What is explained in this article is just the configuration of the connection to the SonarQube instance. – Fabrice - SonarSource Team May 27 '14 at 12:48
-
Must be he two commands be separated like that, or will `mvn clean install sonar:sonar` work the same? – David Harkness May 28 '14 at 00:51
-
As this is explained in the documentation, it can work but it may have side effects... – Fabrice - SonarSource Team May 28 '14 at 07:18
-
I actually have one of those side effects. http://stackoverflow.com/questions/29099614/how-to-make-sonar-module-analyze-the-project-only-once-when-sonar-analysis-is-bo Do you have any idea of how this could be solved? – Zhenya Mar 18 '15 at 08:07