Findbugs and Gradle 2.8

Hey, I just updated my gradle from version 2.2 to latest one 2.8. I didn’t have any issue with findbugs on version 2.2.

I’m working on an Android project that contains two modules. In order to use find bugs in both modules I have following configuration on main build.gradle file of root directory.

configure(allprojects) {
    apply plugin: 'findbugs'

    task findbugs(type: FindBugs) {
        ignoreFailures = false
        effort = "max"

        classes = fileTree('build/intermediates/classes/')
        source = fileTree('src/main/java')
        classpath = files()

        excludeFilter = file("exclude.xml")

        reportLevel = "high"
        reports {
            xml.enabled = false
            html.enabled = true
        }
    }
}

When I run ./gradlew findbugs on my local machine everything is fine and build is successful however when I push my PR to Github and Trivis tries to build then I get error:

:findbugs UP-TO-DATE
:passenger-app:findbugs
:passenger-sdk:findbugs FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':passenger-sdk:findbugs'.
> FindBugs rule violations were found. See the report at: file:///home/travis/build/project-name/passenger-android/passenger-sdk/build/reports/findbugs/findbugs.html

I’m really confused why I have no problem on my local machine while Travis shows error! I’m using java 1.8 while Travis is using 1.7. Does problem relates to this? Thanks

The only difference I know of between Gradle 2.2 and Gradle 2.8 WRT FindBugs is a version bump (3.0.0 to 3.0.1).

Have you looked at the failures to see if they’re new bugs found by FindBugs? http://findbugs.sourceforge.net/Changes.html

It may be that FindBugs identifies different errors between JDK 1.7 and 1.8.

Thanks man for the reply.

You are right I got few errors and fixed them. I also added annotation.jar and jsr305.jar int to my libs folder in order to use SuppressFBWarnings. Now there is no blocker by Findbugs, however I’m getting another problem when I try to build the project.

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Ljavax/annotation/CheckForNull;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':passenger-app:dexTaxDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2

Some solutions are based on Multidex activation for android due to pass of 65k method limitation. I guess I can do something before going for multidex approach.

I found something strange by running ./geadlew dependencies

$ ./gradlew -q dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

findbugs - The FindBugs libraries to be used for this project.
\--- com.google.code.findbugs:findbugs:3.0.1 FAILED

findbugsPlugins - The FindBugs plugins to be used for this project.
No dependencies

I don’t understand what it says exactly :confused:
Does it mean Gradle has confused because I added those two jar files and plugin have them already?

Thanks :thumbsup:

Hmm, that’s tricky.

You could try using a suppression filter instead of the annotation: http://findbugs.sourceforge.net/manual/filter.html

You could also just downgrade to 3.0.0 if you don’t care about the new bugs: https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.FindBugsExtension.html

You are awesome Sterling :+1:
I used filer instead of jar file and everything passes.
woooooooo, thanks :smile: