Настройка sonarcube для многомодульного проекта Gradle - PullRequest
0 голосов
/ 03 марта 2020

Я пытаюсь добавить sonarcube для моего многомодульного проекта gradle.

settings.gradle

rootProject.name = 'main-app'
include(':sub-app-1')
include(':sub-app-1')

build.gradle для основного приложения -

    import com.github.spotbugs.SpotBugsTask

plugins {
    id 'org.springframework.boot' version '2.2.2.RELEASE'
    id 'java'
    id 'jacoco'
    id 'idea'
    id "com.github.spotbugs" version "3.0.0"
    id "org.sonarqube" version "2.8"
}

sonarqube {
    properties {
        property "sonar.projectName", "main-app"
        property "sonar.host.url", "xxxxxxx"
        property "sonar.login", "xxxxxxxx"
        property 'sonar.exclusions', "**/test/**"
        property 'sonar.java.binaries', "**/classes"

    }
}


description = 'main-app'
group = 'xxxx'
version = '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8
targetCompatibility = 1.8

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

ext {
    set('springCloudVersion', "Hoxton.SR1")
}

repositories {
    mavenCentral()
}

dependencies {

    compile project(':sub-app-1')
    compile project(':sub-app-1')

    implementation 'org.springframework.boot:spring-boot-starter-amqp'

    implementation 'org.springframework.boot:spring-boot-starter-aop'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-hystrix'

    compileOnly 'org.projectlombok:lombok:1.18.6'
    annotationProcessor 'org.projectlombok:lombok:1.18.6'

    implementation 'io.springfox:springfox-swagger2:2.7.0'
    implementation 'io.springfox:springfox-swagger-ui:2.7.0'

    compile 'org.webjars:bootstrap:3.3.7'

    compile 'net.minidev:json-smart:2.3'
    compile 'com.vaadin.external.google:android-json:0.0.20131108.vaadin1'
    compile 'org.assertj:assertj-core:3.9.1'
    compile group: 'com.google.guava', name: 'guava', version: '27.0.1-jre'

    runtime('com.h2database:h2')
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

configurations {
    all {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
}

jacoco {
    toolVersion = "0.8.2"
}

jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled false
        html.destination file("${buildDir}/jacocoHtml")
    }
}


test.finalizedBy jacocoTestReport
//check.dependsOn jacocoTestCoverageVerification

test {
    useJUnitPlatform()
}

tasks.withType(SpotBugsTask) {
    reports {
        xml.enabled = false
        html.enabled = true
    }
}

spotbugs {
    ignoreFailures = true
    effort = "max"
    reportLevel = "low"
}

build.gradle для sub-app-1 равен

import com.github.spotbugs.SpotBugsTask

plugins {
    id 'java'
    id 'jacoco'
    id 'idea'
    //id "org.sonarqube" version "2.8"
    id "com.github.spotbugs" version "3.0.0"
}

description = 'aub-app-1'
group = 'xxxxxxx'
version = '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8
targetCompatibility = 1.8

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

configurations.all {
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
    exclude group: 'org.springframework.boot', module: 'logback-classic'
}

sonarqube {
    properties {

        property "sonar.projectName", "main-app"
        property "sonar.login", "xxxxxxx"
        property "sonar.host.url", "xxxxxxx"
        property 'sonar.exclusions', "**/test/**"
    }
}

dependencies {
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.8'

    compileOnly 'org.projectlombok:lombok:1.18.6'
    annotationProcessor 'org.projectlombok:lombok:1.18.6'
}

tasks.withType(SpotBugsTask) {
    reports {
        xml.enabled = false
        html.enabled = true
    }
}

spotbugs {
    ignoreFailures = true
    effort = "max"
    reportLevel = "low"
}

Я не могу сгенерировать анализ сонара для этого в рамках одного проекта на моем сервере сонара. Если я помещу

plugins {
    id 'java'
    id 'jacoco'
    id 'idea'
    id "org.sonarqube" version "2.8"
    id "com.github.spotbugs" version "3.0.0"
}

в sub-app-1 build.gradle, у меня будет два отдельных проекта. Есть ли какая-либо конфигурация, которую я пропустил, чтобы добавить этот многомодульный проект Gradle в рамках одного сонарного проекта?

...