pre*_*edi 5 java ant classpath checkstyle
在尝试使用ANT设置Hudson来构建我们的项目时,我偶然发现了类似于此问题的问题.但是,建议的解决方案对我不起作用.
我通过ANT任务调用checkstyle来设置它自己的类路径.
<target name="checkstyle" depends="init, staticAnalysisInit">
<mkdir dir="${checkstyle.dir}"/>
<path id="checkstyle.classpath">
<fileset dir="${env.CHECKSTYLE_HOME}">
<include name="*.jar"/>
<exclude name="*all.jar"/>
<!-- already bundled with ANT distributions and causes problems -->
<exclude name="antlr*.jar"/>
</fileset>
</path>
<property name="chkstyl.cp" refid="checkstyle.classpath"/>
<echo>Checkstyle classpath: ${chkstyl.cp}</echo>
<taskdef name="checkstyle"
classpathref="checkstyle.classpath"
classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"/>
<checkstyle config="${env.CHECKSTYLE_HOME}/sun_checks.xml"
failOnViolation="false">
<formatter type="xml" toFile="${checkstyle.dir}/checkstyle.xml"/>
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</checkstyle>
</target>
Run Code Online (Sandbox Code Playgroud)
它给了我以下输出:
init:
staticAnalysisInit:
checkstyle:
[echo] Checkstyle classpath: C:\Program Files (x86)\Checkstyle\checkstyle-5.6\checkstyle-5.6.jar;C:\Program Files (x86)\Checkstyle\checkstyle-5.6\commons-beanutils-core-1.8.3.jar;C:\Program Files (x86)\Checkstyle\checkstyle-5.6\commons-cli-1.2.jar;C:\Program Files (x86)\Checkstyle\checkstyle-5.6\commons-logging-1.1.1.jar;C:\Program Files (x86)\Checkstyle\checkstyle-5.6\google-collections-1.0.jar
[checkstyle] Running Checkstyle 5.6 on 1025 files
[checkstyle] Can't find/access AST Node typecom.puppycrawl.tools.checkstyle.api.DetailAST
[checkstyle] Can't find/access AST Node typecom.puppycrawl.tools.checkstyle.api.DetailAST
[checkstyle] Can't find/access AST Node typecom.puppycrawl.tools.checkstyle.api.DetailAST
...
Run Code Online (Sandbox Code Playgroud)
在我的IDE(自己的ANT实例中,手动添加了相同的antlr.jar的类路径),命令行和hudson(后两个使用1.8.3 ANT的常规分布,其中存在antlr $ANT_HOME/lib)中生成相同的输出.
到目前为止,我设法让它工作的唯一方法是在IDE内部(删除手动添加的antlr.jar类路径条目并使用checkstyle-5.6-all.jar作为任务类路径).
同样版本的antlr在ant和checkstyle发行版中都有.事实上,如果在ant库类路径中包含其中任何一个(并且不使用checkstyle-5.6-all.jar),它在我的IDE中不起作用.
我究竟做错了什么?
我放弃了解决这个问题的尝试。变成checkstyle.classpath
<path id="checkstyle.classpath">
<fileset dir="${env.CHECKSTYLE_HOME}">
<include name="*all.jar"/>
</fileset>
</path>
Run Code Online (Sandbox Code Playgroud)
并删除了 中的antlr.jar $ANT_HOME/lib,可能会破坏内容。
但仍在寻找潜在的答案。
请参阅此 GitHub 线程以获取更多信息:https ://github.com/kframework/k/issues/659
| 归档时间: |
|
| 查看次数: |
1387 次 |
| 最近记录: |