Maven + sonar, Gradle + sonar

Source: Internet
Author: User

sonar installation and configuration
    1. Download sonar
      http://downloads.sonarsource.com/sonarqube/
    2. Decompression Sonar Package for installation
    3. Set SONAR environment variable
      Sonar_home: "D:\sonarqube"
      PATH: "%sonar_home%\bin\windows-x86-64"
    4. Start-up sonar
      Cmd:startsonar
    5. Log into Sonar
      Http://localhost:9000/
    6. Check issue in Sonar Web page
Eclipse Plug-in Installation
    1. Installation from "Eclipse Marketplace"
    2. Configuration Sonar Server
Sonar with Maven
    1. 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
    1. 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 '}  }}
    1. Gradle CMD for Sonar
      Cmd:
      Gradle Build Cleaneclipse-x Test
      Gradle Sonarrunner
    2. Log into Sonar
      Http://localhost:9000/
Analyze codes via sonar in eclipse
    1. Associate with SonarQube
    2. Analyze codes via sonar

Maven + sonar, Gradle + sonar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.