While trying to setup Hudson to build our projects with ANT I stumbled upon an issue similar to this one. The suggested solution there does not work for me, however.
I invoke checkstyle though an ANT task that sets up it's own classpath.
<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>
It gives me the following output:
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
...
The same output is generated inside my IDE (own ANT instance with the same antlr.jar manually added to it's classpath), command line and hudson (the latter two use the usual distribution of 1.8.3 ANT, where antlr is present in $ANT_HOME/lib
).
The only way I've managed to get it to work so far is inside IDE (removed manually added antlr.jar classpath entry and used the checkstyle-5.6-all.jar for task classpath).
The same version of antlr is inside both ant and checkstyle distributions. In fact it doesn't work inside my IDE if include either of them in ant library classpath (and don't use checkstyle-5.6-all.jar).
What am I doing wrong?
I gave up trying to solve this. Changed checkstyle.classpath
to
<path id="checkstyle.classpath">
<fileset dir="${env.CHECKSTYLE_HOME}">
<include name="*all.jar"/>
</fileset>
</path>
and deleted the antlr.jar in $ANT_HOME/lib
, possibly breaking stuff.
Still looking for a potential answer though.
Refer to this GitHub thread for more information: https://github.com/kframework/k/issues/659
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With