FindBugs的为Android项目在ant构建库 [英] Findbugs for Android project with libraries in ant build

查看:276
本文介绍了FindBugs的为Android项目在ant构建库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FindBugs的是一个伟大的软件和我的团队使用它在我们的Andr​​oid项目时。在Eclipse中的一切是好的,有光泽,但现在我们正在努力实现自动化构建我们与蚂蚁并为每个版本自动生成FindBugs的结果。

Findbugs is a great software and my team uses it while working on our Android project. In Eclipse everything is nice and shiny, however now we're trying to automate our builds with ant and generate Findbugs results automatically for each build.

它似乎并不难。我跟着这个教程:结果
<一href=\"https://wiki.jenkins-ci.org/display/JENKINS/Building+an+Android+app+and+test+project#BuildinganAndroidappandtestproject-FindBugs\" rel=\"nofollow\">https://wiki.jenkins-ci.org/display/JENKINS/Building+an+Android+app+and+test+project#BuildinganAndroidappandtestproject-FindBugs

一个小问题是,我不得不改变 $ {}的android.jar $ {project.target.android.jar}

It's seems not that difficult. I followed this tutorial:
https://wiki.jenkins-ci.org/display/JENKINS/Building+an+Android+app+and+test+project#BuildinganAndroidappandtestproject-FindBugs
One minor issue is that I had to change ${android.jar} to ${project.target.android.jar}.

更糟的一部分需要分析以下类人失踪:警告说来,我们使用表单库项目的类。其中有些是我们自己的,我们希望扫描他们FindBugs的,太。为了使问题更加复杂,这些库中的一个使用另一个LIB(也是我们自己的,需要扫描),所以它看起来是这样的:结果
A计划--uses - &GT;图书馆乙--uses - &GT;库C

The worse part are The following classes needed for analysis were missing: warnings for classes that come form library projects we use. Some of them are our own and we would like to scan them with Findbugs, too. To make matters more complicated, one of these libs uses another lib (also our own and needs scanning), so it looks like this:
Project A --uses--> Library B --uses--> Library C

在这里,我想,既然Android的SDK可以处理所有这些依赖关系,我能以某种方式使用它(当我发出蚂蚁调试项目A库C编译) ,获取库列表中我的项目取决于并将其提供给FindBugs的任务。不幸的是我还没有成功地做到这一点。

Here I thought that since Android SDK can handle all these dependencies (Library C is compiled when I issue ant debug for Project A), I can somehow make use of it, get the list of libs my project depends on and provide it to the findbugs task. Unfortunately I haven't managed to do that.

现在我用手动输入所有库定居,有的到 FindBugs的任务性质,有的成 auxClasspath ,它具有上升空间,我只能分析一些库的项目依赖。我仍然希望我本来试图做的是可能的。任何人都可以告诉我如何提取路径元素

For now I settled with manually entering all libs, some into class property of findbugs task, some into auxClasspath, which has the upside that I can only analyse some of the libraries the project depends on. Still I hope that what I originally tried to do is possible. Can anybody show me how to extract a path-element

推荐答案

我终于找到SDK构建脚本的那部分放在一起,所有的罐子类路径( classes.jar 所有的图书馆,包括从图库C并从项目的库/ 文件夹罐子和所有的库)的-s。

I've finally found that part of SDK build script that puts together a "classpath" of all the jars (classes.jar-s of all the libraries, including Library C from the "diagram" and jars from the libs/ folder of the project and all the libs).

我的最后自定义rules.xml中与FindBugs的目标是这样的:

My final custom-rules.xml with findbugs 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>

编辑:我已经升级目标运行的构建目标indepent,也就是说现在你可以只运行蚂蚁FindBugs的不是蚂蚁FindBugs的调试

这篇关于FindBugs的为Android项目在ant构建库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆