`

Jenkins(Hudson)+Findbugs/PMD/Checkstyle的配置要点

 
阅读更多

    官方论坛文档写得很烂,让人以为安装了插件后就万事大吉,实际上并不是这样,它只是个静态分析结果的分析插件,而分析结果的生成,却是它完成不了的,你仍然需要在你的ant或maven任务中,写一个任务去执行,生成这个分析结果,通常是一个xml文件,例如:

 

 

	
	<!-- =================================================================== -->
	<!-- CheckStyle build -->
	<!-- =================================================================== -->

        <target name="checkstyle" description="Reports the violations of service source against coding style format">
		<taskdef resource="checkstyletask.properties" classpathref="dist.lib" />
		<checkstyle failOnViolation="false" config="${lib.path}/check/CheckStyle_hangame.xml">
			<classpath refid="dist.lib" />
			<fileset dir="${project.src.dir}">
				<include name="**/*.java" />
			</fileset>
			<formatter type="xml" toFile="${commonbuild.dir}/checkstyle_errors.xml" />
		</checkstyle>
	</target>

	<!-- =================================================================== -->
	<!-- Findbugs build -->
	<!-- =================================================================== -->
	<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="dist.lib" />
	<property name="findbugs.home" value="/home/irteam/app/findbugs-1.3.9" />
	<target name="findbugs" depends="build-jar">
		<findbugs home="${findbugs.home}" output="xml" outputFile="${commonbuild.dir}/findbugs_errors.xml">
			<sourcePath path="${project.src.dir}" />
			<class location="${project.dist.dir}/${project.name}.jar" />
		</findbugs>
	</target>

	<!-- =================================================================== -->
	<!-- PMD build -->
	<!-- =================================================================== -->
	<target name="pmd">
		<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="dist.lib" />
		<pmd rulesetfiles="${lib.path}/check/pmd_hangame.xml" encoding="iso-8859-1">
			<formatter type="xml" toFile="${commonbuild.dir}/pmd.xml" />
			<fileset dir="${project.src.dir}">
				<include name="**/*.java" />
			</fileset>
		</pmd>
	</target>

 并在findbugs插件中指定你生成的文件名才可以,这里生成的叫findbugs_errors.xml,那么你在插件指定的名字也要叫findbugs_errors.xml,其他两个插件类似,不再赘述.

 

分享到:
评论
1 楼 comet0515 2016-07-14  
dist.lib是什么文件?提示找不到

相关推荐

    改之理java源码复制-kin:Jenkins/Hudson作业配置生成器

    使用报告器:DRY、PMD、FindBugs、CheckStyle 和配置的阈值 在构建失败时发送邮件至developers@acme.com 使用 cobertura 出版商 收集target/*.jar工件 理想情况下,所有其他 Maven 项目都应该在更改时重用此配置: ...

    ci-game-plugin:Jenkins ci-game插件

    ##用法##配置####版本要求请注意,插件版本1.13+要求Hudson 1.320可以工作,并且需要以下插件版本: Checkstyle 3.1 Findbugs 4.0 PMD 3.1 任务4.0 警告3.0 违规0.5.4 分析核心1.0 哈科科1.0.18 并非在开始时为...

    代码质量管理平台SonarQube

    从静态分析到动态分析(单元测试)、从系统分析到人工评审、从历史分析到现在的版本分析、从Web客户端到Eclipse插件、从本地分析到远程分析、从集成其他代码分析插件(FindBugs、Checkstyle、PMD等)到作为插件被CI...

    持续集成管理平台的组成.pptx

    常用的代码质量管理工具有 Sonar、Checkstyle、PMD、FindBugs 等。Sonar 是一个代码质量管理平台,提供了代码质量检查、安全检查、性能检查等功能。Checkstyle 是一个静态代码分析工具,提供了代码风格检查、代码...

    12.持续集成CI(ContinuousIntegration)1

    在Jenkins或Hudson等持续集成工具中,可以安装FindBug插件,通过Maven命令如`mvn findbugs:help`、`mvn findbugs:check`和`mvn findbugs:findbugs`来运行检查并获取报告。 总的来说,持续集成是现代软件开发过程中...

    Eclipse测试

    4. **Eclipse插件:PMD和Checkstyle**:为了确保代码质量,Eclipse用户可以使用PMD和Checkstyle插件进行静态代码分析。这两个工具可以检测潜在的编程错误、坏味道和不符合编码规范的地方,帮助提升代码质量。 5. **...

    EclipseTest:Eclipse测试

    10. **Code Analysis和Code Style检查**:通过Checkstyle、FindBugs和PMD等插件,Eclipse能自动检查代码风格和潜在问题,提前发现可能引发错误的代码。 在EclipseTest-master这个压缩包中,可能包含了Eclipse测试...

Global site tag (gtag.js) - Google Analytics