The checkstyle task provides support for the integration of checkstyle code style validation and reporting into the DPML development environment. The task allows the selection of a style format and and postprocessing of XML based report output.
The following example buildfile applies checkstyle checks against the project src path (typically target/build/src). In the case of module projects the source path is prepared taking into account all projects within the same group. Output in generated into the target directory and is subsequently post processed into a checkstyle report directory as an html report.
<target name="checkstyle" depends="prepare"> <property name="checkstyle.dir" location="${project.target.reports.dir}/checkstyle"/> <property name="checkstyle.data" location="${checkstyle.dir}/checkstyle.xml"/> <property name="project.checkstyle.data" location="${project.target.reports.dir}/checkstyle"/> <x:plugin ref="dpml/depot/dpml-depot-checkstyle"> <task class="dpml.tools.checkstyle.CheckstyleTask" name="checkstyle"/> </x:plugin> <mkdir dir="${checkstyle.dir}"/> <checkstyle> <formatter type="xml" toFile="${checkstyle.data}"/> </checkstyle> <xslt style="${dpml.prefs}/dpml/tools/xsls/checkstyle-frames.xsl" in="${checkstyle.data}" out="${checkstyle.dir}/checkstyle_report.html" />
Output from the above project is shown below.
init: checkstyle: [style] Processing D:\demo\target\checkstyle\checkstyle_errors.xml to D:\demo\target\reports\checkstyle\checkstyle_report.html [style] Loading stylesheet D:\dpml\prefs\dpml\tools\xsls\checkstyle-frames.xsl
The following optional properties may be used to override default behaviour.
Property | Default | Description |
---|---|---|
${project.checkstyle.dest} | target/checkstyle | The destination directory for temporary data. |
${project.checkstyle.format} | local:format:dpml/tools/dpml | Local uri of a checkstyle formating rule specification. |
${project.checkstyle.reports} | target/reports/checkstyle | Destination directory for html report content. |
The default formatting rules correspond to the DPML standard code format specification and is required for all contributions to the DPML. Alternative code format specifications include a format approximating the Sun coding guidlines.
Style | URI |
DPML | local:format:dpml/tools/dpml |
SUN | local:format:dpml/tools/sun |