mvn clean install -DskipTests=true mvn sonar:sonar
skipTests=true to not to run unit tests twice: once during the
install goal and again during the
sonar:sonar goal. You can also deactivate the integration tests test execution. Please refer to the Maven documentation.
Make sure you're not using the Eclipse plugin maven embedderMaven Embedder (m2eclipse). Define a new Maven runtime pointing to your local Maven install, use the latest maven eclipse plugin Maven Eclipse plugin, m2e, and uncheck "resolve workspace artifacts" in the maven Maven project launch window.
Note that Advanced Reactor Options (such as "--projects" and "--resume-from") are not supported by SonarQube and should not be used.
When the above configuration is not possible, you can run an analysis in one command, but unit tests will run twice: once in the
install goal and once in the
sonar:sonar one goal. Do not use the
-DskipTests=true parameter, otherwise the unit tests will not be executed at all.
mvn clean install sonar:sonar -Dmaven.test.failure.ignore=true
-Dmaven.test.failure.ignore=true is there to make sure that even if some unit tests fail, the SonarQube analysis will be performed.
Configuring the SonarQubeAnalysisSonarQube Analysis
A pom.xml file sample is available here.