SonarQube Installation and configuration
June 22, 2015 Leave a comment
Code coverage tools comparision
http://java.dzone.com/articles/code-coverage-tools-comparison
What is SonarQube
https://www.linkedin.com/pulse/20140921191030-30431981-what-sonarqube-is-not
Download location : http://www.sonarqube.org/downloads/
SonarQube installation
SonarQube installation overview
http://docs.sonarqube.org/display/SONAR/Installing
Installing SonarQube on Mac
Installing SonarQube ™ (formerly Sonar ™) on Mac OS X Mountain Lion 10.8.4
SonarQube DB creation(MySQL)
https://github.com/SonarSource/sonar-examples/blob/master/scripts/database/mysql/create_database.sql
Start the sonarqube
/[Path]/sonarqube-5.1.1/bin/macosx-universal-64/sonar.sh start
Installing sonarqube runner (analyzer)
http://docs.sonarqube.org/display/SONAR/Installing+an+Analyzer
Running Sonarqube analyzer
http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Runner
Maven Jacoco integration
Creating Code Coverage Reports for Unit and Integration Tests With the JaCoCo Maven Plugin
Pom.xml entries
——————-
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.7.4.201502262128</version> <configuration> <destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile> <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile> <append>true</append> </configuration> <executions> <execution> <id>jacoco-initialize</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>jacoco-site</id> <phase>package</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin>
——-
Nice articles on maven jacoco integration
Creating Code Coverage Reports for Unit and Integration Tests With the JaCoCo Maven Plugin
Sonar Integration into maven settings.xml
———–
</servers> <profiles> <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <!-- Example for MySQL--> <sonar.jdbc.url> jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8 </sonar.jdbc.url> <sonar.jdbc.username>sonar</sonar.jdbc.username> <sonar.jdbc.password>sonar</sonar.jdbc.password> <!-- Optional URL to server. Default value is http://localhost:9000 --> <sonar.host.url> http://localhost:9000 </sonar.host.url> </properties> </profile> </profiles>
————
running sonar through maven
mvn clean package
mvn sonar:sonar