| 1 |
<?xml version="1.0"?> |
| 2 |
<!DOCTYPE project [ |
| 3 |
<!ENTITY properties SYSTEM "file:xmls/properties.xml"> |
| 4 |
<!ENTITY paths SYSTEM "file:xmls/path_refs.xml"> |
| 5 |
]> |
| 6 |
<project name="CheckStyle" default="usage"> |
| 7 |
|
| 8 |
<description> |
| 9 |
this is a library task file that is only to be invoked in an ant task. |
| 10 |
</description> |
| 11 |
|
| 12 |
&properties; |
| 13 |
&paths; |
| 14 |
|
| 15 |
<!-- Load in all standard app-wide properties --> |
| 16 |
|
| 17 |
<property name="checkstyle.project" value="axis"/> |
| 18 |
|
| 19 |
<property name="checkstyle.src.dir" location="${axis.home}/src"/> |
| 20 |
<property name="checkstyle.dest.dir" location="${build.dir}/checkstyle/${checkstyle.project}"/> |
| 21 |
<property name="checkstyle-noframes.xsl" |
| 22 |
location="${axis.home}/xmls/checkstyle-noframes.xsl"/> |
| 23 |
|
| 24 |
<property name="checkstyle.failonerror" value="false"/> |
| 25 |
<!-- <path id="checkstyle.classpath"> |
| 26 |
<path refid="ant.classpath" /> |
| 27 |
</path> |
| 28 |
--> |
| 29 |
|
| 30 |
|
| 31 |
<!-- look for checkstyle; fail gracefully --> |
| 32 |
<target name="probe_checkstyle"> |
| 33 |
<fail unless="axis.home"> |
| 34 |
axis.home is not defined; this is required |
| 35 |
</fail> |
| 36 |
<!-- classpathref="checkstyle.classpath" --> |
| 37 |
<available property="checkstyle.found" |
| 38 |
resource="checkstyletask.properties" |
| 39 |
/> |
| 40 |
<fail unless="checkstyle.found"> |
| 41 |
Unable to find the checkstyle jar on the classpath |
| 42 |
</fail> |
| 43 |
</target> |
| 44 |
|
| 45 |
<target name="init" depends="probe_checkstyle" > |
| 46 |
<taskdef resource="checkstyletask.properties" /> |
| 47 |
</target> |
| 48 |
|
| 49 |
<target name="checkstyle" depends="init" |
| 50 |
description="Check the style of a project"> |
| 51 |
<echo message="Checking style of ${checkstyle.project}"/> |
| 52 |
<mkdir dir="${checkstyle.dest.dir}"/> |
| 53 |
<property name="report.stem" value="checkstyle-${checkstyle.project}" /> |
| 54 |
<property name="results.xml" value="${report.stem}.xml" /> |
| 55 |
<property name="resultsfile.xml" |
| 56 |
location="${checkstyle.dest.dir}/${results.xml}" /> |
| 57 |
<property name="resultsfile.html" |
| 58 |
location="${checkstyle.dest.dir}/${report.stem}.html" /> |
| 59 |
<!-- |
| 60 |
to keep the 5000+ errors manageable and so pick on the key issues |
| 61 |
line length cranked up from apache's 68 rule. |
| 62 |
javadocs are unchecked |
| 63 |
whitespace is ignored |
| 64 |
protected data is allowed |
| 65 |
some time these can be cranked back, though protected vs accessors is a major |
| 66 |
design issue, not a simple source layout problem. |
| 67 |
--> |
| 68 |
<checkstyle failOnViolation="${checkstyle.failonerror}" |
| 69 |
maxLineLen="100" |
| 70 |
allowNoAuthor="true" |
| 71 |
ignoreWhitespace="true" |
| 72 |
allowProtected="true" |
| 73 |
javadocScope="nothing" |
| 74 |
cacheFile="${checkstyle.dest.dir}/checkstyle.cache"> |
| 75 |
<formatter type="plain"/> |
| 76 |
<formatter type="xml" toFile="${resultsfile.xml}"/> |
| 77 |
<fileset dir="${checkstyle.src.dir}" includes="**/*.java"/> |
| 78 |
</checkstyle> |
| 79 |
|
| 80 |
<style basedir="${checkstyle.dest.dir}" destdir="${checkstyle.dest.dir}" |
| 81 |
includes="${results.xml}" |
| 82 |
style="${checkstyle-noframes.xsl}"/> |
| 83 |
<echo> |
| 84 |
Style checked, results are in ${resultsfile.html} |
| 85 |
</echo> |
| 86 |
</target> |
| 87 |
|
| 88 |
<target name="usage" > |
| 89 |
<echo> |
| 90 |
This build file validates the source in a directory |
| 91 |
|
| 92 |
Required properties: |
| 93 |
axis.home base of axis java project |
| 94 |
checkstyle.project name of the project |
| 95 |
checkstyle.src.dir source directory |
| 96 |
checkstyle.dest.dir dir for results |
| 97 |
|
| 98 |
Optional |
| 99 |
checkstyle.failonerror failonerror flag; default=false |
| 100 |
checkstyle.classpath path to checkstyle.jar; default=ant classpath |
| 101 |
|
| 102 |
</echo> |
| 103 |
</target> |
| 104 |
</project> |