Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Findbugs ant task submitting several dynamically detected JAR files for analysis

Tags:

ant

findbugs

I'm currently looking to run static analysis over a pre-existing project. As the project is created and supplied by an off-site company, I cannot change the build process radically.

The project is split into a lot of sub-modules, located in various places. For other analyisi tools (JDepend, Google Testability Explorer, etc.), I have dynamically detected all build JAR files into a path element as follows:

<path id="built-libs">
  <fileset dir="${overall-base}">
    <include name="${some-common-base}/**/lib/*.jar" />
  </fileset>
</path>
<property name="built-libs-string" refid="built-libs" />

For some tools, I use the build-libs, for others I use the string (in classpath form; x.jar;y.jar).

The trouble is, FindBugs uses a completely different format to any other;

<class location="x.jar"/>
<class location="y.jar"/>
...

Now, I could list all the JAR files manually, but then run the risk of this list going out of synch with the other tool's lists, or of introducing typos.

Another complication is that I also want to run the reports in Jenkins, in this case the extract directory for individual modules will depend on the job that has previously built the module (pipeline builds, modules extracted from SCM and built in parallel, the reporting occurring at the end of the pipline).

I could make a call out to the OS to run FindBugs, passing in the JARs in a space separated list (as in Invoking FindBugs from Ant: passing a space-separated list of files to java). However, I prefer a, Ant solution to an OS <exec... hack.

Note I know I have a similar problem for the sourcepath element, however, I'm assuming that solving the class element problem also solves the sourcepath one.

like image 401
GKelly Avatar asked Dec 21 '25 07:12

GKelly


1 Answers

Ideally, FindBugs should be taking a resource collection rather than separate class elements. I'm not familiar with FindBugs, so I can't comment on why they have chose to go the class element route instead of a resource collection, however your comment about using exec implies that using a resource collection is a valid design alternative.

I would try rolling your own Ant macro, which invokes FindBugs directly using the java task. This should give you the control you need and avoiding the redundancy that the FindBugs Ant task would introduce.

Another option (which is an ugly hack) is to use the fileset to write a mini ant file with a FindBugs target, which you then invoke using the ant task. shudders

like image 100
Tom Howard Avatar answered Dec 22 '25 22:12

Tom Howard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!