gpt4 book ai didi

java - ANT checkstyle 任务 : Can't find/access AST Node

转载 作者:搜寻专家 更新时间:2023-10-31 20:29:01 24 4
gpt4 key购买 nike

在尝试设置 Hudson 以使用 ANT 构建我们的项目时,我偶然发现了一个类似于 this one 的问题.但是,那里建议的解决方案对我不起作用。

我通过设置它自己的类路径的 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>

它给了我以下输出:

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
...

我的 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>

并删除了 $ANT_HOME/lib 中的 antlr.jar,可能会破坏内容。

不过仍在寻找可能的答案。

有关更多信息,请参阅此 GitHub 线程:https://github.com/kframework/k/issues/659

关于java - ANT checkstyle 任务 : Can't find/access AST Node,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17466493/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com