<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  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.  For additional information regarding
copyright in this work, please see the NOTICE file in the top level
directory of this distribution.
-->
<project xmlns:ivy='antlib:fr.jayasoft.ivy.ant'
         name='speedyfeed-servlet'
         default='compile'>
  <property name='debug' value='true'/>

  <property name='src' value='src/main/java'/>
  <property name='src.target' value='src/main/target'/>
  <property name='src.classes' value='${src.target}/classes'/>

  <property name='test.src' value='src/test/java'/>
  <property name='test.src.resources' value='src/test/resources'/>
  <property name='test.src.target' value='src/test/target'/>
  <property name='test.src.classes' value='${test.src.target}/classes'/>

  <path id='dependencies'>
    <fileset dir='lib' includes="**/*.jar"/>
  </path>

  <!-- Start junk for bootstrapping ivy... -->
  <condition property="ivy.home" value="${env.IVY_HOME}">
    <isset property="env.IVY_HOME" />
  </condition>

  <property name="ivy.home" value="${user.home}/.ivy"/>
  <property name="ivy.jar.dir" value="${ivy.home}/jars"/>
  <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
  <property name="ivy.install.version" value="1.4.1"/>

  <target name="download-ivy" unless="offline">
    <mkdir dir="${ivy.jar.dir}"/>

    <get src="http://www.jayasoft.org/downloads/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
         dest="${ivy.jar.file}"
         usetimestamp="true"/>
  </target>
	
  <target name="init-ivy" depends="download-ivy">
    <path id="ivy.lib.path">
      <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
    </path>

    <taskdef resource="fr/jayasoft/ivy/ant/antlib.xml"
             uri="antlib:fr.jayasoft.ivy.ant"
             classpathref="ivy.lib.path"/>
  </target>
  <!-- End junk for bootstrapping ivy... -->

  <target name='resolve'
          depends='init-ivy'
          description='retrive dependencies via ivy'>
    <ivy:retrieve/>
  </target>

  <target name='clean'
          description='delete compiled artifacts'>
    <delete dir='${src.target}'/>
    <delete dir='${test.src.target}'/>
  </target>

  <target name='extraclean'
          depends='clean'
          description='delete compiled artifacts and dependencies'>
    <delete dir='lib'/>
  </target>

  <target name='compile'
          depends='resolve'
          description='build the servlet'>
    <mkdir dir='${src.classes}'/>

    <javac srcdir="${src}"
           debug="${debug}"
           destdir="${src.classes}"
           classpathref="dependencies"
           />

    <mkdir dir='${test.src.classes}'/>

    <javac srcdir="${test.src}"
           debug="${debug}"
           destdir="${test.src.classes}"
           classpathref="dependencies"
           classpath="${src.classes}"
           />
    <copy todir="${test.src.classes}">
      <fileset dir="${test.src.resources}" includes="**/*" />
    </copy>
  </target>

  <target name='test'
          depends='compile'
          description='run the tests'>
    <java classpathref='dependencies'
          classpath="${src.classes}:${test.src.classes}"
          classname='org.apache.speedyfeed.test.TestSuite'
          fork='yes'
          />
  </target>
</project>
