FindBugs refuses to find bcel jar on classpath - java

For the life of me, I am trying to get FindBugs (2.0.1) to run as part of my command-line Ant build. I downloaded the FindBugs JAR and extracted it to /home/myuser/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1:
As you can see in the screenshot, under /home/myuser/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1/lib there is a JAR called bcel-1.0.jar, and if you open it, you can see that I have drilled down to a class called org.apache.bcel.classfile.ClassFormatException. Hold that thought.
I then copied /home/myuser/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1/lib/findbugs-ant.jar to ${env.ANT_HOME}/lib to make it accessible to the version of Ant that is ran from the command-line (instead of the Ant instance that comes built-into Eclipse).
My project directory structure is as follows:
/home/myuser/sandbox/workbench/eclipse/workspace/myapp/
src/
main/
java/
test/
java/
build/
build.xml
build.properties
gen/
bin/
main/ --> where all main Java class files compiled to
test/ --> where all test Java class files compiled to
audits/
qual/
staging/
Inside build.xml:
<project name="myapp-build" basedir=".." default="package"
xmlns:fb="antlib:edu.umd.cs.findbugs">
<path id="findbugs.source.path">
<fileset dir="src/main/java">
<include name="**.*java"/>
</fileset>
<fileset dir="src/main/test">
<include name="**.*java"/>
</fileset>
</path>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
uri="antlib:edu.umd.cs.findbugs"/>
<!-- Other Ant target omitted for brevity. -->
<target name="run-findbugs">
<!-- Create a temp JAR that FindBugs can use for analysis. -->
<property name="fb.tmp.jar" value="gen/staging/${ant.project.name}-findbugs-temp.jar"/>
<echo message="Creating ${fb.tmp.jar} for FindBugs."/>
<jar destfile="gen/staging/${ant.project.name}-findbugs-temp.jar">
<fileset dir="gen/bin/main" includes="**/*.class"/>
<fileset dir="gen/bin/test" includes="**/*.class"/>
</jar>
<echo message="Conducting code quality tests with FindBugs."/>
<fb:findbugs home="/home/myuser/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1"
output="html" outputFile="gen/audits/qual/findbugs.html" stylesheet="fancy-hist.xsl" failOnError="true">
<sourcePath refid="findbugs.source.path"/>
<class location="${fb.tmp.jar}"/>
</fb:findbugs>
</target>
<target name="echoMsg" depends="run-findbugs">
<echo message="The build is still alive!!!"/>
</target>
</project>
But when I run ant -buildfile build.xml echoMsg from the command-line, I get an error in FindBugs:
run-findbugs:
[echo] Creating gen/staging/myapp-build-findbugs-temp.jar for FindBugs.
[jar] Building jar: /home/myuser/sandbox/workbench/eclipse/workspace/myapp/gen/staging/myapp-build-findbugs-temp.jar
[echo] Conducting code quality tests with FindBugs.
[fb:findbugs] Executing findbugs from ant task
[fb:findbugs] Running FindBugs...
[fb:findbugs] Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/bcel/classfile/ClassFormatException
[fb:findbugs] Caused by: java.lang.ClassNotFoundException: org.apache.bcel.classfile.ClassFormatException
[fb:findbugs] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[fb:findbugs] at java.security.AccessController.doPrivileged(Native Method)
[fb:findbugs] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[fb:findbugs] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[fb:findbugs] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[fb:findbugs] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[fb:findbugs] Could not find the main class: edu.umd.cs.findbugs.FindBugs2. Program will exit.
[fb:findbugs] Java Result: 1
[fb:findbugs] Output saved to gen/audits/qual/findbugs.html
echoMsg:
[echo] The build is still alive!!!
Here's what has me amazed:
Even with failOnError="true", FindBugs is not halting the build even when this runtime exception is encountered
The last piece of output "Output saved to gen/audits/qual/findbugs.html" is a lie! There is nothing in gen/audits/qual!
The bcel-1.0.jar is absolutely under FindBugs home, just like every other JAR in the lib/ directory.
Please note: the findbugs-ant.jar is definitely copied to ANT_HOME/lib; otherwise I would be getting a failed build complaining that it couldn't find the Ant tasks. As a sanity check, I went ahead and did this (I deleted the findbugs-ant.jar from ANT_HOME/lib and got a failed build). This build doesn't fail (it succeeds!). It just doesn't run findbugs.
Can anyone spot what is going on here? Thanks in advance!

You can debug where BCEL is being loaded from using the -verbose:class argument to the jvm.
To pass this argument to the jvm running findbugs, use the jvmargs flag on the find bugs plugin
jvmargs
Optional attribute. It specifies any arguments that should be
passed to the Java virtual machine used to run FindBugs. You may need
to use this attribute to specify flags to increase the amount of
memory the JVM may use if you are analyzing a very large program.
How did you populate the find bugs lib jar? When I download findbugs.zip, I get a lib directory which looks very different than what you show. In particular, mine contains a bcel with a version of 5.3, not 1.0 as you show.

Funny thing because I am using the same version of Findbugs and the jar file is named bcel.jar not bcel-1.0.jar. I am also running Findbugs from an Ant script. As crazy as it might sound, try to download the Findbugs once again, unpack it in the place of your current one and run your script once again.

My guess is that you actually have BCEL in the classpath twice. And the file is being loaded from the jar outside the FindBugs library. Then, when FindBugs tries to load the jar, it finds the BCEL in the FindBugs library and cannot load it, because it's already loaded.
The solution would be to find where else BCEL exists in the classpath and remove it.

You might have to define a AuxClasspath to include the classpath that your <javac> task used when compiling your class files.
You don't show how the compile took place, so I am assuming your created a compile.classapath classpath reference:
<javac destdir="gen/bin/main"
srcdir="src/main/java"
classpathref="compile.classpath"/>
<fb:findbugs home="/home/myuser/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1"
output="html" outputFile="gen/audits/qual/findbugs.html" stylesheet="fancy-hist.xsl" failOnError="true">
<auxClasspath refid="compile.classpath"/>
<sourcePath refid="findbugs.source.path"/>
<class location="${fb.tmp.jar}"/>
</fb:findbugs>

I don't see from your Ant script that bcel is landing on any classpath that the findbugs task would be able to load it from. You might want to try making your taskdef explicitly include everything findbugs needs.
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
uri="antlib:edu.umd.cs.findbugs">
<classpath>
<fileset dir="/home/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>

most classpath problems you can debug with tattle. it will report you all jars in your project. all duplicated classes etc. saved me a lot of time.
there is also ant task ready: http://docs.jboss.org/tattletale/userguide/1.2/en-US/html/ant.html

Related

Ant jar task fails after wsimport task

An Ant build executes wsimport prior to creating a jar which includes the generated classes. After upgrading various libraries in the project, to include jaxws, the task which creates the jar fails. The reported error is "Cause: the class org.apache.tools.ant.taskdefs.Jar was not found"
I'm upgrading an old project to use newer versions of various libraries. I've been gradually upgrading the libraries in the project. I perform an Ant build each time to isolate any compile time errors. Thus far the upgrades haven't had a major impact, though the libraries I've replaced are things like logging, e-mail, and etc.
Now I've reached the jaxws libraries. We're coming from version 2.1 and going to 2.2.7. After a few cycles of upgrading the libraries and updating the build file with newer versions, the deployed WAR seems to function correctly as the WSDL is responding.
As part of the build process the service is deployed. Subsequently an Ant task performs wsimport to generate Java classes corresponding to the WSDL. The generated classes are then used to create a jar.
It is here that the process now breaks with an exception from Ant. The first visible exception is "java.lang.ClassNotFoundException: org.apache.tools.ant.util.DateUtils". Running the process again in verbose mode generates "Problem: failed to create task or type jar" as an earlier exception in the trace.
I've fiddled with things like setting ANT_HOME per a post involving jaxb. I've also tried different JDKs - open vs Oracle. Changing various classpath entries in the build file hasn't had a positive effect.
What I have discovered is that I can execute each task independently in the proper sequence. The jar task normally has a depends statement involving the wsimport task. In prior use this worked fine. Now it seems as though the hand-off between the tasks is causing something to break.
I did try integrating the wsimport execution into the jar task. No change. I can't seem to narrow down whether the issue is with the wsimport task, the jar task, or some underlying environment configuration. It's especially strange as various other tasks in the build prior to this point work just fine.
The environment is RHEL 7, open JDK 1.7, ant 1.9.4. I also have an Oracle JDK 1.8 available.
build.xml:
<path id="jaxws.classpath">
<pathelement location="${java.home}/../lib/tools.jar"/>
<fileset dir="${jar.dir}">
<include name="jaxws-tools.jar"/>
</fileset>
</path>
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
<classpath refid="jaxws.classpath"/>
</taskdef>
<path id="processing.service.classpath">
<pathelement location="${java.home}/../lib/tools.jar"/>
<fileset dir="${jar.dir}">
<include name="activemq-core-5.4.3.jar"/>
<include name="jaxb-impl.jar"/>
<include name="jaxb-xjc.jar"/>
<include name="jaxrpc.jar"/>
<include name="jaxws-rt.jar"/>
<include name="jaxws-tools.jar"/>
<include name="jms.jar"/>
<include name="jsr181-api.jar"/>
<include name="policy.jar"/>
<include name="slf4j-api-1.7.26.jar"/>
</fileset>
</path>
<target name="generate-processing-client" depends="setup">
<waitfor maxwait="60" maxwaitunit="second">
<http url="${serviceurl}?wsdl"/>
</waitfor>
<wsimport debug="true" verbose="true" keep="true" package="x.x.x.service.processing.client" destdir="${build.classes.dir}" wsdl="${serviceurl}?wsdl">
</wsimport>
</target>
<target name="jar-processing-client" depends="generate-processing-client" unless="skip.service.clients">
<jar basedir="${build.classes.dir}" destfile="${jar.dir}/agard-processing-client.jar" includes="x/x/x/service/processing/client/**"/>
</target>
Stacktrace:
jar-processing-client:
Caught an exception while logging the end of the build. Exception was:
java.lang.NoClassDefFoundError: org/apache/tools/ant/util/DateUtils
at org.apache.tools.ant.DefaultLogger.formatTime(DefaultLogger.java:330)
at org.apache.tools.ant.DefaultLogger.buildFinished(DefaultLogger.java:177)
at org.apache.tools.ant.Project.fireBuildFinished(Project.java:2087)
at org.apache.tools.ant.Main.runBuild(Main.java:872)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.util.DateUtils
at java.net.URLClassLoader$1.run(URLClassLoader.java:360)
at java.net.URLClassLoader$1.run(URLClassLoader.java:349)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:348)
at java.lang.ClassLoader.loadClass(ClassLoader.java:430)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:323)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 7 more
There has been an error prior to that:
/home/x/git/x/etc/ant/services/processing.xml:132: Problem: failed to create task or type jar
Cause: the class org.apache.tools.ant.taskdefs.Jar was not found.
Action: Check that the component has been correctly declared
and that the implementing JAR is in one of:
-/usr/share/ant/lib
-/home/x/.ant/lib
-a directory added on the command line with the -lib argument
Do not panic, this is a common problem.
It may just be a typographical error in the build file or the task/type declaration.
The commonest cause is a missing JAR.
This is not a bug; it is a configuration problem
at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:499)
at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:431)
at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
at org.apache.tools.ant.Task.perform(Task.java:347)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
I've also encountered errors relating to the manifest when I build the entire project. The jar task doesn't define a manifest. Adding manifest entries to the jar task seemed to remove that as an issue. When I execute only the jar task I receive the jar taskdef error above.
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.util.DateUtils
at java.net.URLClassLoader$1.run(URLClassLoader.java:360)
at java.net.URLClassLoader$1.run(URLClassLoader.java:349)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:348)
at java.lang.ClassLoader.loadClass(ClassLoader.java:430)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:323)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 7 more
There has been an error prior to that:
/home/x/git/alerting/build.xml:114: The following error occurred while executing this line:
/home/x/git/alerting/build.xml:63: The following error occurred while executing this line:
/home/x/git/alerting/etc/ant/services/processing.xml:132: Could not find default manifest: /org/apache/tools/ant/defaultManifest.mf
Update
I reverted several of the jaxws and jaxb libraries. This returned the build to a working state. I've subsequently added the newer versions of the libraries, each time running the build process. I identified the need to include items like jaxb-core-2.2.7, which oddly aren't available in the jaxws-ri-2.2.7 distribution. There are still issues with the build process as I proceed with upgrading the libraries. The current stack I'm receiving is as follows:
Caused by: java.lang.IllegalAccessError: tried to access field com.sun.xml.bind.marshaller.SAX2DOMEx.nodeStack from class com.sun.tools.ws.wsdl.parser.DOMBuilder
at com.sun.tools.ws.wsdl.parser.DOMBuilder.comment(DOMBuilder.java:136)
It seems very strange that these errors are occurring during what should be a rather simple jar task.
Update
I've been placing the new libraries in the same folder as the old ones. I thought this may cause an issue with the classpath. I decided to isolate the new libraries from the old by placing them in a separate directory. I copied in the other libraries I haven't yet updated. The issue with Ant still persists. I've isolated it to the wsimport task. I'm wondering if it isn't something to do with the classpath set by the taskdef.
Update
I've been digging through the wsimport Ant task sources. The closest thing I've seen thus far in the call hierarchy resides in WsTask2.java. They're changing the classloader. In tracking this down, it appears that the classpath should be that of the Ant tool. There are cases of reading the java.class.path and few which alter it.
It's still unclear why I'm experiencing this issue in my environment with these versions of software. I looked at the history of this project on github and didn't see any obvious sign of a bug related to this issue being fixed.
ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try {
ok = runInVm(getCommandline().getJavaCommand().getArguments(), logstr);
} finally {
Thread.currentThread().setContextClassLoader(old);
}
Update
I've confirmed the issue is not specific to my environment. I moved the source code and libraries to another server which is installed with RHEL 6. The build still fails with the same error.
I went back to my development machine and attempted to replace the JAXWS libraries with a higher version. I tried 2.2.8, 2.2.10, and 2.3.0. Of course with 2.3.0 I had to change to a 1.8 JDK. The issue persists.

Ant to Gradle: JUnit (4.11) Test conversion

I'm not very familiar with JUnit, but I'm attempting to translate an ant target that makes use of junit into the gradle equivalent. It's not going so hot, since I'm getting some failures on the gradle side -- I'm under the impression that it's due to inputs not being found somehow/somewhere, but I can't confirm, since it's not readily present in the ant target.
Here's the ant script:
<target name="testing">
<junit printsummary="yes" showoutput="yes">
<classpath refid="classpath"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="someOutputLocation">
<fileset dir="${base}/testCode">
<include name="**/included.java"/>
<exclude name="**/excluded.java"/>
</fileset>
</batchtest>
</junit>
</target>
And here's (one of the variations) of my gradle attempt:
task testing(type:Test){
useJUnit()
testClassesDir = file("testCodeCompiled")
include '**/included.class'
exclude '**/excluded.class'
classpath = classpath
}
The two errors I get:
junit.framework.AssertionFailedError
java.lang.NullPointerException
The AssertionFailedError is supposedly caused by multiple JUnit dependencies, which I don't have. I import a local version of only junit-4.11.
I really don't know why it's not working, though I suspect it's due to some of gradle's complexities. I've seen people mention an ant-junit library, which I may try to use to at least replicate the results from within gradle.
EDIT: A thought occurs: I found JUnit within some of gradle's src files. By calling useJUnit(), I may be using that instead? If so, there could be a double dependency after all? Nope. Got rid of useJUnit() and the local jar separately. The former behaved as it did before whereas the latter exploded.
MORE INFO: The cause may likely be that the compiledTestCode is missing several of the directories/data that testCode contains. I probably have to copy over the relevant files. Alternatively, is there a way to make gradle's JUnit use .java files instead of .class?
For those of you wondering, the code is fine. I'm just dumb.

Exclude a file or package from the Clover report using ant build script

I am using a short ant script to generate my Clover coverage report. I want to exclude certain source files from the report. The code is already fully instrumented, it's not feasible for me to exclude the file during instrumentation.
Excerpt of the ant build xml (trimmed):
<project name="Clover Coverage" default="clover.report" basedir="${basedir}">
<target name="clover.report">
<clover-report initstring="${cloverdb}" >
<current outfile="${reportdir}" title="${title}" >
<format type="html"/>
<sourcepath>
<pathelement path="${srcdir1}"/>
</sourcepath>
</current>
</clover-report>
</target>
</project>
I've tried to exclude this using fileset, but when I do this, Clover gives an error message saying that no coverage info could be found. But if I remove the fileset then it works fine.
My attempted fix that doesn't work:
<current outfile="${reportdir}" title="${title}" >
<format type="html"/>
<fileset dir="${srcdir1}">
<exclude name="**/ExcludeThisClass.java"/>
</fileset>
<sourcepath>
<pathelement path="${srcdir1}"/>
</sourcepath>
</current>
Is the exclusion of files from the Clover report not possible?
Please run your Ant with debug logging (ant -d). The <clover-report> task should print more details then. The most probably you instrumented and/or executed your source code not at once but in several build/test sessions.
And it's probable that Clover rejected some of recording files because it found them out of date.
See these knowledge base articles:
https://confluence.atlassian.com/cloverkb/ignoring-coverage-recording-files-300816998.html
https://confluence.atlassian.com/cloverkb/no-coverage-recordings-found-no-report-will-be-generated-611812757.html

Ant (build.xml) equivalent to Eclipse's Build Path->Export?

I have an Android test project using Espresso that I am attempting to build with Ant. I can build the test application just fine. Install it to the device and everything. The problem is, whenever I try to run the test with
adb shell am instrument -w
com.test.package/com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner
I get this in my command prompt:
INSTRUMENTATION_RESULT: shortMsg=java.lang.ClassNotFoundException
INSTRUMENTATION_RESULT: longMsg=java.lang.ClassNotFoundException: Didn't find class "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner" on path: /system/framework/com.google.android.maps.jar:/system/framework/android.test.runner.jar:/data/app/test.apk:/data/app/myApp.apk
INSTRUMENTATION_CODE: 0
And this in the logcat:
E/AndroidRuntime(27558): java.lang.RuntimeException: Unable to
instantiate instrumentation
ComponentInfo{com.avai.app.test.automate/com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner}:
java.lang.ClassNotFoundException: Didn't find class
"com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
on path:
/system/framework/com.google.android.maps.jar:/system/framework/android.test.runner.jar:/data/app/test.apk:/data/app/myApp.apk
I can run the tests in Eclipse if I check the box next to my Espresso jar under Configure Build Path->Order and Export. I noticed that with this box unchecked I get the exact same error message as above.
What I need to know is how to emulate Eclipse's behavior here with Ant?
Here is a snippet from my build.xml file (mostly generated from Export->Ant build files in Eclipse:
<path id="Android 4.4.2.libraryclasspath">
... (lots of jars) ...
</path>
<path id="AutomationTests.classpath">
... (more jars) ...
</path>
<path id="AutomationTests.classpath">
<pathelement location="bin/classes"/>
<path refid="Android 4.4.2.libraryclasspath"/>
<path refid="Android Private Libraries.libraryclasspath"/>
<path refid="Android Dependencies.libraryclasspath"/>
<pathelement location="../../android-test-kit/bin/espresso-standalone/espresso-1.1-bundled.jar"/>
</path>
<javac encoding="${java.encoding}" source="${java.source}"
target="${java.target}"
debug="true" extdirs="" includeantruntime="false"
destdir="${out.classes.absolute.dir}"
bootclasspathref="project.target.class.path"
classpathref="project.javac.classpath">
...(stuff) ...
</javac>
The error you're seeing is caused by the third-party jar not being packaged inside the APK.
The default behaviour of the android ant build is that only the jars found in application project /libs folder are packaged into the apk.
Copy the espresso-1.1-bundled.jar to the /libs folder of the app project and you'll be fine.
Another thing to consider - you'll be better off generating the build.xml with Android tools as described here: http://developer.android.com/tools/projects/projects-cmdline.html#UpdatingAProject

FindBugs scanning external jars

I am using the following link to create an ant script to run findbugs on a web application:
Chapter 6. Using the FindBugs™ Ant task
I am setting the auxClasspath parameter to my jars folder.
But when i run the task using ant findbugs from the command prompt, it takes a very long time(~45 minutes) and the output xml contains analysis of the jars in the auxClasspath as well as my source code.
I want only my source code to be analyzed.
This is the code in my build.xml:
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
<property name="findbugs.home" value="C:/Software/FindBugs" />
<target name="findbugs" >
<echo message="Finding Bugs From ${basedir}/src/java"/>
<findbugs home="${findbugs.home}"
output="xml:withMessages"
outputFile="${basedir}\findbugs.xml"
stylesheet="fancy-hist.xsl"
timeout="6000000"
jvmargs="-Xmx1200m">
<auxClasspath path="${basedir}/Jars/*.jar" />
<sourcePath path="${basedir}/src/java"/>
<class location="${basedir}/build/myApp-1.0.jar" />
</findbugs>
</target>
I have added findbugs-ant.jar to lib of my ant installation.
The findbugs directory exists.
Other information:
IDE: Netbeans 7.3
OS: Microsoft Windows XP
Ant Version: 1.8.4
Find Bugs Version: 2.0.2
Update
If i leave out this line:
<auxClasspath path="${basedir}/Jars/*.jar" />
I get my desired output(i.e. analysis of only my source code).
But it raises a warning:
[findbugs] The following classes needed for analysis were missing:
[findbugs] javax.servlet.http.HttpServlet
[findbugs] javax.servlet.http.HttpServletRequestWrapper
[list continues]....
Any idea, why find bugs is analyzing jars which it should not analyze(according to the documentation)
I tried to track which Jars are being used in the source code.
In the findbugs xml output, i found a line: ${basedir}\Jars\antlr-2.7.2.jar
The findbugs analysis report showed that all the other jars(except antlr-2.7.2.jar) were missing.
There were no more auxClassPath entries. Solved this by specifying each class path entry in a different line.
If anyone has any better ideas, kindly contribute.
I used the following auxClasspath settings to pull in all my jars in my lib folder and all the jars in directories under my lib folder.
<auxClasspath>
<fileset dir="${lib.dir}">
<include name="*/**"/>
<include name="*.jar"/>
</fileset>
</auxClasspath>
Place it inside the findbugs tag.
Try to remove this line
<class location="${basedir}/build/myApp-1.0.jar" />
Now to try to analyze both jar and source files, that's it takes so long time.
This line is needed and used to find a class if it encounters during analysis of your source.
<auxClasspath path="${basedir}/Jars/*.jar" />
Maybe to can limit it to only really needed jars, not all in the folder.

Categories

Resources