|
| 1 | +<?xml version="1.0"?> |
| 2 | +<project name="ASM" |
| 3 | + default="main" |
| 4 | + basedir="."> |
| 5 | + <property file="build.properties" /> |
| 6 | + <property file="../globalbuild.properties" /> |
| 7 | + <property file="../checkstyle.properties" /> |
| 8 | + <property file="../gformat.properties" /> |
| 9 | + <property file="../pmd.properties" /> |
| 10 | + <property file="../spotbugs.properties" /> |
| 11 | + <property file="../antcontrib.properties" /> |
| 12 | + <property file="../asm.properties" /> |
| 13 | + <property file="../groovy-ant.properties" /> |
| 14 | + <!-- Sets variables which can later be used. --> |
| 15 | + <!-- The value of a property is accessed via ${} --> |
| 16 | + <property name="src.dir" |
| 17 | + location="." /> |
| 18 | + <property name="build.dir" |
| 19 | + location="." /> |
| 20 | + <property name="dist.dir" |
| 21 | + location="dist" /> |
| 22 | + <property name="docs.dir" |
| 23 | + location="docs" /> |
| 24 | + <loadfile property="cs.cp" |
| 25 | + srcFile="../${cs.classpath.file}" /> |
| 26 | + <loadfile property="pmd.cp" |
| 27 | + srcFile="../${pmd.classpath.file}" /> |
| 28 | + <loadfile property="spotbugs.cp" |
| 29 | + srcfile="../${spotbugs.classpath.file}" /> |
| 30 | + <loadfile property="spotbugs-plugins.cp" |
| 31 | + srcfile="../${spotbugs-plugin.classpath.file}" /> |
| 32 | + <loadfile property="antcontrib.cp" |
| 33 | + srcFile="../${antcontrib.classpath.file}" /> |
| 34 | + <taskdef resource="net/sf/antcontrib/antlib.xml" |
| 35 | + classpath="${antcontrib.cp}"></taskdef> |
| 36 | + <target name="setupclasspath"> |
| 37 | + <description>setupclasspath target</description> |
| 38 | + <exec executable="bash"> |
| 39 | + <arg value="./setupclasspath" /> |
| 40 | + </exec> |
| 41 | + </target> |
| 42 | + <target name="loadclasspath" |
| 43 | + depends="setupclasspath"> |
| 44 | + <loadfile property="cs.cp" |
| 45 | + srcFile="../${cs.classpath.file}" /> |
| 46 | + <loadfile property="pmd.cp" |
| 47 | + srcFile="../${pmd.classpath.file}" /> |
| 48 | + <loadfile property="spotbugs.cp" |
| 49 | + srcfile="../${spotbugs.classpath.file}" /> |
| 50 | + <loadfile property="spotbugs-plugins.cp" |
| 51 | + srcfile="../${spotbugs-plugin.classpath.file}" /> |
| 52 | + <loadfile property="antcontrib.cp" |
| 53 | + srcFile="../${antcontrib.classpath.file}" /> |
| 54 | + <loadfile property="groovy-ant.cp" |
| 55 | + srcFile="../${groovy-ant.classpath.file}" /> |
| 56 | + <loadfile property="compilerclasspath" |
| 57 | + srcFile="${compile.cp}" /> |
| 58 | + <loadfile property="runclasspath" |
| 59 | + srcFile="${run.cp}" /> |
| 60 | + </target> |
| 61 | + <!-- Deletes the existing build, docs and dist directory--> |
| 62 | + <target name="clean"> |
| 63 | + <delete> |
| 64 | + <fileset dir="." |
| 65 | + includes="**/*.class" /> |
| 66 | + </delete> |
| 67 | + <delete dir="${docs.dir}" /> |
| 68 | + <delete dir="${dist.dir}" /> |
| 69 | + </target> |
| 70 | + <!-- Creates the build, docs and dist directory--> |
| 71 | + <target name="makedir"> |
| 72 | + <mkdir dir="${docs.dir}" /> |
| 73 | + <mkdir dir="${dist.dir}" /> |
| 74 | + </target> |
| 75 | + <!-- Compiles the java code (including the usage of library for JUnit --> |
| 76 | + <target name="compile" |
| 77 | + depends="loadclasspath,clean, makedir,format,checkstyle"> |
| 78 | + <javac includeantruntime="false" |
| 79 | + srcdir="${src.dir}" |
| 80 | + destdir="${build.dir}" |
| 81 | + classpath="${compilerclasspath}"> |
| 82 | + <compilerarg value="${javac.params}" /> |
| 83 | + <compilerarg value="${javac.params1}" /> |
| 84 | + </javac> |
| 85 | + </target> |
| 86 | + <!-- Creates Javadoc --> |
| 87 | + <target name="docs" |
| 88 | + depends="loadclasspath,compile"> |
| 89 | + <javadoc packagenames="${packages}" |
| 90 | + sourcepath="${src.dir}" |
| 91 | + destdir="${docs.dir}" |
| 92 | + additionalparam="${javadoc.params}"> |
| 93 | + <classpath> |
| 94 | + <pathelement path="${runclasspath}" /> |
| 95 | + </classpath> |
| 96 | + </javadoc> |
| 97 | + </target> |
| 98 | + <target name="manifest"> |
| 99 | + <tstamp /> |
| 100 | + <exec executable="bash" |
| 101 | + outputproperty="build"> |
| 102 | + <arg value="-c" /> |
| 103 | + <arg value="git log --pretty=format:'%h' | head -1" /> |
| 104 | + </exec> |
| 105 | + <manifest mode="update" |
| 106 | + file="${jar.manifest}"> |
| 107 | + <attribute name="Built-By" |
| 108 | + value="${user.name}" /> |
| 109 | + <section name="common"> |
| 110 | + <attribute name="Specification-Title" |
| 111 | + value="${ant.project.name}" /> |
| 112 | + <attribute name="Specification-Version" |
| 113 | + value="${version}" /> |
| 114 | + <attribute name="Specification-Vendor" |
| 115 | + value="" /> |
| 116 | + <attribute name="Implementation-Title" |
| 117 | + value="" /> |
| 118 | + <attribute name="Implementation-Version" |
| 119 | + value="${build} ${TODAY}" /> |
| 120 | + <attribute name="Implementation-Vendor" |
| 121 | + value="" /> |
| 122 | + </section> |
| 123 | + <attribute name="Main-Class" |
| 124 | + value="${main.class}" /> |
| 125 | + </manifest> |
| 126 | + </target> |
| 127 | + <!--Creates the deployable jar file --> |
| 128 | + <target name="jar" |
| 129 | + depends="loadclasspath,compile,manifest"> |
| 130 | + <jar destfile="${dist.dir}\${ant.project.name}-${version}.jar" |
| 131 | + basedir="${build.dir}" |
| 132 | + includes="**/*.class" |
| 133 | + manifest="${jar.manifest}"></jar> |
| 134 | + </target> |
| 135 | + <target name="run" |
| 136 | + depends="loadclasspath"> |
| 137 | + <description>Run target</description> |
| 138 | + <java classname="${main.class}"> |
| 139 | + <classpath> |
| 140 | + <pathelement location="${dist.dir}\${ant.project.name}-${version}.jar" /> |
| 141 | + <pathelement path="${java.class.path}" /> |
| 142 | + <pathelement path="${runclasspath}" /> |
| 143 | + </classpath> |
| 144 | + </java> |
| 145 | + </target> |
| 146 | + <target name="format"> |
| 147 | + <fileset dir="${basedir}" |
| 148 | + id="javasrcs"> |
| 149 | + <include name="**/*.java" /> |
| 150 | + </fileset> |
| 151 | + <pathconvert property="sources" |
| 152 | + refid="javasrcs" |
| 153 | + pathsep=" " /> |
| 154 | + <loadfile property="gformat.cp" |
| 155 | + srcFile="../${gformat.classpath.file}" /> |
| 156 | + <java classname="${gformat.main.class}" |
| 157 | + fork="true"> |
| 158 | + <arg line="-i ${sources}" /> |
| 159 | + <classpath> |
| 160 | + <pathelement path="${gformat.cp}" /> |
| 161 | + <pathelement path="${java.class.path}" /> |
| 162 | + </classpath> |
| 163 | + </java> |
| 164 | + <exec executable="bash"> |
| 165 | + <arg line="../cformat ${basedir}" /> |
| 166 | + </exec> |
| 167 | + <exec executable="bash"> |
| 168 | + <arg line="../xformatall ${basedir}" /> |
| 169 | + </exec> |
| 170 | + </target> |
| 171 | + <target name="checkstyleg" |
| 172 | + depends="loadclasspath"> |
| 173 | + <taskdef resource="net/sf/antcontrib/antlib.xml" |
| 174 | + classpath="${antcontrib.cp}"></taskdef> |
| 175 | + <move file="suppressions-xpath.xml" |
| 176 | + tofile="suppressions-xpath.xml.bak" |
| 177 | + preservelastmodified="true" |
| 178 | + force="true" |
| 179 | + failonerror="false" |
| 180 | + verbose="true" /> |
| 181 | + <fileset dir="${basedir}" |
| 182 | + id="javasrcs"> |
| 183 | + <include name="**/*.java" /> |
| 184 | + </fileset> |
| 185 | + <pathconvert property="sources" |
| 186 | + refid="javasrcs" |
| 187 | + pathsep=" " /> |
| 188 | + <loadfile property="cs.cp" |
| 189 | + srcFile="../${cs.classpath.file}" /> |
| 190 | + <java classname="${cs.main.class}" |
| 191 | + logError="true"> |
| 192 | + <arg line="-c ../${cs.config} -p ../${cs.properties} -o ${ant.project.name}-xpath.xml -g ${sources}" /> |
| 193 | + <classpath> |
| 194 | + <pathelement path="${cs.cp}" /> |
| 195 | + <pathelement path="${java.class.path}" /> |
| 196 | + </classpath> |
| 197 | + </java> |
| 198 | + <condition property="file.is.empty" |
| 199 | + else="false"> |
| 200 | + <length file="${ant.project.name}-xpath.xml" |
| 201 | + when="equal" |
| 202 | + length="0" /> |
| 203 | + </condition> |
| 204 | + <if> |
| 205 | + <equals arg1="${file.is.empty}" |
| 206 | + arg2="false" /> |
| 207 | + <then> |
| 208 | + <move file="${ant.project.name}-xpath.xml" |
| 209 | + tofile="suppressions-xpath.xml" |
| 210 | + preservelastmodified="true" |
| 211 | + force="true" |
| 212 | + failonerror="true" |
| 213 | + verbose="true" /> |
| 214 | + </then> |
| 215 | + <else> |
| 216 | + <echo message="No suppressions generated." /> |
| 217 | + <delete file="${ant.project.name}-xpath.xml" |
| 218 | + verbose="true" |
| 219 | + failonerror="false" /> |
| 220 | + </else> |
| 221 | + </if> |
| 222 | + </target> |
| 223 | + <target name="checkstyle" |
| 224 | + depends="loadclasspath"> |
| 225 | + <taskdef resource="${cs.taskdef.resource}" |
| 226 | + classpath="${cs.cp}" /> |
| 227 | + <first id="checkstylefile"> |
| 228 | + <fileset dir=".." |
| 229 | + includes="${cs.config}" /> |
| 230 | + </first> |
| 231 | + <checkstyle config="${toString:checkstylefile}" |
| 232 | + failOnViolation="false" |
| 233 | + properties="../${cs.properties}"> |
| 234 | + <fileset dir="${src.dir}" |
| 235 | + includes="**/*.java" /> |
| 236 | + <formatter type="plain" /> |
| 237 | + <formatter type="plain" |
| 238 | + toFile="${cs.output}" /> |
| 239 | + <classpath> |
| 240 | + <pathelement path="${cs.cp}" /> |
| 241 | + <pathelement path="${java.class.path}" /> |
| 242 | + </classpath> |
| 243 | + </checkstyle> |
| 244 | + </target> |
| 245 | + <target name="pmd" |
| 246 | + depends="loadclasspath"> |
| 247 | + <taskdef name="pmd" |
| 248 | + classname="net.sourceforge.pmd.ant.PMDTask" |
| 249 | + classpath="${pmd.cp}" /> |
| 250 | + <property name="pmd.errCount" |
| 251 | + value="0" /> |
| 252 | + <pmd cacheLocation="${pmd.cacheFile}" |
| 253 | + minimumPriority="${pmd.minimumPriority}" |
| 254 | + suppressMarker="${pmd.suppressMarker}" |
| 255 | + failuresPropertyName="pmd.errCount"> |
| 256 | + <ruleset>../${pmd.config}</ruleset> |
| 257 | + <auxclasspath> |
| 258 | + <pathelement path="${basedir}" /> |
| 259 | + </auxclasspath> |
| 260 | + <formatter type="${pmd.reportFormat}" |
| 261 | + toFile="${pmd.output}" |
| 262 | + toConsole="${pmd.toConsole}"></formatter> |
| 263 | + <fileset dir="${basedir}"> |
| 264 | + <include name="**/*.java" /> |
| 265 | + </fileset> |
| 266 | + </pmd> |
| 267 | + <echo message="${pmd.errCount} violations found." /> |
| 268 | + </target> |
| 269 | + <target name="spotbugs" |
| 270 | + depends="loadclasspath,compile"> |
| 271 | + <taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties" |
| 272 | + classpath="${spotbugs.cp}:${spotbugs-plugins.cp}" /> |
| 273 | + <spotbugs output="text" |
| 274 | + outputFile="${spotbugs.output}" |
| 275 | + reportLevel="low" |
| 276 | + effort="max" |
| 277 | + nested="true"> |
| 278 | + <auxClasspath path="${basedir}" /> |
| 279 | + <auxClasspath path="${runclasspath}" /> |
| 280 | + <sourcePath path="${basedir}" /> |
| 281 | + <class location="${basedir}" /> |
| 282 | + <classpath> |
| 283 | + <pathelement path="${spotbugs.cp}" /> |
| 284 | + <pathelement path="${java.class.path}" /> |
| 285 | + </classpath> |
| 286 | + </spotbugs> |
| 287 | + </target> |
| 288 | + <target name="main" |
| 289 | + depends="loadclasspath,compile, pmd, spotbugs,jar,docs"> |
| 290 | + <description>Main target</description> |
| 291 | + </target> |
| 292 | +</project> |
0 commit comments