ANT checkstyle task: cannot find / access AST Node

While trying to configure Hudson to create our projects using ANT, I came across a problem similar to this one . However, the proposed solution does not work for me.

I call checkstyle, although an ANT task that sets its 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 result:

 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 (native ANT instance with the same antlr.jar manually added to it classpath), command line and hudson (the last two use the usual 1.8.3 ANT distribution, where antlr is present in $ANT_HOME/lib ).

The only way I managed to get it to work so far is inside the IDE (manually deleted path entry is antlr.jar classpath and checkstyle-5.6-all.jar is used for the path to the task class).

The same version of antlr is found both inside ANT and in checkstyle distributions. Actually this does not work inside my IDE if they include any of them in the ANT classpath library path (and do not use checkstyle-5.6-all.jar).

What am I doing wrong?

+4
source share
1 answer

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 removed antlr.jar in $ANT_HOME/lib , possibly breaking the material.

However, searching for a potential answer.

Check out this GitHub thread for more info: https://github.com/kframework/k/issues/659

+2
source

Source: https://habr.com/ru/post/1489659/


All Articles