Findbugs exclude files

(Ankit ) #1

I am having trouble excluding certain types of files when using findbugs.

// FindBugs
apply plugin: 'findbugs'
findbugs {
    toolVersion = "3.0.1"
    sourceSets = [sourceSets.main]
    ignoreFailures = true
    reportsDir = file("$project.buildDir/findbugsReports")
    effort = "max"
    reportLevel = "high"
    excludeFilter = file("$rootDir/gradle/config/findbugs/exclude.xml")
    ignoreFailures = true


        <Source name="**/*.scala" />
        <Source name="**/*.xml" />
        <Source name="**/*.zip" />
        <Source name="**/*.list" />
        <Source name="**/*.ftl" />
        <Source name="**/*.ts" />
        <Source name="**/*.proto"/>
        <Source name="**/*.txt"/>
    <!-- (i.e., classes ending in 'Test' or 'Tests', and inner classes of same) -->
    <!-- excluding source should suffice but it doesn't work-->

        <Class name="~.*\.*Tests?(\$.*)?" />
        <Class name="~.*\.list" />
        <Class name="~.*\.Manifest\$.*"/>
        <Class name="~.*\.ftl\$.*"/>
        <Class name="~.*\.ts\$.*"/>
        <Class name="~.*\.*list.*"/>
        <Class name="~.*\.zip\$.*"/>
        <Class name="~.*\.xml\$.*"/>
        <Class name="~.*\.properties"/>

I get errors: Wrong magic bytes of 2320416c for zip file

What is the correct way to exclude files ending with blah?

(Benjamin Muschko) #2

This is likely happening due to the fact that you have other file types under build/classes/main than Java class files. Currently this message is bubbling up to the console as described in this post. You can work around the issue with the following code:

tasks.withType(FindBugs) {
    // file types you want to exclude e.g.
    exclude '**/*.conf'
    exclude '**/*.properties'
    exclude '**/*.properties'