1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
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.
-->
<!--
This file contains all the jar download targets to build Velocity.
Its tasks are referenced from the build.xml file and should not be
called directly.
This is here so that the main build file is not cluttered any further.
-->
<project name="VelocityTools" basedir=".">
<!-- test classpath -->
<path id="test.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${dist.dir}/${view.id}.jar"/>
<fileset dir="${test.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- prepare tests -->
<target name="prepare.test">
<!-- <property name="cp" refid="test.classpath"/>
<echo message="using classpath=${cp}"/>
-->
<condition property="java.version.ok">
<not>
<or>
<equals arg1="${ant.java.version}" arg2="1.1"/>
<equals arg1="${ant.java.version}" arg2="1.2"/>
<equals arg1="${ant.java.version}" arg2="1.3"/>
<equals arg1="${ant.java.version}" arg2="1.4"/>
</or>
</not>
</condition>
<fail message="VelocityTools tests require at least Java 1.5" unless="java.version.ok"/>
<mkdir dir="${test.lib.dir}"/>
<mkdir dir="${test.rst.dir}"/>
<mkdir dir="${test.classes.dir}"/>
<mkdir dir="${test.log.dir}"/>
<pathconvert property="test.conf.dir.java" targetos="unix">
<path location="${test.conf.dir}"/>
</pathconvert>
<pathconvert property="test.file.dir" targetos="unix">
<path location="${test.src.dir}"/>
</pathconvert>
<filter token="test.file.dir" value="${test.file.dir}"/>
<filter token="test.conf.dir" value="${test.conf.dir.java}"/>
<filter token="test.log.dir" value="${test.log.dir}"/>
<filter token="test.webcontainer.port" value="${test.webcontainer.port}"/>
<copy todir="${test.build.src.dir}" filtering="yes">
<fileset dir="${test.src.dir}">
<include name="**/*.java"/>
<include name="**/*.properties"/>
<include name="**/*.xml"/>
</fileset>
</copy>
<copy tofile="${test.dir}/etc/jetty.xml" file="${test.dir}/etc/jetty.xml.tmpl" filtering="yes"/>
</target>
<!-- clean tests -->
<target name="test.clean">
<delete file="${test.dir}/etc/jetty.xml"/>
</target>
<!-- clean test libraries -->
<target name="test.clean.lib">
<delete dir="${test.lib.dir}"/>
</target>
<!-- whitebox tests downloads -->
<target name="whitebox.test.download" depends="prepare.test">
<!-- download dependency jars if needed -->
<ant antfile="${basedir}/download.xml" target="whitebox-test-download"/>
</target>
<!-- blackbox tests downloads -->
<target name="blackbox.test.download" depends="prepare.test">
<!-- download dependency jars if needed -->
<ant antfile="${basedir}/download.xml" target="blackbox-test-download"/>
</target>
<!-- compile whitebox tests -->
<target name="compile.whitebox.test" depends="whitebox.test.download">
<javac srcdir="${test.build.src.dir}"
destdir="${test.classes.dir}"
encoding="${compile.encoding}"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
includes="**/whitebox/*.java"
source="${test.compile.source}"
target="${test.compile.target}"
classpathref="test.classpath">
<include name="*.java"/>
<include name="**/*Tests.java"/>
<exclude name="**/blackbox/*.java"/>
</javac>
<!-- copy non-java resources -->
<copy todir="${test.classes.dir}">
<fileset dir="${test.build.src.dir}" excludes="**/*.java"/>
</copy>
</target>
<!-- compile blackbox tests -->
<target name="compile.blackbox.test" depends="blackbox.test.download">
<property name="name" value="showcase" />
<property name="base" value="${examples.home}/${name}" />
<property name="lib" value="${base}/WEB-INF/lib"/>
<ant antfile="${basedir}/examples.xml" target="example-compile"/>
<javac srcdir="${test.build.src.dir}"
destdir="${test.classes.dir}"
encoding="${compile.encoding}"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
includes="**/blackbox/*.java,org/apache/velocity/tools/test/JettyLogger.java"
classpathref="test.classpath"/>
<jar jarfile="${test.lib.dir}/jettylogger.jar" basedir="${test.classes.dir}" includes="org/apache/velocity/tools/test/JettyLogger.class"/>
<copy todir="${lib}" file="${lib.dir}/commons-logging-${jar.commons-logging.version}.jar"/>
<copy todir="${base}/WEB-INF/classes" file="${test.dir}/conf/commons-logging.properties"/>
<javac srcdir="${test.build.src.dir}"
destdir="${base}/WEB-INF/classes"
encoding="${compile.encoding}"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
includes="org/apache/velocity/tools/test/FilteredLogChuteCommonsLog.java"
classpathref="test.classpath"/>
</target>
<!-- generic (whitebox) tests -->
<target name="test.generic" depends="compile.whitebox.test">
<junit fork="false"
printSummary="yes"
haltonerror="${test.haltonerror}"
haltonfailure="${test.haltonfailure}">
<classpath>
<path refid="test.classpath"/>
<pathelement location="${test.classes.dir}"/>
</classpath>
<batchtest todir="${test.rst.dir}">
<fileset dir="${test.classes.dir}">
<include name="org/apache/velocity/tools/**/*Tests.class"/>
<exclude name="org/apache/velocity/tools/test/blackbox/**/*"/>
</fileset>
</batchtest>
<formatter type="plain"/>
</junit>
</target>
<!-- view tools (blackbox) tests -->
<target name="test.view">
<antcall target="start-showcase-webapp"/>
<junit fork="false"
printSummary="withOutAndErr"
haltonerror="false"
haltonfailure="false"
errorproperty="test.error"
failureproperty="test.failure">
<classpath>
<path refid="test.classpath"/>
<pathelement location="${test.classes.dir}"/>
</classpath>
<batchtest todir="${test.rst.dir}">
<fileset dir="${test.classes.dir}">
<include name="**/blackbox/*Test*"/>
</fileset>
</batchtest>
<formatter type="plain"/>
</junit>
<antcall target="stop-showcase-webapp"/>
<antcall target="clean-showcase-webapp"/>
<condition property="test.success">
<and>
<isfalse value="${test.error}"/>
<isfalse value="${test.failure}"/>
</and>
</condition>
<fail message="blackbox tests failed" unless="test.success"/>
</target>
<!-- start showcases webapp -->
<target name="start-showcase-webapp" depends="compile.blackbox.test">
<fail message="Localhost port ${test.webcontainer.control.port} is busy. Is the showcase webapp already running?">
<condition>
<socket server="127.0.0.1" port="${test.webcontainer.port}"/>
</condition>
</fail>
<java fork="true" spawn="true" jar="${test.lib.dir}/start-6.0.1.jar" dir="${test.dir}">
<arg value="etc/jetty.xml"/>
<sysproperty key="jetty.home" value="${test.dir}"/>
<sysproperty key="jetty.port" value="${test.webcontainer.port}"/>
<sysproperty key="STOP.PORT" value="${test.webcontainer.control.port}"/>
<sysproperty key="STOP.KEY" value="verysecret"/>
<sysproperty key="org.mortbay.log.class" value="org.apache.velocity.tools.test.JettyLogger"/>
<sysproperty key="jetty.log.file" value="${test.log.dir}/showcase.log"/>
</java>
<waitfor maxwait="2" maxwaitunit="minute" checkevery="500">
<http url="http://localhost:${test.webcontainer.port}/"/>
</waitfor>
<echo message="web server launched successfully."/>
</target>
<!-- stop showcase webapp -->
<target name="stop-showcase-webapp">
<java fork="true" jar="${test.lib.dir}/start-6.0.1.jar" dir="${test.dir}">
<arg value="--stop"/>
<sysproperty key="STOP.PORT" value="${test.webcontainer.control.port}"/>
<sysproperty key="STOP.KEY" value="verysecret"/>
</java>
</target>
<!-- cleanup showcase webapp -->
<target name="clean-showcase-webapp">
<waitfor maxwait="30" maxwaitunit="second" checkevery="1000">
<not>
<isreachable url="http://localhost:${test.webcontainer.port}/"/>
</not>
</waitfor>
<property name="target" value="clean"/>
<ant antfile="${basedir}/examples.xml" target="showcase-example" />
</target>
<!-- Analyze code with FindBugs -->
<target name="findbugs">
<echo>Working with FindBugs at: ${findbugs.home}</echo>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
<classpath>
<fileset dir="${findbugs.home}/lib">
<include name="findbugs-ant.jar"/>
</fileset>
</classpath>
</taskdef>
<echo>Analyzing ${dist.dir}/${project.id}.jar built from ${source.home}</echo>
<findbugs home="${findbugs.home}"
output="html"
outputFile="${test.build.dir}\findbugs-report.html"
failOnError="true">
<auxClasspath>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</auxClasspath>
<sourcePath path="${source.home}" />
<class location="${dist.dir}/${project.id}.jar" />
</findbugs>
</target>
<!-- Analyze code with PMD -->
<target name="pmd">
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
<classpath>
<fileset dir="${pmd.home}/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<echo>Analyzing ${source.home}/main/java...</echo>
<pmd shortFilenames="true"
failonerror="true">
<!-- To minimize noise keep rulesets that you are done checking here...
-->
<ruleset>unusedcode</ruleset>
<ruleset>imports</ruleset>
<ruleset>braces</ruleset>
<!-- ... and rulesets you're not ready to check here.
<ruleset>basic</ruleset>
<ruleset>strings</ruleset>
<ruleset>design</ruleset>
<ruleset>codesize</ruleset>
-->
<formatter type="html"
toFile="${test.build.dir}\pmd_report.html"/>
<fileset dir="${source.home}/main/java">
<include name="**/*.java"/>
</fileset>
</pmd>
<echo>Generated report is at ${test.build.dir}\pmd_report.html</echo>
</target>
</project>
|