maven 插件findbugs源代码的解析
来源:互联网 发布:中药软件哪个好使 编辑:程序博客网 时间:2024/05/22 04:32
为了了解findbugs的插件运行原理,特地翻了findbugs插件的源码,插件的源码视图如下:
FindBugsMojo.java就是我们的findbugs主类
代码如下:
/** * Generates a FindBugs Report when the site plugin is run. * The HTML report is generated for site commands only. * * @goal findbugs * @phase compile * @requiresDependencyResolution compile * @requiresProject * @threadSafe * @author <a href="mailto:gleclaire@codehaus.org">Garvin LeClaire</a> * @version $Id: FindBugsMojo.groovy 16932 2012-06-21 01:13:14Z gleclaire $ */public class FindBugsMojo extends AbstractMavenReport implements groovy.lang.GroovyObject
findbugs的实现是使用groovy实现的,在FindBugsMojo.groovy中找到executeFindbugs的方法,
ant.java(classname: "edu.umd.cs.findbugs.FindBugs2", inputstring: getFindbugsAuxClasspath(), fork: "${fork}", failonerror: "true", clonevm: "false", timeout: "${timeout}", maxmemory: "${maxHeap}m") { def effectiveEncoding = System.getProperty( "file.encoding", "UTF-8" ) if ( sourceEncoding ) { effectiveEncoding = sourceEncoding } log.debug("File Encoding is " + effectiveEncoding) sysproperty(key: "file.encoding" , value: effectiveEncoding) if ( jvmArgs && fork ) { log.debug("Adding JVM Args => ${jvmArgs}") String[] args = jvmArgs.split(FindBugsInfo.BLANK) args.each() {jvmArg -> log.debug("Adding JVM Arg => ${jvmArg}") jvmarg(value: jvmArg) } } if ( debug || trace ) { sysproperty(key: "findbugs.debug" , value: true) } classpath() { pluginArtifacts.each() {pluginArtifact -> log.debug(" Adding to pluginArtifact ->" + pluginArtifact.file.toString()) pathelement(location: pluginArtifact.file) } } findbugsArgs.each { findbugsArg -> log.debug("Findbugs arg is ${findbugsArg}") arg(value: findbugsArg) } }
调用的是edu.umd.cs.findbugs.FindBugs2来实现检查代码的,这个是findbugs.jar中实现的,maven插件是调用findbugs.jar来实现的。
findbugs.jar可以单独使用,findbugs的maven插件中java与groovy是如何相关交互的这些都是新的问题
然后在findbugs的maven pom中的依赖
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs-ant</artifactId>
<version>${findbugsVersion}</version>
</dependency>
version是2.0.1
<findbugsVersion>2.0.1</findbugsVersion>
0 0
- maven 插件findbugs源代码的解析
- Findbugs Maven插件使用
- maven findbugs插件集成
- maven之findbugs插件
- Maven 之 findbugs 插件
- maven 使用findbugs 插件
- Maven 工程添加 findbugs 插件
- Eclipse的FindBugs插件
- findbugs插件的安装
- FindBugs插件的介绍
- maven中findbugs-maven-plugin插件与cobertura-maven-plugin的使用
- maven与findbugs的集成
- FindBugs插件的安装与使用FindBugs插件
- FindBugs-IDEA插件的使用
- Maven 打包源代码插件
- maven 使用 checkstyle findbugs pmd 代码覆盖率检测等插件的使用
- Maven经验分享(七)maven集成findBugs插件
- findbugs 出现的问题解析
- 使用hessian进行服务器与客户端通讯
- asp.net中output参数为null问题
- 黑马程序员—OC基础—autorelease的使用
- android加载大图片
- 电子干涉--粒子还是波?
- maven 插件findbugs源代码的解析
- 初级数据持有化-沙盒
- zipper dp与dfs poj4710
- 继承hibernateDaoSupport之后通过注解方式注入SessionFactory
- 11用户手册
- Apache Mahout的KMeans算法测试
- Mysql 安装与配置
- 一张图看懂hash的核心思想(我只是从我的角度)
- LeetCode-Climbing Stairs