sonar installation and configuration
- Download sonar
http://downloads.sonarsource.com/sonarqube/
- Decompression Sonar Package for installation
- Set SONAR environment variable
Sonar_home: "D:\sonarqube"
PATH: "%sonar_home%\bin\windows-x86-64"
- Start-up sonar
Cmd:startsonar
- Log into Sonar
Http://localhost:9000/
- Check issue in Sonar Web page
Eclipse Plug-in Installation
- Installation from "Eclipse Marketplace"
- Configuration Sonar Server
Sonar with Maven
- Pom.xml Fragment for Sonar
<properties> <project.build .sourceencoding >utf-8 </project.build > <sonar.host . URL >http://localhost:9000 </sonar .host .url > <sonar.exclusions > **/*.class, **/ *.groovy , src/main/java/ Spark/*</sonar.exclusions> </properties>
Note: sonar uses H2 as default database
2. Maven CMD for Sonar
CMD:MVN Sonar:sonar
3. Analyze maven project in Sonar GUI
Http://localhost:9000/
Sonar with Gradle
- Build.gradle Fragment for Sonar
Apply plugin:' Java 'Apply plugin:' Eclipse 'Apply plugin:"Sonar-runner"Group =' Com.shuai.gradle.demo 'Description =' Hello Gradle for demo 'Sourcecompatibility =1.7version=' 1.0 'Jar {manifest {attributes' Implementation-title ':' Gradle Quickstart ',' Implementation-version ':version}}repositories {maven {URL"http://scm0.access.nsn.com/nexus/content/groups/unify/"}}dependencies {Compile group:' Commons-io ', Name:' Commons-io ',version:' 2.+ 'Compile group:' Org.apache.commons ', Name:' Commons-lang3 ',version:' 3.+ 'Compile group:' Commons-collections ', Name:' Commons-collections ',version:' 3.+ 'Testcompile Group:' JUnit ', Name:' JUnit ',version:' 4.+ '}sonarrunner {sonarproperties {property"Sonar.host.url","http://localhost:9000"Property"Sonar.jdbc.url","Jdbc:h2:tcp://localhost:9092/sonar"Property"Sonar.jdbc.driverClassName","Org.h2.Driver"Property"Sonar.jdbc.username","Sonar"Property"Sonar.jdbc.password","Sonar"}}test {systemproperties' property ':' value '}uploadarchives {repositories {flatdir {dirs' Repos '} }}
- Gradle CMD for Sonar
Cmd:
Gradle Build Cleaneclipse-x Test
Gradle Sonarrunner
- Log into Sonar
Http://localhost:9000/
Analyze codes via sonar in eclipse
- Associate with SonarQube
- Analyze codes via sonar
Maven + sonar, Gradle + sonar