Findbugs project for Android with libraries in ant build

Findbugs is great software, and my team uses it while working on our Android project. Everything is beautiful and brilliant in Eclipse, however now we are trying to automate our builds with ant and automatically generate Findbugs results for each build.

It doesn't seem so complicated. I followed this guide:
https://wiki.jenkins-ci.org/display/JENKINS/Building+an+Android+app+and+test+project#BuildinganAndroidappandtestproject-FindBugs
One of the minor issues is that I had to change ${android.jar} to ${project.target.android.jar} .

The worst part is the warnings. The following classes needed for analysis were missing: for classes that are part of the library projects we use. Some of them are our own, and we would also like to scan them using Findbugs. To complicate the situation, one of these libraries uses another lib (also our own and requires scanning), so it looks like this: Project A --uses--> Library B --uses--> Library C

Here I thought that since the Android SDK can handle all these dependencies (the C library compiled when I issue ant debug for Project A), I can somehow use it, get a list of libraries that my project depends on, and provide this findbugs task. Unfortunately, I did not.

Now I decided to manually enter all the libs, some in the class property of the findbugs task, some in the auxClasspath , which has growth potential, that I can only analyze the libraries on which the project depends. Nevertheless, I hope that what I originally tried to do is possible. Can someone show me how to extract path element

+4
source share
2 answers

Finally, I found that part of the SDK build script that combines the "class path" of all cans ( classes.jar -s of all libraries, including Library C, from the "diagram" and cans from the libs/ project folder and all libraries).

My last custom-rules.xml with the custom-rules.xml target looks like this:

 <?xml version="1.0" encoding="UTF-8"?> <project name="Project_custom" default="findbugs"> <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/> <target name="findbugs"> <gettarget androidJarFileOut="project.target.android.jar" androidAidlFileOut="project.target.framework.aidl" bootClassPathOut="project.target.class.path" targetApiOut="project.target.apilevel" minSdkVersionOut="project.minSdkVersion" /> <dependency libraryFolderPathOut="project.library.folder.path" libraryPackagesOut="project.library.packages" libraryManifestFilePathOut="project.library.manifest.file.path" libraryResFolderPathOut="project.library.res.folder.path" libraryBinAidlFolderPathOut="project.library.bin.aidl.folder.path" libraryNativeFolderPathOut="project.library.native.folder.path" jarLibraryPathOut="project.all.jars.path" targetApi="${project.target.apilevel}" verbose="${verbose}" /> <findbugs home="${findbugs.home}" output="xml" outputFile="findbugs-results.xml"> <auxClasspath> <pathelement location="${project.target.android.jar}" /> <path refid="project.all.jars.path" /> </auxClasspath> <class location="${out.dir}" /> </findbugs> </target> </project> 

Edit: I updated the goal to run a build independent of the goals, i.e. now you can only run ant findbugs not ant debug findbugs .

+3
source

I added a few additional definitions and worked. thank you

 <target name="findbugs"> <mkdir dir="reports" /> <gettarget androidJarFileOut="project.target.android.jar" androidAidlFileOut="project.target.framework.aidl" bootClassPathOut="project.target.class.path" targetApiOut="project.target.apilevel" minSdkVersionOut="project.minSdkVersion" /> <dependency libraryFolderPathOut="project.library.folder.path" libraryPackagesOut="project.library.packages" libraryManifestFilePathOut="project.library.manifest.file.path" libraryResFolderPathOut="project.library.res.folder.path" libraryBinAidlFolderPathOut="project.library.bin.aidl.folder.path" libraryNativeFolderPathOut="project.library.native.folder.path" jarLibraryPathOut="project.all.jars.path" libraryRFilePathOut="project.library.rfile.path" buildToolsFolder="${sdk.dir}/build-tools" renderscriptSupportLibsOut="project.rs.support.libs.path" renderscriptSupportMode="${renderscript.support.mode}" targetApi="${project.target.apilevel}" verbose="${verbose}" /> <findbugs home="${findbugs.home}" output="xml:withMessages" outputFile="reports/findbugs.xml" excludeFilter="findbugs-exclude.xml" maxRank="9"> <!-- auxClasspath path="${project.target.android.jar}" / --> <auxClasspath> <pathelement location="${project.target.android.jar}" /> <path refid="project.all.jars.path" /> </auxClasspath> <sourcePath path="${basedir}/src/" /> <class location="${basedir}/bin/classes/" /> </findbugs> </target> 
+1
source

All Articles