Ignoring generated sources in Sonar

We use the sonarRunner plugin in a multi-project build. In one of the modules, we use wsdl2java to generate java sources from a wsdl file. The wsdl2java conversion puts its sources in “build/generatedSource/java”. We then add the generated code to the compile path with this:

sourceSets.main.java {

srcDir “build/generatedSource/java” }

This works well. However, it also means that sonarRunner picks up these generated sources, which we don’t want. But I can’t figure out how to exclude them from the sources that Sonar is analyzing. Any help would be appreciated.

You can possibly do the following:

sonar.project {
    sourceDirs -= [file("build/generatedSource/java")]
}

are the generated sources in a specific package? you might be able to exclude them using the ‘sonar.exclusions’ property

sonarRunner {
    sonarProperties {
        property “sonar.exclusions”, “/gen/;
    }
}

Thank you for your help. This seems to work fine:

sonarRunner {

sonarProperties {

}

project(":hsa-integration") {

sonarRunner {

sonarProperties {

properties[“sonar.sources”] -= project(":hsa-integration").file(“build/generatedSource/java”)

}

}

}

}