DOC

Build Android project with Findbugs ant task

By Sharon Bailey,2014-04-05 19:38
11 views 0
Build Android project with Findbugs ant task

http://findbugs.sourceforge.net/

总结如下?

    1. 前提是你已经正确安装了Android SDKAnt。建议配置$ANDROID_HOME$ANT_HOME

    境变量。

    2. 下载并且安装Findbugs;配置环境变量$FINDBUGS_HOME

    3. $FINDBUGS_HOME/lib/findbugs-ant.jar拷贝到$ANT_HOME/lib目录。

    4. 将如下的配置加到Android工程的build.xml中;并且根据实际情况作适当修改:

    <;taskdef name=";findbugs";

    classname=";edu.umd.cs.findbugs.anttask.FindBugsTask";/>; <;property name=";findbugs.home"; value=";${env.FINDBUGS_HOME}"; />; <;target name=";findbugs"; depends=";-compile";>;

     <;mkdir dir=";reports"; />;

     <;findbugs home=";${findbugs.home}"; output=";html"; outputFile=";reports/findbugs.html";>;

     <;!-- so we dont get hundrets of ";The following classes needed for analysis

    were missing"; warnings. -->;

     <;auxClasspath path=";${android.jar}"; />;

     <;auxClasspath>;

     <;fileset dir=";${other-dependency-lib-dir}/libs"; includes=";*.jar"; />;

     <;/auxClasspath>;

     <;class location=";${out.dir}"; />;

     <;sourcePath path=";${source.dir}"; />;

     <;/findbugs>;

    <;/target>;

参考?

    http://findbugs.sourceforge.net/manual/anttask.html

    http://findbugs.sourceforge.net/manual/running.html

    http://tntxia.iteye.com/blog/604714

    http://www.dotblogs.com.tw/yuanchien/archive/2010/11/24/add-findbugs-in-your-build-file.aspx

    http://www.dotblogs.com.tw/yuanchien/archive/2010/11/26/a-sample-android-build-file-for-ant.aspx

    https://wiki.jenkins-ci.org/display/JENKINS/Building+an+Android+app+and+test+project

更新?

    更加方便的配置;不需要拷贝findbugs-ant.jar

     <;property name=";findbugs.home"; value=";${env.FINDBUGS_HOME}"; />;

     <;path id=";findbugs_lib";>;

     <;fileset dir=";${findbugs.home}/lib/";>;

     <;include name=";*.jar";/>;

     <;/fileset>;

     <;/path>;

     <;taskdef name=";findbugs";

    classname=";edu.umd.cs.findbugs.anttask.FindBugsTask"; classpathref=";findbugs_lib"; />;

     <;target name=";findbugs"; depends=";-compile";>;

     <;mkdir dir=";reports"; />;

     <;findbugs home=";${findbugs.home}"; output=";html"; outputFile=";reports/${ant.project.name}_findbugs.html";>;

     <;auxClasspath path=";${android.jar}"; />;

     <;auxClasspath>;

     <;fileset dir=";${other-dependency-lib-dir}/libs"; includes=";*.jar"; />;

     <;/auxClasspath>;

     <;class location=";${out.dir}"; />;

     <;sourcePath path=";${source.dir}"; />;

     <;/findbugs>;

     <;/target>;

Report this document

For any questions or suggestions please email
cust-service@docsford.com