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>
次の出力が得られます。
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 (同じ antlr.jar がクラスパスに手動で追加された独自の ANT インスタンス)、コマンドライン、および hudson 内で生成されます (後者の 2 つは、antlr が存在する 1.8.3 ANT の通常のディストリビューションを使用します$ANT_HOME/lib
)。
これまでのところ、それを機能させることができた唯一の方法は、IDE内にあります(手動で追加されたantlr.jarクラスパスエントリを削除し、タスククラスパスにcheckstyle-5.6-all.jarを使用しました)。
antlr の同じバージョンは、ant と checkstyle の両方のディストリビューションに含まれています。実際、いずれかを ant ライブラリのクラスパスに含める (checkstyle-5.6-all.jar を使用しない) と、IDE 内では機能しません。
私は何を間違っていますか?