Gradle - how to exclude Findbugs on /src/test/java
Asked Answered
B

2

9

Is there a way to exclude Findbugs execution on classes under /src/test/java. I tried the following but it doesn't seem to work.

classes = classes.filter {
   !it.path.contains("**classes\\test\\org*")
}
Bioecology answered 28/5, 2014 at 20:6 Comment(0)
U
12

Sure. The documentation of the Findbugs extension says:

sourceSets : The source sets to be analyzed as part of the check and build tasks.

And the example just above shows an example doing exactly what you want:

apply plugin: "findbugs"

findbugs {
    sourceSets = [sourceSets.main]
}

i.e. only analyze the main sourceSet, and not the test sourceSet.

Unvoice answered 28/5, 2014 at 20:37 Comment(2)
I tried that but it still executes the findbugsTest. I see the following in the logs. Deprecated dynamic property: "sourceSets" on "task ':findbugsIntegTest'", value: "[source set 'main']". Deprecated dynamic property "sourceSets" created in multiple locations.Bioecology
It is working in findbugs{}, now with tasks.withType(FindBugs) {}Bioecology
O
3

For Gradle 4.5.1

apply plugin: 'findbugs'

findbugs {
    findbugsTest.enabled = false
}

It isn't mentioned anywhere in documentation, at least I, as 1 day gradle user, don't find it, but it works.

Orlantha answered 9/2, 2018 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.