Reputation: 2062
when I build my project I usually call mvn clean install
.
Now I tried to integrate sonarqube analysis. Therefore I created a new Run Configuration in Eclipse where I execute the goal mvn sonar:sonar
with some parameters.
Is there a way to run sonar:sonar
within the mvn clean install
automatially?
Upvotes: 2
Views: 606
Reputation: 1
Try this,
<properties>
<sonar.java.jdkHome>C:\ProgramFiles\Java\jdk1.8.0_202</sonar.java.jdkHome>
</properties>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
</dependency>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.10.0.2594</version> <!-- Use the latest version -->
</plugin>
cmd:
mvn sonar:sonar -Dsonar.projectKey=Project1 -Dsonar.projectName=‘Project1’ -Dsonar.host.url=http://localhost:9000 -Dsonar.token=sqp_3099fc6c1bee72f7633b604dd463000764581a14
Upvotes: 0
Reputation: 1323095
This should be documented in "Analyzing with SonarQube Scanner for Maven".
It will be triggered in the build phase.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.3.0.603</version>
</plugin>
</plugins>
</pluginManagement>
</build>
Then see "Running sonar analysis with mvn sonar:sonar
ignores sonar-project.properties".
To associate it with an existing lifecycle phase seems problematic.
Upvotes: 1