checkstyle {
sourceSets = [ subProject.sourceSets.main ]
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle.xml' )
showViolations = false
ignoreFailures = true
}
// exclude generated java sources - by explicitly setting the base source dir
checkstyleMain.source = 'src/main/java'
findbugs {
sourceSets = [ subProject.sourceSets.main, subProject.sourceSets.test ]
ignoreFailures = true
toolVersion = '3.0.1'
// for now we need to set this to low so that FindBugs will actually report the DM_CONVERT_CASE warning we care about
reportLevel = 'low'
}
// exclude generated java sources - by explicitly setting the base source dir
findbugsMain.source = 'src/main/java'
// because cfg package is a mess mainly from annotation stuff
checkstyleMain.exclude '**/org/hibernate/cfg/**'
checkstyleMain.exclude '**/org/hibernate/cfg/*'
findbugsMain.exclude '**/org/hibernate/cfg/**'
findbugsMain.exclude '**/org/hibernate/cfg/*'
The checkstyleMain task does in fact only process the src/main/java dir. findbugsMain, however, processes every source directory in the main SourceSet.
I think it has to do with the class files that FindBugs sees (changing source doesn’t change the collection of classes that FindBugs sees). Checkstyle must look at the list of source files vs the classes on the classpath.
I think if you set findbugsMain.classes to only include the classes from sources from src/main/java (which isn’t going to be easy if there are overlapping packages), you’ll see what you expect.
RIght, that’s the problem. Even without overlapping packages, it is far easier to say "ignore everything in the $buildDir/generated-src" then it is to say “ignore this package, and that package, and that package…”
So then my only recourse is to explicitly list out each (uniqiue) package I want excluded from generated-src (hoping that there are no overlaps)? Does that sound reasonable to you? Am I crazy for wanting this to be more concise?
I tried to come up with a different way of doing this, but it sounds like you’re stuck with excluding the generated packages. The only other way I could think of doing it is to split the generated source into its own sourceSet and deal with it that way.