Here is a good article about ant and Findbugs
I just recorded two things I've met.
1. Timeout error, the stack trace as below:
[findbugs] Executing findbugs from ant task
[findbugs] Running FindBugs...
[findbugs] Timeout: killed the sub-process
[findbugs] at org.apache.tools.ant.taskdefs.Java.fork(Java.java:754)
[findbugs] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:171)
[findbugs] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:84)
[findbugs] at edu.umd.cs.findbugs.anttask.AbstractFindBugsTask.execFindbugs(AbstractFindBugsTask.java:360)
[findbugs] at edu.umd.cs.findbugs.anttask.AbstractFindBugsTask.execute(AbstractFindBugsTask.java:216)
[findbugs] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[findbugs] at org.apache.tools.ant.Task.perform(Task.java:364)
[findbugs] at org.apache.tools.ant.Target.execute(Target.java:341)
[findbugs] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[findbugs] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[findbugs] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[findbugs] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[findbugs] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[findbugs] at org.apache.tools.ant.Main.runBuild(Main.java:668)
[findbugs] at org.apache.tools.ant.Main.startAnt(Main.java:187)
[findbugs] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
[findbugs] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
[findbugs] Output saved to findbugs.xml
To solve this problem, just add properity timeout to the findbugs task in your ant build script
here is a example (in milliseconds)
timeout="90000000"
2. Out of Memory error, the stack trace as below:
[findbugs] Executing findbugs from ant task
[findbugs] Running FindBugs...
[findbugs] Out of memory
[findbugs] Total memory: 66M
[findbugs] free memory: 0M
[findbugs] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
[findbugs] at edu.umd.cs.findbugs.asm.FBClassReader.readLabel(FBClassReader.java:53)
[findbugs] at org.objectweb.asm.ClassReader.accept(Unknown Source)
[findbugs] at edu.umd.cs.findbugs.asm.FBClassReader.accept(FBClassReader.java:44)
[findbugs] at org.objectweb.asm.ClassReader.accept(Unknown Source)
[findbugs] at edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:93)
[findbugs] at edu.umd.cs.findbugs.classfile.engine.ClassParserUsingASM.parse(ClassParserUsingASM.java:395)
[findbugs] at edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:65)
[findbugs] at edu.umd.cs.findbugs.classfile.engine.ClassInfoAnalysisEngine.analyze(ClassInfoAnalysisEngine.java:39)
[findbugs] at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getClassAnalysis(AnalysisCache.java:213)
[findbugs] at edu.umd.cs.findbugs.FindBugs2.buildReferencedClassSet(FindBugs2.java:675)
[findbugs] at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:176)
[findbugs] at edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:323)
[findbugs] at edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1049)
[findbugs] Java Result: 1
[findbugs] Output saved to findbugs.xml
To solve this problem, just add parameter "jvmargs" to the findbugs task in your ant build script
here is a example
jvmargs="-Xmx1024m"
The finbugs task description like below
<target name="findbugs"> <findbugs home="${findbugs.home}" output="xml:withMessages" outputFile="findbugs.xml" timeout="90000000" jvmargs="-Xmx1024m" > <auxClasspath path="${lib.path}" /> <sourcePath path="${project.home}/src" /> <class location="${project.home}/classes" /> </findbugs> </target>
沒有留言:
張貼留言