Gradle configuration using sonar for code analysis

Source: Internet
Author: User
Tags wrapper
preparatory workThe Gradle version in the project is 3.3, Sonar uses 5.6.6Project for Springboot Project introducing sonar warehouse addresses and dependency packagesMaven {URL "https://plugins.gradle.org/m2/"} classpath ("Org.sonarsource.scanner.gradle:sonarqube-gradle-plugin : 2.3 ") because it is multi-module, it is placed on the outermost build.gradle

Build.gradle

Buildscript {
    repositories {
        maven {URL "https://plugins.gradle.org/m2/"}
    }
    dependencies {
        Classpath ("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.3")
    }
}
SonarqubeAdding Sonarqube in Build.gradle is added to the subprojects because it is used in all projects
subprojects{
    sonarqube{
        properties{Property
            "Sonar.host.url", "Http://localhost:9000/"
            property "Sonar.jdbc.url", "Jdbc:mysql://my.server.com/sonar" Property
            "Sonar.jdbc.driverClassName", " Com.mysql.jdbc.Driver "
            sonar.jdbc.username", "sonar" property
            "Sonar.jdbc.password", "sonar"
        }
    }
 }
Apply PluginApply plugin: ' Org.sonarqube ' the complete Build.gradle
Buildscript {repositories {maven {URL "https://plugins.gradle.org/m2/"}} dependencies {C  Lasspath ("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.3")}} Apply plugin: ' Org.sonarqube ' allprojects  {Apply plugin: ' idea ' group = ' Com.bootcwenao ' version = ' 0.1.0-snapshot '} subprojects {Apply plugin: ' java ' sourcecompatibility = 1.8 Targetcompatibility = 1.8 Sourcesets {main {JAVA.SRCD IR (' Src/main/java ') resources.srcdir (' Src/main/resources ')} Test {Java.srcdir (' s
            Rc/test/java ') resources.srcdir (' Src/test/resources ')}} sonarqube{properties{ "Sonar.host.url", "Http://localhost:9000/" property "Sonar.jdbc.url", "Jdbc:mysql://my.server". Com/sonar "Sonar.jdbc.driverClassName", "Com.mysql.jdbc.Driver" property "Sonar.jdbc.use
        Rname "," sonar "    Property "Sonar.jdbc.password", "Sonar"}} task wrapper (type:wrapper) {gradleversion = ' 3.3 '
    }
}
start SonarStartsonar.bat TestGradle Sonarqube-x Test

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.