<target name="checkstyle" depends="執行準備操作target" targetdescription="target 描述">
<property name="checkstyle.data.dir" location="${build.dir}/docs/checkstyle"/> <!-- 生成數據存放目錄 -->
<property name="checkstyle.data.file" location="${checkstyle.data.dir}/checkstyle.xml"/> <!-- 生成xml文件地址 -->
<property name="checkstyle.report.file" location="${checkstyle.data.dir}/checkstyle.html"/> <!-- 生成html 文件地址 -->
<property name="checkstyle.xsl.file" location="${checkstyle.dir}/contrib/checkstyle-noframes.xsl"/> <!-- 美化報告 -->
<mkdir dir="${checkstyle.data.dir}"/>
<taskdef resource="checkstyletask.properties" classpath="${checkstyle.jar}"/>
<!-- ${checkstyle.dir}/sun_checks.xml 該文件內容代表檢查規則,下面將具體介紹 -->
<checkstyle config="${checkstyle.dir}/sun_checks.xml" failOnViolation="false" failureProperty="checkstyle.failure">
<fileset dir="src">
<patternset refid="java.files.pattern"/>
</fileset>
<fileset dir="other">
<patternset refid="java.files.pattern"/>
</fileset>
<formatter type="xml" toFile="${checkstyle.data.file}"/>
</checkstyle>
<xslt in="${checkstyle.data.file}" out="${checkstyle.report.file}" style="${checkstyle.xsl.file}"/>
</target>
<property name="applyToPublic" value="true"/> <!-- 應用到public聲明對象 -->
<property name="applyToProtected" value="false"/><!-- 非public 不應用-->
<property name="applyToPackage" value="false"/>
<property name="applyToPrivate" value="false"/>
<property name="format" value="^[a-zA-Z0-9]*$"/><!--非靜態變量名稱定義規則-->
</module>
<property name="max" value="100"/><property name="tabWidth" value="4"/>