001      <?xml version="1.0" encoding="ISO-8859-1"?>
 002      
 003      <!--
 004         - Copyright 2005-2006 Jens Voß.
 005         -
 006         - Licensed under the Apache License, Version 2.0 (the "License");
 007         - you may not use this file except in compliance with the License.
 008         - You may obtain a copy of the License at
 009         -
 010         -     http://www.apache.org/licenses/LICENSE-2.0
 011         -
 012         - Unless required by applicable law or agreed to in writing, software
 013         - distributed under the License is distributed on an "AS IS" BASIS,
 014         - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 015         - See the License for the specific language governing permissions and
 016         - limitations under the License.
 017         -
 018        -->
 019      
 020      <!---
 021          - This is the main ant build file for the Alster project.
 022         -->
 023      <project name="Alster" basedir="." default="deploy">
 024      
 025        <property name="srcdir" value="${basedir}/src"/>
 026        <property name="libdir" value="${basedir}/lib"/>
 027        <property name="builddir" value="${basedir}/classes"/>
 028        <property name="distdir" value="${basedir}/dist"/>
 029        <property name="etcdir" value="${basedir}/etc"/>
 030      
 031        <property name="testdir" value="${basedir}/test"/>
 032        <property name="testsrcdir" value="${testdir}/src"/>
 033        <property name="testbuilddir" value="${testdir}/classes"/>
 034        <property name="testresultdir" value="${testdir}/results"/>
 035      
 036        <property name="docdir" value="${basedir}/doc"/>
 037        <property name="apidir" value="${docdir}/build/api"/>
 038        <property name="xdcdir" value="${docdir}/build/xdc"/>
 039      
 040        <property name="compile.debug" value="true"/>
 041        <property file="${etcdir}/buildNumber.properties"/>
 042        <property name="version" value="${number.major}.${number.minor}.${number.build}"/>
 043      
 044        <path id="cp">
 045          <fileset dir="${libdir}">
 046            <include name="*.jar"/>
 047          </fileset>
 048        </path>
 049      
 050        <!---
 051            - The <code>clean</code> target removes all class files and copied
 052            - resources from the build directory.
 053           -->
 054        <target name="clean" description="Delete all generated files">
 055          <mkdir dir="${builddir}"/>
 056          <delete includeemptydirs="yes">
 057            <fileset dir="${builddir}" includes="**/*"/>
 058          </delete>
 059        </target>
 060      
 061        <!---
 062            - This target compiles all Java sources of the Alster project. It also
 063            - copies all other resources (like XML files and XSLT stylesheets) from
 064            - the source directory to the build directory.
 065           -->
 066        <target name="compile" description="Compile Nalax classes">
 067          <mkdir dir="${builddir}"/>
 068          <javac srcdir="${srcdir}" destdir="${builddir}" debug="${compile.debug}">
 069            <classpath refid="cp"/>
 070          </javac>
 071          <copy todir="${builddir}" overwrite="yes">
 072            <fileset dir="${srcdir}">
 073              <include name="**/*.xml"/>
 074              <include name="**/*.xsl"/>
 075            </fileset>
 076          </copy>
 077        </target>
 078      
 079        <!---
 080            - This target compiles all sources "from scratch".
 081           -->
 082        <target name="compile-all"
 083                description="Compile Alster classes in 'fresh' directory"
 084                depends="clean,compile"/>
 085      
 086        <!---
 087            - The <code>jar</code> target combines all class and resource files
 088            - from the build directory in a JAR archive.
 089           -->
 090        <target name="jar" description="Archive class files in a JAR file" depends="compile">
 091          <mkdir dir="${distdir}"/>
 092          <delete file="${distdir}/alster.jar"/>
 093          <jar destfile="${distdir}/alster.jar">
 094            <fileset dir="${builddir}" includes="**/*.class"/>
 095            <fileset dir="${builddir}" includes="**/*.xml"/>
 096            <fileset dir="${builddir}" includes="**/*.xsl"/>
 097            <manifest>
 098              <attribute name="Built-By" value="${user.name}"/>
 099              <attribute name="Implementation-Title" value="Alster"/>
 100              <attribute name="Implementation-Version" value="${version}"/>
 101              <attribute name="Implementation-URL"
 102                         value="http://alster.sourceforge.net"/>
 103            </manifest>
 104          </jar>
 105        </target>
 106      
 107      
 108        <!---
 109            - This target compiles everything from scratch and builds a JAR archive
 110            - from all class and resource files.
 111           -->
 112        <target name="deploy" description="Create a build and package from scratch" depends="compile-all, jar"/>
 113      
 114      
 115        <!-- *********************************************************** -->
 116        <!-- *************** targets related to testing  *************** -->
 117        <!-- *********************************************************** -->
 118      
 119        <!---
 120            - This target cleans all class and result files from the XDC unit tests.
 121           -->
 122        <target name="clean.test" description="Clean test class directory">
 123          <mkdir dir="${testbuilddir}"/>
 124          <delete includeemptydirs="yes">
 125            <fileset dir="${testbuilddir}">
 126              <include name="**/*"/>
 127            </fileset>
 128          </delete>
 129        </target>
 130      
 131        <!---
 132            - This target deletes all previously generated JUnit and Alster test
 133            - results.
 134           -->
 135        <target name="clean.testresults" description="Clean test result directory">
 136          <mkdir dir="${testresultdir}"/>
 137          <delete includeemptydirs="yes">
 138            <fileset dir="${testresultdir}">
 139              <include name="**/*"/>
 140            </fileset>
 141          </delete>
 142        </target>
 143      
 144        <!---
 145            - This target is used to compile the JUnit test sources.
 146           -->
 147        <target name="compile.test" description="Compile the XDC test sources">
 148          <mkdir dir="${testbuilddir}"/>
 149          <javac srcdir="${testsrcdir}" destdir="${testbuilddir}"
 150                 encoding="ISO-8859-1"
 151                 debug="${compile.debug}">
 152            <classpath>
 153              <path refid="cp"/>
 154              <pathelement path="${builddir}"/>
 155            </classpath>
 156          </javac>
 157          <copy todir="${testbuilddir}">
 158            <fileset dir="${testsrcdir}">
 159              <include name="**/*.xml"/>
 160              <include name="**/*.xsl"/>
 161            </fileset>
 162          </copy>
 163        </target>
 164      
 165        <!---
 166            - This target executes all JUnit tests.
 167           -->
 168        <target name="junit" description="Run all JUnit tests">
 169          <delete includeemptydirs="yes">
 170            <fileset dir="${testresultdir}">
 171              <include name="**/*"/>
 172            </fileset>
 173          </delete>
 174          <junit fork="yes" printsummary="yes" haltonfailure="no" haltonerror="yes"
 175                 failureproperty="test.failed">
 176            <classpath>
 177              <path refid="cp"/>
 178              <pathelement path="${builddir}"/>
 179              <pathelement path="${testbuilddir}"/>
 180            </classpath>
 181            <batchtest todir="${testresultdir}">
 182              <formatter type="plain"/>
 183              <fileset dir="${testbuilddir}">
 184                <include name="**/*Test.class"/>
 185              </fileset>
 186            </batchtest>
 187          </junit>
 188          <fail if="test.failed" message="Not all JUnit tests passed!"/>
 189        </target>
 190      
 191        <!---
 192            - This target executes all Alster tests.
 193           -->
 194        <target name="alster" description="Run all Alster tests">
 195          <taskdef name="alster" classname="net.sf.alster.AlsterTextTask">
 196            <classpath>
 197              <pathelement location="${builddir}"/>
 198            </classpath>
 199          </taskdef>
 200          <alster dir="${testsrcdir}" failonerror="yes"
 201                  recurse="yes" resultdir="${testresultdir}">
 202            <classpath>
 203              <path refid="cp"/>
 204              <pathelement location="${builddir}"/>
 205            </classpath>
 206          </alster>
 207        </target>
 208      
 209        <!---
 210            - The <code>test</code> target performs all steps necessary for running
 211            - all (JUnit ans Alster) unit tests.
 212           -->
 213        <target name="test" description="Run all tests"
 214                depends="clean.test,clean.testresults,compile.test,junit,alster"/>
 215      
 216        <!-- *********************************************************** -->
 217        <!-- ************* targets related to documenting  ************* -->
 218        <!-- *********************************************************** -->
 219      
 220        <property name="titleText" value="Alster - Unit Testing Framework for XSLT"/>
 221        <property name="headerText" value="Alster - v. ${version}"/>
 222      
 223        <!---
 224            - This target deletes all Javadoc generated documentation.
 225           -->
 226        <target name="clean.javadoc" description="Clean the generated Javadoc documentation">
 227          <mkdir dir="${apidir}"/>
 228          <delete includeemptydirs="yes">
 229            <fileset dir="${apidir}">
 230              <include name="**/*"/>
 231            </fileset>
 232          </delete>
 233        </target>
 234      
 235        <!---
 236            - The <code>javadoc</code> target generates Javadoc documentation from the
 237            - Java source files of the XDC application.
 238           -->
 239        <target name="javadoc" description="Generate Javadoc documentation from XDC source Java files">
 240          <mkdir dir="${apidir}"/>
 241          <javadoc classpathref="cp"
 242                   locale="de_DE"
 243                   encoding="ISO-8859-1"
 244                   destdir="${apidir}"
 245                   linksource="yes"
 246                   windowtitle="${titleText}"
 247                   doctitle="${titleText}"
 248                   header="${headerText}"
 249                   footer="${headerText}">
 250            <packageset dir="${srcdir}" defaultexcludes="yes"/>
 251          </javadoc>
 252        </target>
 253      
 254        <!---
 255            - This target deletes all XDC generated documentation.
 256           -->
 257        <target name="clean.xdc" description="Clean the generated XDC documentation">
 258          <mkdir dir="${xdcdir}"/>
 259          <delete includeemptydirs="yes">
 260            <fileset dir="${xdcdir}">
 261              <include name="**/*"/>
 262            </fileset>
 263          </delete>
 264        </target>
 265      
 266        <!---
 267            - The <code>xdc</code> target generates XDC documentation from the XML
 268            - source files of the XDC application.
 269           -->
 270        <target name="xdc"
 271                description="Generate XDC documentation from Alster source XML files">
 272          <taskdef name="xdc" classname="net.sf.xdc.XdcTask" classpathref="cp"/>
 273          <mkdir dir="${xdcdir}"/>
 274          <xdc classpathref="cp"
 275               sourcepath="${basedir};${srcdir}"
 276               destdir="${xdcdir}"
 277               subpackages="net.sf.alster"
 278               extensions="xsl"
 279               notimestamp="no"
 280               linksource="yes"
 281               defaultexcludes="yes"
 282               author="yes"
 283               nosince="yes"
 284               version="yes"
 285               windowtitle="${titleText}"
 286               doctitle="${titleText}"
 287               header="${headerText}"
 288               footer="${headerText}"
 289               reportmissing="yes">
 290            <bottom>
 291              <![CDATA[<i>Copyright &#169; 2005 - 2006 Jens Voß</i>.]]>
 292            </bottom>
 293            <arg value="build.xml"/>
 294          </xdc>
 295        </target>
 296      
 297        <!---
 298            - This target prepares the sources from which the XDC Developers'
 299            - Handbook is generated.
 300           -->
 301        <target name="preprocess.developer" description="Generate material for developers' handbook">
 302          <mkdir dir="${docdir}/generated"/>
 303          <mkdir dir="${docdir}/build/developer"/>
 304          <xslt in="${basedir}/etc/libraries.xml"
 305                style="${docdir}/etc/libraries.xsl"
 306                out="${docdir}/generated/libraries.xml" force="yes">
 307            <outputproperty name="method" value="xml"/>
 308            <outputproperty name="encoding" value="iso8859_1"/>
 309            <outputproperty name="indent" value="yes"/>
 310          </xslt>
 311          <copy todir="${docdir}/build/developer">
 312            <fileset dir="${libdir}">
 313              <include name="*.txt"/>
 314            </fileset>
 315          </copy>
 316        </target>
 317      
 318      
 319        <!---
 320            - This target generates the XDC Developers' Handbook.
 321           -->
 322        <target name="generate.developer" description="Generate developers' handbook"
 323                depends="preprocess.developer">
 324          <mkdir dir="${docdir}/build/developer"/>
 325          <xslt in="${docdir}/src/developer/developer.xml"
 326                style="${docdir}/etc/alsterDoc.xsl"
 327                out="${docdir}/build/developer/index.html" force="yes">
 328            <outputproperty name="encoding" value="iso8859_1"/>
 329          </xslt>
 330          <copy todir="${docdir}/build/developer">
 331            <fileset dir="${docdir}/src/developer">
 332              <include name="*.css"/>
 333              <include name="*.gif"/>
 334            </fileset>
 335          </copy>
 336        </target>
 337      
 338      
 339        <!---
 340            - This target generates the <code>Alster</code> Ant task description.
 341           -->
 342        <target name="generate.ant" description="Generate Ant task description">
 343          <mkdir dir="${docdir}/build/ant"/>
 344          <xslt in="${docdir}/src/ant/AntTask.xml"
 345                style="${docdir}/etc/alsterDoc.xsl"
 346                out="${docdir}/build/ant/index.html" force="yes">
 347            <outputproperty name="encoding" value="iso8859_1"/>
 348          </xslt>
 349        </target>
 350      
 351      
 352        <!---
 353            - The <code>document</code> target performs all build steps to
 354            - generate the complete set of XDC documentation.
 355           -->
 356        <target name="document" description="Generate all documentation"
 357                depends="javadoc,xdc,preprocess.developer,generate.developer,generate.ant">
 358          <copy file="${docdir}/src/index.html" todir="${docdir}/build"/>
 359        </target>
 360      
 361      
 362        <!-- *********************************************************** -->
 363        <!-- ************* targets related to documenting  ************* -->
 364        <!-- *********************************************************** -->
 365      
 366      
 367        <!---
 368            - This target creates a complete source release and creates one
 369            - <code>.zip</code> archive and one <code>.tar.gz</code> archive.
 370           -->
 371        <target name="release-source" description="Create a source release">
 372          <property name="release.name" value="alster-${version}"/>
 373          <mkdir dir="${distdir}"/>
 374          <zip destfile="${distdir}/${release.name}-src.zip">
 375            <zipfileset prefix="${release.name}" dir="${basedir}">
 376              <include name="*"/>
 377              <include name="etc/*"/>
 378              <include name="lib/*"/>
 379              <include name="src/**/*"/>
 380              <include name="test/*"/>
 381            </zipfileset>
 382          </zip>
 383          <tar destfile="${distdir}/${release.name}-src.tar">
 384            <tarfileset prefix="${release.name}" dir="${basedir}">
 385              <include name="*"/>
 386              <include name="etc/*"/>
 387              <include name="lib/*"/>
 388              <include name="src/**/*"/>
 389              <include name="test/*"/>
 390            </tarfileset>
 391          </tar>
 392          <gzip src="${distdir}/${release.name}-src.tar"
 393                destfile="${distdir}/${release.name}-src.tar.gz"/>
 394          <delete file="${distdir}/${release.name}-src.tar"/>
 395        </target>
 396      
 397      
 398        <!---
 399            - This target creates a complete binary release consisting of the
 400            - Alster JAR archive as well as all documentation. The contents of the
 401            - binary release are included in one <code>.zip</code> archive and one
 402            - <code>.tar.gz</code> archive.
 403           -->
 404        <target name="release-binary" description="Create a binary release" depends="deploy, test, document">
 405          <property name="release.name" value="alster-${version}"/>
 406          <mkdir dir="${distdir}"/>
 407          <zip destfile="${distdir}/${release.name}.zip">
 408            <zipfileset prefix="${release.name}" dir="${basedir}">
 409              <include name="dist/*.jar"/>
 410              <include name="lib/*"/>
 411              <include name="doc/**/*"/>
 412            </zipfileset>
 413          </zip>
 414          <tar destfile="${distdir}/${release.name}.tar">
 415            <tarfileset prefix="${release.name}" dir="${basedir}">
 416              <include name="dist/*.jar"/>
 417              <include name="lib/*"/>
 418              <include name="doc/**/*"/>
 419            </tarfileset>
 420          </tar>
 421          <gzip src="${distdir}/${release.name}.tar"
 422                destfile="${distdir}/${release.name}.tar.gz"/>
 423          <delete file="${distdir}/${release.name}.tar"/>
 424        </target>
 425      
 426      
 427        <!---
 428            - The <code>release</code> target creates both a source and a binary
 429            - release.
 430           -->
 431        <target name="release" description="Create a complete release" depends="release-source, release-binary"/>
 432      
 433      </project>