生成Checkstyle的报告(带有扩展检查) [英] Generating Checkstyle Reports (with extended checks)
问题描述
我有一些自己的扩展检查。我已经出口他们作为插件并在Eclipse中,他们表现出警告/错误。所以,延长检查工作的罚款。
I have some own extended checks. I have exported them as plug-in and in Eclipse, they are showing warning/error. So the extended checks are working fine.
现在我想产生的违法行为的 HTML格式的。
Now I want to generate a report of the violations in HTML format.
我有的选中此的,而这个作品很好,如果没有扩展检查都包含在的 rule.xml 的文件。但在扩展检查时,Ant构建是给错误。
I have checked this, and this works fine if no extended checks are included in rule.xml file. But in case of extended checks, the ant build is giving the error.
的在错误是:的
BUILD FAILED
D:\Java_Work\JUnit_CheckStyle\buildCheckStyle.xml:12: Unable to create a Checker: cannot initialize module TreeWalker - Unable to instantiate InterfaceModifier
InterfaceModifier 是我的大检查,它在Eclipse工作正常。
InterfaceModifier is my extended check, and it works fine in eclipse.
在build.xml文件,其中提供的 extendedCheck.jar 让我得到所需的结果?
In build.xml, where to provide the extendedCheck.jar so that I get the required result?
推荐答案
我已经找到了以下解决方案,这是工作的罚款。
I have found out the following solution, which is working fine.
- 提取的的Checkstyle-x.x中-all.jar在的
- 拷贝解压目录扩展类
- 复制的的元数据,信息和属性的在同一目录扩展检查的文件。
- 如果任何文件是alreasy present,然后编辑该文件,并从延长检查添加的内容。
- 创建一个新的.jar文件,包括所有的这些。
- 在蚂蚁的的build.xml
<的taskdef>
的,设置此的的.jar为类路径
的
- extract checkstyle-x.x-all.jar
- copy the extended classes in the extracted directory
- copy the metadata,message and properties file of extended check in the same directory.
- if any of the file is alreasy present, then edit the file and add the content from extended checks.
- create a new .jar file including all these.
- in ant build.xml
<taskdef>
, set this .jar asclasspath
一样,做完后,直到第2步,我发现checkstyle_packages.xml已经present,所以我编辑它,并在适当的位置添加了从扩展的一个内容。
Like, after done till 2nd step, I found checkstyle_packages.xml is already present, so I edit it and added the content from extended one in proper position.
previous版本
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE checkstyle-packages PUBLIC
"-//Puppy Crawl//DTD Package Names 1.0//EN"
"http://www.puppycrawl.com/dtds/packages_1_0.dtd">
<checkstyle-packages>
<package name="com.puppycrawl.tools.checkstyle">
<package name="checks">
<package name="annotation"/>
<package name="blocks"/>
<package name="coding"/>
<package name="design"/>
<package name="duplicates"/>
<package name="header"/>
<package name="imports"/>
<package name="indentation"/>
<package name="javadoc"/>
<package name="metrics"/>
<package name="modifier"/>
<package name="naming"/>
<package name="regexp"/>
<package name="sizes"/>
<package name="whitespace"/>
</package>
<package name="filters"/>
</package>
</checkstyle-packages>
更改版本
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE checkstyle-packages PUBLIC
"-//Puppy Crawl//DTD Package Names 1.0//EN"
"http://www.puppycrawl.com/dtds/packages_1_0.dtd">
<checkstyle-packages>
<package name="com.puppycrawl.tools.checkstyle">
<package name="checks">
<package name="annotation"/>
<package name="blocks"/>
<package name="coding"/>
<package name="design"/>
<package name="duplicates"/>
<package name="header"/>
<package name="imports"/>
<package name="indentation"/>
<package name="javadoc"/>
<package name="metrics"/>
<package name="modifier"/>
<package name="naming"/>
<package name="regexp"/>
<package name="sizes"/>
<package name="whitespace"/>
</package>
<package name="filters"/>
</package>
<!-- Added this lines -->
<package name="myCheck">
<package name="checks"/>
</package>
<!-- -->
</checkstyle-packages>
现在构建文件运行成功,并在报告中我越来越违规延长检查过的。
now the build file is running successfully and in the report I'm getting violation of extended checks too.
这篇关于生成Checkstyle的报告(带有扩展检查)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!