Sonar Scan was failing for Gradle related multi-projects builds

Hey there.

I think what you really want to do is apply sonar once to the root project of the hierarchy. This would mean your build.gradle looks more like this.

plugins {
    id 'org.sonarqube' version '7.0.1.6134' // Add SonarQube plugin at root level only
}

allprojects {
    group = 'com.sai.qgt'
    version = '1.0.0.0-SNAPSHOT'

    repositories {
        maven {
            url = project.uri("http://8.8.8.8/repository/private")
            allowInsecureProtocol = true

            metadataSources {
                mavenPom()
                artifact()
                ignoreGradleMetadataRedirection()
            }
        }
    }
}

subprojects {
    if (project.name != 'bom') {
        apply plugin: 'java-library'
        apply plugin: 'maven-publish'
        apply plugin: 'jacoco'
        // REMOVED: apply plugin: 'org.sonarqube' - no longer needed in subprojects
    }
}

// Configure SonarQube once at root level
sonar {
    properties {
        property "sonar.host.url", "https://sonar.sai.com"
        property "sonar.projectKey", "sai.qgt.app-gradle"
        property "sonar.projectName", "sai-qgt.app-gradle"
        property "sonar.token", "sai_12345672abcdef50a62"
    }
}

// Explicitly skip the BOM project
project(":bom") {
    sonar {
        skipProject = true
    }
}

The way you have it setup now runs analysis for each module individually with the same project key, and then sends it to SonarQube rewriting the previous analysis.