Sonarqube not picking up gradle sourcesets

Hi,

I have a java gradle project with a custom sourceset “src/integration-test” next to the standard “src/test” folder.

build.gradle

plugins {
   id 'org.sonarqube' version '3.3'
   id 'jacoco'
}

sourceSets {
    integrationTest {
        java {
            compileClasspath += main.output + test.output
            runtimeClasspath += main.output + test.output
            srcDir file('src/integration-test/java')
        }
        resources.srcDir file('src/integration-test/resources')
    }
}

jacocoTestReport {
    getExecutionData().setFrom(fileTree(buildDir).include("/jacoco/*.exec"))
    reports {
        xml.required = true
    }
}

sonarqube {
    properties {
        properties["sonar.tests"] += sourceSets.integrationTest.allSource.srcDirs.findAll({ it.exists() })
        properties["sonar.coverage.jacoco.xmlReportPaths"] = "${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml"
    }
}

I’ve tried several things but Sonarqube still only picks up the unit tests in “src/test” and ignoring the ones in my custom sourceset.

What am I doing wrong?

Thanks.

Hi,

Welcome to the community!

I’m no Gradle expert, so I did a little searching & found this SO answer that might help.

 
Ann