FindBugs plugin issue throwing zipException


(vipss78) #1

I am trying to integrate findBugs plugin with my source project I have the directory structure similar to shown below /SRCROOT --build.gradle --/PROJECT1 ----/build.gradle --/PROJECT2 ----/build.gradle

I have the following thing in root project gradle script. subprojects {

apply plugin: ‘java’

apply plugin: ‘findbugs’

findbugsMain.ignoreFailures = true

findbugsTest.ignoreFailures = true . .

I am getting the following exception

Exception occured while running FindBugs. java.util.zip.ZipException: Wrong magic bytes of 3c706572 for zip file /home/sandbox/srcroot/PROJECT1/build/classes/main/META-INF/persistence.xml of 988 bytes

at edu.umd.cs.findbugs.classfile.impl.ZipFileCodeBase.(ZipFileCodeBase.java:80)

at edu.umd.cs.findbugs.classfile.impl.ZipCodeBaseFactory.countUsingZipFile(ZipCodeBaseFactory.java:90)

Any clue what is wrong here?


(vipss78) #2

not sure… but fingbugsMain.excludes can help me here… ??


(vipss78) #3

I tried with excludes, but doesnt seems to be working… I tried findbugsMain {

excludes = ["**/*.xml"] }

Anything wrong here?


(Luke Daley) #4

Seems a very strange problem.

Any chance you could put together a sample project that I can use to reproduce the problem?


(vipss78) #5

I can upload a sample project since it will take sometime, but I have found another work around… seems like the previous solution should work… but it doesn’t… So I found a workaround which seems to be working…

def fM = findbugsMain.classes
  fM.exclude '**/*.xml'
  findbugsMain.classes = files(fM.files)

but there is still another problem, in which if I start a clean build, it can not find classes, and complains, and throws following exception

Caused by: org.gradle.api.InvalidUserDataException: Classes must be configured to be analyzed by the Findbugs.

at org.gradle.api.plugins.quality.internal.findbugs.FindBugsSpecBuilder.(FindBugsSpecBuilder.java:41)

at org.gradle.api.plugins.quality.FindBugs.run(FindBugs.groovy:102)

at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:196)

at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:102)

Any clue what is wrong here? these are my tasks…

apply plugin: 'findbugs'
task runFindBugsMain(type:findbugsMain.getClass(), dependsOn:[':build']) {
  def fM = findbugsMain.classes
  fM.exclude '**/*.xml'
  fM.exclude '**/*.conf'
  fM.exclude '**/*.properties'
  fM.exclude '**/*.index'
  findbugsMain.classes = files(fM.files)
  findbugsMain.ignoreFailures = true
}
  task runFindBugsTest(type:findbugsTest.getClass(), dependsOn:[':build']) {
  def
fT = findbugsTest.classes
  fT.exclude '**/*.*'
  fT.exclude '**/*.conf'
  fT.exclude '**/*.properties'
  findbugsTest.classes = files(fT.files)
  findbugsTest.ignoreFailures = true
}

Findbugs exclude files
(Peter Niederwieser) #6

Not sure how these additional tasks would help. In any case, ‘findbugsMain.getClass()’ is the wrong type; try ‘“FindBugs”’. 'exclude ‘**/.xml’’ looks good; the pattern '"/.xml"’ you used earlier looks wrong (it’s an Ant-style glob pattern, not a Java regex).