You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

check.xml 5.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <project default="checkstyle" name="CheckAnt">
  17. <description>
  18. Check Ants codebase against certain code styleguide rules using
  19. checkstyle and simian.
  20. Checkstyle uses an abstract syntax tree (AST) for doing checks
  21. against java sources. It is available at http://checkstyle.sourceforge.net/
  22. under GPL 2.1 license.
  23. "Simian (Similarity Analyser) identifies duplication in Java, C#, C,
  24. CPP, COBOL, JSP, HTML source code and even plain text files."
  25. It is available at http://www.redhillconsulting.com.au/products/simian/
  26. and is for free use in open source projects.
  27. See external task page and homepages for more information.
  28. </description>
  29. <import file="build.xml"/>
  30. <property name="config.dir" location="${etc.dir}/checkstyle"/>
  31. <property name="checkstyle.reportdir" location="${build.dir}/reports/checkstyle"/>
  32. <property name="checkstyle.raw" location="${checkstyle.reportdir}/raw.xml"/>
  33. <property name="stylesheet.html" location="${config.dir}/checkstyle-frames.xsl"/>
  34. <property name="stylesheet.text" location="${config.dir}/checkstyle-text.xsl"/>
  35. <property name="stylesheet.xdoc" location="${config.dir}/checkstyle-xdoc.xsl"/>
  36. <property name="checkstyle.basedir" location="${java.dir}"/>
  37. <!-- Ant Checkstyle report -->
  38. <property name="tocheck" value="**/*.java"/>
  39. <property name="javadoc.scope" value="public"/>
  40. <taskdef resource="simiantask.properties"/>
  41. <taskdef resource="checkstyletask.properties"/>
  42. <target name="checkstyle" description="--> checks Ant codebase according to ${config.dir}/checkstyle-config">
  43. <mkdir dir="${checkstyle.reportdir}"/>
  44. <checkstyle config="${config.dir}/checkstyle-config" failOnViolation="false">
  45. <formatter type="xml" toFile="${checkstyle.raw}"/>
  46. <fileset dir="${java.dir}">
  47. <include name="${tocheck}"/>
  48. <exclude name="**/bzip2/*.java"/>
  49. <exclude name="**/CVSPass.java"/>
  50. </fileset>
  51. </checkstyle>
  52. </target>
  53. <target name="htmlreport" description="--> generates a html checkstyle report">
  54. <mkdir dir="${checkstyle.reportdir}"/>
  55. <xslt in="${checkstyle.raw}" style="${stylesheet.html}"
  56. out="${checkstyle.reportdir}/html/output.txt">
  57. <param name="basedir" expression="${checkstyle.basedir}"/>
  58. </xslt>
  59. </target>
  60. <target name="textreport" description="--> generates a text checkstyle report">
  61. <xslt in="${checkstyle.raw}" style="${stylesheet.text}"
  62. out="${checkstyle.reportdir}/report.txt">
  63. </xslt>
  64. </target>
  65. <target name="textreport-display" depends="textreport" description="--> generates a text checkstyle report and displays it immediately">
  66. <loadfile property="report" srcfile="${checkstyle.reportdir}/report.txt"/>
  67. <echo>${report}</echo>
  68. </target>
  69. <target name="xdocreport" description="--> generates a xdoc checkstyle report">
  70. <xslt in="${checkstyle.raw}" style="${stylesheet.xdoc}"
  71. out="${checkstyle.reportdir}/xdocs/index.xml">
  72. <param name="basedir" expression="${checkstyle.basedir}"/>
  73. </xslt>
  74. </target>
  75. <target name="dumphtml" depends="checkstyle, htmlreport" description="--> runs the checkstyle and generates a html report"/>
  76. <target name="dumptext" depends="checkstyle, textreport" description="--> runs the checkstyle and displays result as text">
  77. <concat>
  78. <filelist dir="${checkstyle.reportdir}" files="report.txt"/>
  79. </concat>
  80. </target>
  81. <target name="simiancheck" description="--> runs the check for duplicates">
  82. <simian>
  83. <fileset dir="${java.dir}" />
  84. </simian>
  85. </target>
  86. <target name="fixTS" description="fix error 'Line has trailing spaces'">
  87. <fail message="Define path to java file 'path'">
  88. <condition><not><isset property="path"/></not></condition>
  89. </fail>
  90. <replaceregexp match="\s+$" replace="" flags="g" byline="true">
  91. <fileset dir="src/main" includes="${path}"/>
  92. </replaceregexp>
  93. </target>
  94. <target name="fixTab" description="fix error 'Line contains TAB sign'">
  95. <fail message="Define path to java file 'path'">
  96. <condition><not><isset property="path"/></not></condition>
  97. </fail>
  98. <fixcrlf srcdir="src/main" includes="${path}" javafiles="yes" tab="remove" tablength="4"/>
  99. </target>
  100. </project>