|
- <?xml version="1.0"?>
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <project default="checkstyle" name="CheckAnt">
-
- <description>
- Check Ants codebase against certain code styleguide rules using
- checkstyle and simian.
-
- Checkstyle uses an abstract syntax tree (AST) for doing checks
- against java sources. It is available at http://checkstyle.sourceforge.net/
- under GPL 2.1 license.
-
- "Simian (Similarity Analyser) identifies duplication in Java, C#, C,
- CPP, COBOL, JSP, HTML source code and even plain text files."
- It is available at http://www.redhillconsulting.com.au/products/simian/
- and is for free use in open source projects.
-
- See external task page and homepages for more information.
- </description>
-
- <import file="build.xml"/>
- <property name="config.dir" location="${etc.dir}/checkstyle"/>
-
- <property name="checkstyle.reportdir" location="${build.dir}/reports/checkstyle"/>
- <property name="checkstyle.raw" location="${checkstyle.reportdir}/raw.xml"/>
- <property name="stylesheet.html" location="${config.dir}/checkstyle-frames.xsl"/>
- <property name="stylesheet.text" location="${config.dir}/checkstyle-text.xsl"/>
- <property name="stylesheet.xdoc" location="${config.dir}/checkstyle-xdoc.xsl"/>
-
- <property name="checkstyle.basedir" location="${java.dir}"/>
-
- <!-- Ant Checkstyle report -->
- <property name="tocheck" value="**/*.java"/>
- <property name="javadoc.scope" value="public"/>
-
- <taskdef resource="simiantask.properties"/>
- <taskdef resource="checkstyletask.properties"/>
-
- <target name="checkstyle" description="--> checks Ant codebase according to ${config.dir}/checkstyle-config">
- <mkdir dir="${checkstyle.reportdir}"/>
- <checkstyle config="${config.dir}/checkstyle-config" failOnViolation="false">
- <formatter type="xml" toFile="${checkstyle.raw}"/>
- <fileset dir="${java.dir}">
- <include name="${tocheck}"/>
- <exclude name="**/bzip2/*.java"/>
- <exclude name="**/CVSPass.java"/>
- </fileset>
- </checkstyle>
- </target>
-
- <target name="htmlreport" description="--> generates a html checkstyle report">
- <mkdir dir="${checkstyle.reportdir}"/>
- <xslt in="${checkstyle.raw}" style="${stylesheet.html}"
- out="${checkstyle.reportdir}/html/output.txt">
- <param name="basedir" expression="${checkstyle.basedir}"/>
- </xslt>
- </target>
-
- <target name="textreport" description="--> generates a text checkstyle report">
- <xslt in="${checkstyle.raw}" style="${stylesheet.text}"
- out="${checkstyle.reportdir}/report.txt">
- </xslt>
- </target>
-
- <target name="textreport-display" depends="textreport" description="--> generates a text checkstyle report and displays it immediately">
- <loadfile property="report" srcfile="${checkstyle.reportdir}/report.txt"/>
- <echo>${report}</echo>
- </target>
-
- <target name="xdocreport" description="--> generates a xdoc checkstyle report">
- <xslt in="${checkstyle.raw}" style="${stylesheet.xdoc}"
- out="${checkstyle.reportdir}/xdocs/index.xml">
- <param name="basedir" expression="${checkstyle.basedir}"/>
- </xslt>
- </target>
-
- <target name="dumphtml" depends="checkstyle, htmlreport" description="--> runs the checkstyle and generates a html report"/>
- <target name="dumptext" depends="checkstyle, textreport" description="--> runs the checkstyle and displays result as text">
- <concat>
- <filelist dir="${checkstyle.reportdir}" files="report.txt"/>
- </concat>
- </target>
-
- <target name="simiancheck" description="--> runs the check for duplicates">
- <simian>
- <fileset dir="${java.dir}" />
- </simian>
- </target>
-
- <target name="fixTS" description="fix error 'Line has trailing spaces'">
- <fail message="Define path to java file 'path'">
- <condition><not><isset property="path"/></not></condition>
- </fail>
- <replaceregexp match="\s+$" replace="" flags="g" byline="true">
- <fileset dir="src/main" includes="${path}"/>
- </replaceregexp>
- </target>
-
- <target name="fixTab" description="fix error 'Line contains TAB sign'">
- <fail message="Define path to java file 'path'">
- <condition><not><isset property="path"/></not></condition>
- </fail>
- <fixcrlf srcdir="src/main" includes="${path}" javafiles="yes" tab="remove" tablength="4"/>
- </target>
-
- </project>
|