<?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.
-->

<project name="velocity-tools" default="all" basedir="." xmlns:artifact="urn:maven-artifact-ant">

<!-- ========== Properties ===================================== -->

  <!-- Give user a chance to override without editing this file
       (and without typing -D each time it compiles it -->
  <property file="${user.home}/.ant.properties" />
  <property file="${user.home}/build.properties" />
  <property file=".ant.properties" />

  <!-- This file contains all the defaults for building VelocityTools -->
  <property file="build.properties"/>                <!-- Component local   -->



<!-- ========== Targets ======================================== -->

  <!-- Main Target -->
  <target name="all" depends="clean,jar.struts,examples,javadoc,docs,env"
          description="Clean and build velocity-tools library, examples, and documentation."/>


  <!-- Environment Target -->
  <target name="env" description="Prints build parameters">
    <echo>
  Global settings:
    java.home =         ${java.home}
    user.home =         ${user.home}
    java.class.path =   ${java.class.path}

  Project settings:
    Version:            ${project.id}
    Debug:              ${compile.debug}
    Optimize:           ${compile.optimize}
    Deprecation:        ${compile.deprecation}
    Encoding:           ${compile.encoding}

  Build settings:
    Source Files:       ${source.home}
    Build Files:        ${build.dir}
    Distribution Files: ${dist.dir}
    </echo>
  </target>


  <!-- Clean Target -->
  <target name="clean" description="Deletes the build, dist and docs directories">
    <delete dir="${build.dir}"/>
    <delete dir="${dist.dir}"/>
    <delete dir="${docs.dir}"/>
    <delete dir="${mvn.build.dir}"/>

    <!-- Clean example applications  -->
    <ant antfile="${basedir}/examples.xml" target="clean-examples" />

    <!-- Clean tests -->
    <ant antfile="${basedir}/test.xml" target="test.clean"/>

  </target>

  <!-- To do a truly, completely clean build, include this target -->
  <target name="clean.lib"
          description="Deletes the folder of downloaded dependencies">
    <delete dir="${lib.dir}"/>
    <ant antfile="${basedir}/test.xml" target="test.clean.lib"/>
  </target>


  <!-- Prepare Environment -->
  <target name="prepare" depends="prepare.compile,prepare.docs,prepare.examples">
    <echo message="-------- ${project.name} ${project.version} --------"/>
  </target>

  <!-- Prepare Compilation Environment -->
  <target name="prepare.compile">
    <!-- make necessary directories -->
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${lib.dir}" />
    <mkdir dir="${classes.dir}"/>
    <mkdir dir="${dist.dir}"/>

    <!-- download dependency jars -->
    <ant antfile="${basedir}/download.xml" target="compile-download" />

    <!-- construct classpath of all jars in lib repository -->
    <path id="compile.classpath">
      <fileset dir="${lib.dir}">
        <include name="**/*.jar"/>
      </fileset>
    </path>
  </target>

  <!-- Prepare Documentation Environment -->
  <target name="prepare.docs">
    <!-- make necessary directories -->
    <mkdir dir="${lib.dir}" />

    <!-- download dependency jars -->
    <ant antfile="${basedir}/download.xml" target="docs-download" />

    <!-- construct classpath of all jars needed to build docs -->
    <path id="docs.classpath">
      <fileset dir="${lib.dir}">
        <include name="**/*.jar"/>
      </fileset>
    </path>
  </target>

  <!-- Prepare Examples Environment -->
  <target name="prepare.examples">
    <!-- download dependency jars -->
    <ant antfile="${basedir}/download.xml" target="examples-download" />
  </target>


  <!-- Compile VelocityTools (all of it) -->
  <target name="compile" depends="compile.struts"
          description="Compiles the Velocity-Tools project (struts, view and generic)"/>

  <!-- Compile VelocityStruts (struts, view, generic) -->
  <target name="compile.struts" depends="prepare.compile"
          description="Compiles the Velocity-Tools project (struts, view, and generic)">
    <javac srcdir="${classes.src}"
           debug="${compile.debug}"
           optimize="${compile.optimize}"
           source="${compile.source}"
           target="${compile.target}"
           deprecation="${compile.deprecation}"
           encoding="${compile.encoding}"
           destdir="${classes.dir}">
      <classpath refid="compile.classpath" />
      <include name="org/**"/>
    </javac>

    <copy todir="${classes.dir}" filtering="yes">
      <fileset dir="${classes.src}">
        <include name="**/*.properties"/>
        <include name="**/*.xml"/>
        <include name="**/*.tld"/>
      </fileset>
    </copy>
  </target>

  <!-- Compile Just VelocityView (view, generic) -->
  <target name="compile.view" depends="prepare.compile"
          description="Compiles VelocityView and the generic tools">
    <javac srcdir="${classes.src}"
           debug="${compile.debug}"
           optimize="${compile.optimize}"
           source="${compile.source}"
           target="${compile.target}"
           deprecation="${compile.deprecation}"
           encoding="${compile.encoding}"
           destdir="${classes.dir}">
      <classpath refid="compile.classpath" />
      <include name="org/**"/>
      <exclude name="**/struts/**"/>
    </javac>

    <copy todir="${classes.dir}" filtering="yes">
      <fileset dir="${classes.src}">
        <include name="**/generic/*.properties"/>
        <include name="**/generic/*.xml"/>
        <include name="**/view/*.properties"/>
        <include name="**/view/*.xml"/>
        <include name="**/*.tld"/>
      </fileset>
    </copy>
  </target>

  <!-- Compile Just Generic Tools (generic) -->
  <target name="compile.generic" depends="prepare.compile"
          description="Compiles just the generic tools in this project">
    <javac srcdir="${classes.src}"
           debug="${compile.debug}"
           optimize="${compile.optimize}"
           source="${compile.source}"
           target="${compile.target}"
           deprecation="${compile.deprecation}"
           encoding="${compile.encoding}"
           destdir="${classes.dir}">
      <classpath refid="compile.classpath" />
      <include name="org/**"/>
      <exclude name="**/struts/**"/>
      <exclude name="**/view/**"/>
    </javac>

    <copy todir="${classes.dir}" filtering="yes">
      <fileset dir="${classes.src}">
        <include name="**/generic/*.properties"/>
        <include name="**/generic/*.xml"/>
      </fileset>
    </copy>
  </target>



  <!-- Jar VelocityTools (struts, view, generic) -->
  <target name="jar" depends="jar.struts"
          description="Creates a velocity-tools jar in the dist directory."/>

  <!-- Jar VelocityStruts (struts, view, generic) -->
  <target name="jar.struts" depends="compile.struts"
          description="Creates a velocity-tools jar in the dist directory.">
    <jar jarfile="${dist.dir}/${struts.id}.jar">
      <fileset dir="${classes.dir}"/>
      <metainf dir="${basedir}">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
      </metainf>
      <manifest>
        <attribute name="Created-By" value="Apache Ant"/>
        <attribute name="Package" value="org.apache.velocity.tools"/>
        <attribute name="Build-Jdk" value="${java.version}"/>
        <attribute name="Extension-Name" value="${struts.libname}"/>
        <attribute name="Specification-Title" value="${struts.name} is ${struts.description}" />
        <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Title" value="org.apache.velocity"/>
        <attribute name="Implementation-Vendor-Id" value="org.apache"/>
        <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Version" value="${project.version}"/>
      </manifest>
    </jar>
    <checksum file="${dist.dir}/${struts.id}.jar" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${struts.id}.jar" algorithm="sha1" fileext=".sha1"/>
  </target>

  <!-- Jar Just VelocityView (view, generic) -->
  <target name="jar.view" depends="compile.view"
          description="Creates a velocity-tools-view jar in the dist directory">
    <jar jarfile="${dist.dir}/${view.id}.jar">
      <fileset dir="${classes.dir}">
          <exclude name="**/struts/**"/>
      </fileset>
      <metainf dir="${basedir}">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
      </metainf>
      <manifest>
        <attribute name="Created-By" value="Apache Ant"/>
        <attribute name="Package" value="org.apache.velocity.tools"/>
        <attribute name="Build-Jdk" value="${java.version}"/>
        <attribute name="Extension-Name" value="${view.libname}"/>
        <attribute name="Specification-Title" value="${view.name} is ${view.description}" />
        <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Title" value="org.apache.velocity"/>
        <attribute name="Implementation-Vendor-Id" value="org.apache"/>
        <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Version" value="${project.version}"/>
      </manifest>
    </jar>
    <checksum file="${dist.dir}/${view.id}.jar" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${view.id}.jar" algorithm="sha1" fileext=".sha1"/>
  </target>

  <!-- Jar Just Generic Tools (generic) -->
  <target name="jar.generic" depends="compile.generic"
          description="Creates a velocity-tools-generic jar in the dist directory">
    <jar jarfile="${dist.dir}/${generic.id}.jar">
      <fileset dir="${classes.dir}">
          <exclude name="**/struts/**"/>
          <exclude name="**/view/**"/>
      </fileset>
      <metainf dir="${basedir}">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
      </metainf>
      <manifest>
        <attribute name="Created-By" value="Apache Ant"/>
        <attribute name="Package" value="org.apache.velocity.tools.generic"/>
        <attribute name="Build-Jdk" value="${java.version}"/>
        <attribute name="Extension-Name" value="${generic.libname}"/>
        <attribute name="Specification-Title" value="${generic.name} is ${generic.description}" />
        <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Title" value="org.apache.velocity.tools"/>
        <attribute name="Implementation-Vendor-Id" value="org.apache"/>
        <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Version" value="${project.version}"/>
      </manifest>
    </jar>
    <checksum file="${dist.dir}/${generic.id}.jar" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${generic.id}.jar" algorithm="sha1" fileext=".sha1"/>
  </target>



  <!-- Jar all source files (struts, view, generic) -->
  <target name="jar.source" depends="prepare"
          description="Builds a jar file of all the source classes">
    <jar jarfile="${dist.dir}/${project.id}-src.jar">
      <metainf dir="${basedir}">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
      </metainf>

      <fileset dir="${source.home}"/>
      <manifest>
        <attribute name="Created-By" value="Apache Ant"/>
        <attribute name="Specification-Title" value="${struts.name} is ${struts.description}" />
        <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Title" value="org.apache.velocity"/>
        <attribute name="Implementation-Vendor-Id" value="org.apache"/>
        <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Version" value="${project.version}"/>
      </manifest>
    </jar>
    <checksum file="${dist.dir}/${project.id}-src.jar" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${project.id}-src.jar" algorithm="sha1" fileext=".sha1"/>
  </target>

  <!-- Build Javadocs (struts, view, generic) -->
  <target name="javadoc" description="Builds Javadoc for the whole project.">
    <mkdir dir="${javadoc.dir}" />
    <javadoc packagenames="org.apache.velocity.tools.*"
             destdir="${docs.dir}/javadoc"
             author="true"
             private="true"
             version="true"
             doctitle="&lt;h1&gt;${javadoc.title}&lt;/h1&gt;"
             windowtitle="${javadoc.title}"
             bottom="Copyright (c) ${javadoc.year} Apache Software Foundation" >

      <classpath refid="compile.classpath"/>
      <sourcepath>
        <pathelement path="${classes.src}" />
      </sourcepath>
    </javadoc>
  </target>

  <!-- Build Javadocs Jar (struts, view, generic) -->
  <target name="jar.javadoc" depends="prepare,javadoc"
          description="Builds a jar file with the javadoc for the whole project.">

    <jar jarfile="${dist.dir}/${project.id}-javadoc.jar">
      <metainf dir="${basedir}">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
      </metainf>
      <fileset dir="${javadoc.dir}"/>
      <manifest>
        <attribute name="Created-By" value="Apache Ant"/>
        <attribute name="Specification-Title" value="${struts.name} is ${struts.description}" />
        <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Title" value="org.apache.velocity"/>
        <attribute name="Implementation-Vendor-Id" value="org.apache"/>
        <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
        <attribute name="Implementation-Version" value="${project.version}"/>
      </manifest>
    </jar>
    <checksum file="${dist.dir}/${project.id}-javadoc.jar" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${project.id}-javadoc.jar" algorithm="sha1" fileext=".sha1"/>
  </target>

  <!-- Build JDocs (for jdocs.com) -->
  <target name="jdocs" description="Builds JDocs for the whole project">
    <taskdef name="jdocs" classname="com.dzone.jdocs.ant.jdk15.task.Jdocs"/>
    <mkdir dir="${javadoc.dir}" />
    <jdocs packagenames="org.apache.velocity.tools.*"
             destdir="${docs.dir}/javadoc"
             author="true"
             private="true"
             version="true"
             doctitle="&lt;h1&gt;${javadoc.title}&lt;/h1&gt;"
             windowtitle="${javadoc.title}"
             bottom="Copyright (c) ${javadoc.year} Apache Software Foundation" >

      <classpath refid="compile.classpath"/>
      <sourcepath>
        <pathelement path="${classes.src}" />
      </sourcepath>
    </jdocs>
  </target>

  <!-- Build Velocity-Tools documentation -->
  <target name="docs" depends="prepare.docs"
          description="Generate documentation into ${docs.dir}">
    <taskdef name="dvsl" classname="org.apache.dvsl.DVSLTask">
      <classpath refid="docs.classpath"/>
    </taskdef>

    <dvsl basedir="${docs.src}"
          destdir="${docs.dir}/"
          extension=".html"
          style="${docs.src}/site.dvsl">
        <exclude name="**/*project.xml"/>
        <include name="**/*.xml"/>
    </dvsl>
    <!-- create printer version of documentation -->
    <dvsl basedir="${docs.src}"
          destdir="${docs.dir}/"
          extension="-printer.html"
          style="${docs.src}/site.dvsl">
        <exclude name="**/*project.xml"/>
        <include name="**/*.xml"/>
        <tool name="toolbox.string.PrinterFriendlyVersion" value="yes" />
    </dvsl>

    <copy todir="${docs.dir}/images">
      <fileset dir="${docs.src}/images">
        <include name="*.png" />
      </fileset>
    </copy>
    <copy todir="${docs.dir}/css">
      <fileset dir="${docs.src}/css">
        <include name="*.css" />
      </fileset>
    </copy>
  </target>


  <!-- Make documentation tar ball -->
  <target name="tardocs" depends="javadoc,docs"
          description="Combine all xdocs and docs into a tar ball.">

    <!-- make sure the dist directory exists -->
    <mkdir dir="${dist.dir}" />
    <tar destfile="${dist.dir}/docs.tar.gz"
         basedir="${basedir}"
         includes="docs/**,xdocs/**"
         compression="gzip" />
  </target>


  <!-- Build all example applications -->
  <target name="examples" depends="jar.view,jar.struts,prepare.examples"
          description="Compiles and jars all example applications.">
    <ant antfile="${basedir}/examples.xml" target="build-examples" />
  </target>

  <!-- Build VelocityView - Simple application -->
  <target name="simple" depends="jar.view,prepare.examples"
          description="Compiles and jars the VelocityView example application.">
    <property name="target" value="war"/>
    <ant antfile="${basedir}/examples.xml" target="simple-example" />
  </target>

  <!-- Build VelocityView - Showcase application -->
  <target name="showcase" depends="jar.view,prepare.examples"
          description="Compiles and jars the VelocityView Showcase example application.">
    <property name="target" value="war"/>
    <ant antfile="${basedir}/examples.xml" target="showcase-example" />
  </target>

  <!-- Let the user start Jetty on his local box -->
  <target name="start.showcase.webapp" description="Launches the Showcase example application using Jetty (uses http://localhost:8081 by default)">
    <ant antfile="${basedir}/test.xml" target="start-showcase-webapp"/>
  </target>

  <!-- Let the user stop Jetty -->
  <target name="stop.showcase.webapp" description="">
    <ant antfile="${basedir}/test.xml" target="stop-showcase-webapp"/>
  </target>

  <!-- Build VelocityStruts example application -->
  <target name="struts" depends="jar.struts,prepare.examples"
          description="Compiles and jars the VelocityStruts example application.">
    <property name="target" value="war"/>
    <ant antfile="${basedir}/examples.xml" target="struts-example" />
  </target>



  <!-- Convenient target for rolling releases -->
  <target name="release"
          depends="release.source,release.binaries,env,release.howto"
          description="Creates binary and source distribution files"/>

  <target name="release.howto">
    <echo>
                         ***** RELEASE INSTRUCTIONS *****

    * Be sure you can answer "yes" to the following:

        * Was your local code up to date and free of modifications or extra files?

        * Was the version number correct in both build.properties and pom.xml?

        * For a final release, the distributionManagement.site.url value
          in the pom.xml should be:
            scpexe://people.apache.org/www/velocity.apache.org/tools/releases/velocity-tools-${project.version}
          and for alpha or beta releases it should be:
            scpexe://people.apache.org/www/velocity.apache.org/engine/devel/

        * Do all new files have the Apache License? (use "ant rat" to double-check)

        * Is ${basedir}/xdocs/changes.xml up to date?
          Feel free to set an estimated release date for this version in that file;
          it can be corrected later if the release is delayed.

        * Is the ${basedir}/README.txt up to date for this release?

    * Check that you have no uncommitted changes with 'svn status'

    * Run 'ant clean compile' and 'ant clean test' with all supported JDKs

    * Check that at least 'maven clean install' works.

    * Check that all version numbers are in sync: build.properties, changes.xml, and pom.xml

    * Check that the README.txt and other documentation are up to date.

    * Write down the current svn revision so you don't have to look it up
      later when you make the tag for this release (post-vote).
    
    * Go to ${build.dir} and sign all the jar, zip, tar.gz and pom files
      with your personal PGP key. If using gpg, you'll probably do this:
        gpg --armor --output ${final.name}.zip.asc --detach-sig ${final.name}.zip
    * Now that the distribution files have been created, you will need to sign all
      of the jar, zip, pom, and tar.gz files with your private key. You can simplify
      this process with a script along the lines of:
        #! /bin/bash
        for i in *.tar.gz *.zip *jar; do
          gpg --armor --output $i.asc --detach-sig $i
        done

    * SSH into people.apache.org and make sure that this directory exists:
        ${publish.dir}
    * Login to people.apache.org and create an empty folder at:
         ~/public_html/velocity/tools/${project.version}

    * If you haven't done it before, ensure that your PGP key is appended to
        /www/www.apache.org/dist/velocity/KEYS
      Some instructions for that are at the top of that file.
    
    * Use 'ant publish' to upload the distribution files to that folder.
    
    * Review http://wiki.apache.org/velocity/ReleaseProcess for more details.
    </echo>
  </target>

  <!-- Create source distribution files -->
  <target name="release.source"
          depends="clean"
          description="Cleans everything and creates source distribution files">

    <mkdir dir="${dist.dir}"/>
    <zip zipfile="${dist.dir}/${project.id}-src.zip">
      <zipfileset dir="${basedir}" prefix="${project.id}-src">
        <include name="*"/>
        <include name="examples/**"/>
        <include name="src/**"/>
        <include name="xdocs/**"/>
        <include name="test/etc/**"/>
        <include name="test/conf/**"/>
      </zipfileset>
    </zip>
    <tar tarfile="${dist.dir}/${project.id}-src.tar" longfile="gnu">
      <tarfileset dir="${basedir}" prefix="${project.id}-src">
        <include name="*"/>
        <include name="examples/**"/>
        <include name="src/**"/>
        <include name="xdocs/**"/>
        <include name="test/etc/**"/>
        <include name="test/conf/**"/>
      </tarfileset>
    </tar>
    <gzip zipfile="${dist.dir}/${project.id}-src.tar.gz"
          src="${dist.dir}/${project.id}-src.tar"/>

    <!-- Create checksums for the binary distribution files -->
    <checksum file="${dist.dir}/${project.id}-src.zip" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${project.id}-src.zip" algorithm="sha1" fileext=".sha1"/>
    <checksum file="${dist.dir}/${project.id}-src.tar.gz" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${project.id}-src.tar.gz" algorithm="sha1" fileext=".sha1"/>
  </target>

  <!-- Create binary distribution files -->
  <target name="release.binaries"
          depends="clean,prepare,jar.struts,jar.view,jar.generic,jar.source,jar.javadoc,examples,javadoc,docs,test,showcase"
          description="Builds everything and creates the binary distribution files">

    <!-- Gather misc docs/files -->
    <mkdir dir="${release.dir}"/>
    <copy todir="${release.dir}" file="${basedir}/CONTRIBUTORS"/>
    <copy todir="${release.dir}" file="${basedir}/LICENSE"/>
    <copy todir="${release.dir}" file="${basedir}/NOTICE"/>
    <copy todir="${release.dir}" file="${basedir}/STATUS"/>
    <copy todir="${release.dir}" file="${basedir}/README.txt"/>
    <copy todir="${release.dir}" file="${basedir}/WHY_THREE_JARS.txt"/>

    <!-- Gather all project jars (exclude src and javadoc jars, as they're mostly for Maven) -->
    <mkdir dir="${release.dir}/lib"/>
    <copy todir="${release.dir}/lib">
      <fileset dir="${dist.dir}">
        <include name="*.jar" />
        <exclude name="*-src.jar"/>
        <exclude name="*-javadoc.jar"/>
      </fileset>
    </copy>

    <!-- Gather all project dependencies -->
    <copy todir="${release.dir}/lib">
      <fileset dir="${lib.dir}" includes="*.jar"/>
    </copy>

    <!-- Gather example war files -->
    <mkdir dir="${release.dir}/examples"/>
    <copy todir="${release.dir}/examples">
      <fileset dir="${examples.home}">
        <include name="*.war" />
      </fileset>
    </copy>

    <!-- Gather all generated documentation -->
    <mkdir dir="${release.dir}/docs"/>
    <copy todir="${release.dir}/docs">
      <fileset dir="${docs.dir}">
        <include name="**" />
      </fileset>
    </copy>

    <!-- Create binary distribution files -->
    <zip zipfile="${dist.dir}/${project.id}.zip"
         basedir="${dist.dir}/release"/>
    <tar tarfile="${dist.dir}/${project.id}.tar" longfile="gnu"
         basedir="${dist.dir}/release"/>
    <gzip zipfile="${dist.dir}/${project.id}.tar.gz"
          src="${dist.dir}/${project.id}.tar"/>

    <!-- Create a distribution ready POM -->
    <copy file="pom.xml" tofile="${dist.dir}/${project.id}.pom"/>

    <!-- Create checksums for the binary distribution files -->
    <checksum file="${dist.dir}/${project.id}.pom" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${project.id}.pom" algorithm="sha1" fileext=".sha1"/>
    <checksum file="${dist.dir}/${project.id}.zip" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${project.id}.zip" algorithm="sha1" fileext=".sha1"/>
    <checksum file="${dist.dir}/${project.id}.tar.gz" algorithm="md5" fileext=".md5"/>
    <checksum file="${dist.dir}/${project.id}.tar.gz" algorithm="sha1" fileext=".sha1"/>

    <!-- Delete TAR files and staging dir as they're no longer needed -->
    <delete>
      <fileset dir="${dist.dir}" includes="*.tar"/>
      <fileset dir="${dist.dir}/release"/>
    </delete>
  </target>


<!-- ========== Publish Targets ======================================== -->

  <target name="publish.check">
    <condition property="release.signed">
        <and>
            <available file="${dist.dir}/${project.id}.tar.gz.asc"/>
            <available file="${dist.dir}/${project.id}.zip.asc"/>
            <available file="${dist.dir}/${project.id}-src.tar.gz.asc"/>
            <available file="${dist.dir}/${project.id}-src.zip.asc"/>
            <available file="${dist.dir}/${project.id}.jar.asc"/>
            <available file="${dist.dir}/${project.id}-src.jar.asc"/>
            <available file="${dist.dir}/${project.id}-javadoc.jar.asc"/>
            <available file="${dist.dir}/${view.id}.jar.asc"/>
            <available file="${dist.dir}/${generic.id}.jar.asc"/>
        </and>
    </condition>
  </target>

  <target name="publish.sigs" unless="release.signed"
          depends="publish.check">
    <echo>
    You must first execute "release" target, then sign the distribution
    files with your pgp key (creating the needed '.asc'signature files).
    You may also need to add the Jsch jar to Ant's classpath to enable the
    optional 'scp' task.
    </echo>
  </target>

  <target name="publish.user" unless="username">
    <input message="Type your username and hit enter:" addproperty="username"/>
  </target>

  <target name="publish.pass" unless="password">
    <input message="Type your password and hit enter:" addproperty="password"/>
  </target>

  <target name="publish.auth"
          depends="publish.user,publish.pass">
    <condition property="have.auth">
        <and>
            <isset property="username"/>
            <isset property="password"/>
        </and>
    </condition>
  </target>

  <target name="prepare.publish" 
          depends="publish.sigs,publish.auth">
    <condition property="ready">
        <and>
            <isset property="release.signed"/>
            <isset property="have.auth"/>
        </and>
    </condition>
  </target>

  <target name="publish.upload" depends="prepare.publish" if="ready"
          description="Uploads distribution files">
    <echo>
    Uploading distribution files from
        ${dist.dir}
    to
        ${username}:${password}@${publish.server}:${publish.dir}
    </echo>
    <scp todir="${username}:${password}@${publish.server}:${publish.dir}"
        verbose="true" failonerror="true" trust="yes">
        <fileset dir="${dist.dir}"/>
    </scp>
  </target>

  <target name="publish.howto">
    <echo>
                         ***** RELEASE INSTRUCTIONS *****

    * SSH to ${publish.server} and verify the checksums and signatures of the uploaded
      files with a script like:
          #!/bin/csh
          foreach fn ( *.tar.gz *.zip *.jar *.pom )
            echo Verifying $fn...
            echo GPG signature should be "Good"
            gpg --verify $fn.asc
            echo MD5s should be identical
            cat $fn.md5
            md5 -q $fn
            echo SHA1s should be identical
            cat $fn.sha1
            sha1 -q $fn
            echo
          end

    * Announce the availability of the test build on the dev@velocity.apache.org list.
    
    * Allow a couple days for people to test the test build.

    * Call for a release vote on private@velocity.apache.org and dev@velocity.apache.org

    * Once the release vote has passed, these files should all be copied to
        /www/www.apache.org/dist/velocity/tools/${project.version}
      and the full jar, pom and their md5 and sha1 files should be copied into 
        /www/people.apache.org/repo/m2-ibiblio-rsync-repository/org/apache/velocity/velocity-tools/${project.version}/

    * Remove older releases of the same grade as this one (alpha, beta, final) from
        /www/www.apache.org/dist/velocity/tools

    * Tag the release in SVN with a command such as:
        svn copy -m "Release Tools ${project.version}" -r [revision #] \
           https://svn.apache.org/repos/asf/velocity/tools/trunk \
           https://svn.apache.org/repos/asf/velocity/tools/tags/${project.version}

    * Publish the documentation for this release on the website using 'ant publish.docs'

    * Update the download and news pages on the website

    * Send an announcement email to all Velocity lists and announce@apache.org
      once most of the mirrors have been updated with the distribution files.
    
    * Review http://wiki.apache.org/velocity/ReleaseProcess for more details.
    </echo>
  </target>

  <target name="publish" depends="publish.upload,publish.howto" if="ready"
          description="Uploads distribution files to server for release"/>

  <target name="publish.docs" depends="docs,publish.auth" if="have.auth"
          description="Updates development documentation on the website">
    <mkdir dir="${dist.dir}"/>
    <zip zipfile="${dist.dir}/docs.zip"
         basedir="${docs.dir}"/>
    <echo>
    Zips documentation files from
        ${docs.dir}
    and uploads them to
        ${username}:${password}@${publish.server}:${publish.docs.dir}
    </echo>
    <scp todir="${username}:${password}@${publish.server}:${publish.docs.dir}"
        verbose="true" failonerror="true" trust="yes">
        <fileset dir="${dist.dir}">
            <include name="docs.zip"/>
        </fileset>
    </scp>
    <echo>
                         ***** PUBLISH INSTRUCTIONS *****

    * SSH into people.apache.org

    * Unzip ${publish.docs.dir}docs.zip into either
        ${publish.docs.dir}releases/${project.version}
      or
        ${publish.docs.dir}devel/
      as appropriate.
    </echo>
  </target>

  <target name="rat" depends="release.source,prepare"
    description="Runs Apache RAT against the source code.">
    <!-- TODO: download RAT and deps -->
    <echo>
      NOTE: At this time, you must add Apache RAT, Apache RAT AntTasks
      Commons-Lang, Commons-Collections and Commons-CLI to Ant's lib directory
      to use this.
    </echo>
    <typedef resource="org/apache/rat/anttasks/antlib.xml" uri="antlib:rat.anttasks"/>
    <rat:report xmlns:rat="antlib:org.apache.rat.anttasks"
      reportFile="${build.dir}/rat-report.txt">
      <tarfileset>
        <gzipresource>
          <file file="${dist.dir}/${project.id}-src.tar.gz"/>
        </gzipresource>
      </tarfileset>
    </rat:report>
    <echo>Your RAT report is here: ${build.dir}/rat-report.txt</echo>
  </target>

  <!-- Prepare to use Maven Ant Tasks -->
  <target name="maven.prepare">
    <ant antfile="${basedir}/download.xml" target="build-download" />

    <path id="mvnantpath" path="${lib.dir}/maven-ant-tasks-${jar.maven.ant.version}.jar"/>
    <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
        uri="urn:maven-artifact-ant" classpathref="mvnantpath"/>

    <artifact:install-provider artifactId="wagon-ssh" version="${wagon-ssh.version}"/>
    <artifact:pom file="${maven.pom}" id="maven.project"/>
  </target>

  <!-- Install Maven Artifacts in local repo -->
  <target name="install" depends="maven.prepare,release" 
    description="Installs the Maven artifacts in local repository">

    <artifact:install file="${dist.dir}/${project.id}.jar" >
      <pom refid="maven.project"/>
      <attach file="${dist.dir}/${generic.id}.jar" type="jar" classifier="generic"/>
      <attach file="${dist.dir}/${view.id}.jar" type="jar" classifier="view"/>
      <attach file="${dist.dir}/${project.id}-src.jar" type="jar" classifier="sources"/>
      <attach file="${dist.dir}/${project.id}-javadoc.jar" type="jar" classifier="javadoc"/>
    </artifact:install>
  </target>

  <!-- Deploy Maven artifacts to custom remote repository -->
  <target name="deploy-custom" if="maven.remote.repository">
    <echo>Deploying to ${maven.remote.repository}</echo>
    <artifact:deploy file="${dist.dir}/${project.id}.jar" >
      <remoteRepository id="velocity.custom.repository" url="${maven.remote.repository}"/>
      <pom refid="maven.project"/>
      <attach file="${dist.dir}/${generic.id}.jar" type="jar" classifier="generic"/>
      <attach file="${dist.dir}/${view.id}.jar" type="jar" classifier="view"/>
      <attach file="${dist.dir}/${project.id}-src.jar" type="jar" classifier="sources"/>
      <attach file="${dist.dir}/${project.id}-javadoc.jar" type="jar" classifier="javadoc"/>
    </artifact:deploy>
  </target>

  <!-- Deploy Maven artifacts to Apache remote repository -->
  <target name="deploy-apache" unless="maven.remote.repository">
    <echo>Deploying to Apache Maven repository</echo>
    <artifact:deploy file="${dist.dir}/${project.id}.jar" >
      <pom refid="maven.project"/>
      <attach file="${dist.dir}/${generic.id}.jar" type="jar" classifier="generic"/>
      <attach file="${dist.dir}/${view.id}.jar" type="jar" classifier="view"/>
      <attach file="${dist.dir}/${project.id}-src.jar" type="jar" classifier="sources"/>
      <attach file="${dist.dir}/${project.id}-javadoc.jar" type="jar" classifier="javadoc"/>
    </artifact:deploy>
  </target>

  <!-- Deploy Maven artifacts to remote repository -->
  <target name="deploy" depends="maven.prepare,release,deploy-custom,deploy-apache"
    description="Deploys the Maven artifacts to configured repository">
  </target>


<!-- ========== Test Targets ======================================== -->

  <!-- Main test target -->
  <target name="test" description="Test VelocityTools" depends="test.generic,test.view">
  </target>

  <!-- Code Analysis targets -->
  <target name="findbugs" description="Run FindBugs" depends="jar">
    <ant antfile="${basedir}/test.xml" target="findbugs" />
  </target>

  <target name="pmd" description="Run PMD" depends="compile">
    <ant antfile="${basedir}/test.xml" target="pmd" />
  </target>

  <!-- Generic tests -->
  <target name="test.generic" description="Test GenericTools" depends="jar.view">
    <ant antfile="${basedir}/test.xml" target="test.generic" />
  </target>

  <!-- View tests -->
  <target name="test.view" description="Test VelocityView" depends="jar.view">
    <ant antfile="${basedir}/test.xml" target="test.view" />
  </target>

  <!-- View tests -->
  <target name="test.stop" description="Stop VelocityView Test">
    <ant antfile="${basedir}/test.xml" target="stop-showcase-webapp" />
  </target>
        
</project>
