Reputation: 644
How can I configure checkstyle (in Ant nt Maven) task? I tried little bit but I didn't get the reports properly. Here's my ant script.
<target name="checkStyle">
<taskdef resource="checkstyletask.properties">
<classpath refid="compile.class.pathtest"/>
</taskdef>
<checkstyle config="${source.code.dir}/config/sun_checks.xml">
<fileset dir="${base.working.dir}/JavaFolder">
<include name="**/*.java"/>
</fileset>
<formatter type="plain"/>
<formatter type="xml" toFile="checkstyle-result.xml"/>
</checkstyle>
</target>
<path id="compile.class.pathtest">
<pathelement location="${checkstyle.dir}/checkstyle-5.5-all.jar"/>
<pathelement location="${checkstyle.dir}/checkstyle-5.5.jar"/>
<pathelement location="${checkstyle.dir}/pmd-3.9.jar"/>
<pathelement location="${checkstyle.dir}/asm-3.0.jar"/>
<pathelement location="${checkstyle.dir}/backport-util-concurrent-2.1.jar"/>
<pathelement location="${checkstyle.dir}/jaxen-1.1-beta-10.jar"/>
<pathelement location="${checkstyle.dir}/saxpath-1.0-FCS.jar"/>
</path>
What's that sun_checks.xml file? I have downloaded and kept in the above mentioned folder. While running the build, it shows some warnings and errors. Later, it shows like this.
BUILD FAILED
C:\server\build.xml:9725: The following error occurred while executing this line: C:\server\build.xml:3838: Got 56 errors and 27599 warnings.
Can you please guide me how to solve this?
Thanks
Upvotes: 4
Views: 4909
Reputation: 18704
The sun_checks.xml
file contains the checkstyle configurations, i.e. all rules that should be applied when evaluating your source code.
Your build failes, because checkstyle found error.
You can set the failOnViolation property to false to avoid this. This property defaults to true, when it is not set.
<checkstyle config="${source.code.dir}/config/sun_checks.xml" failOnViolation="false">
<fileset dir="${base.working.dir}/JavaFolder">
<include name="**/*.java"/>
</fileset>
<formatter type="plain"/>
<formatter type="xml" toFile="checkstyle-result.xml"/>
</checkstyle>
Upvotes: 6