<!-- version: $Id: build-common.xml,v 1.5 2005/05/11 16:14:37 nthx Exp $ -->

   | Each target in main buildfile should depend on this one
<target name="common:init"
                 common:resources" />

<target name="common:read_params">
    <property file="build.properties"/>

    <path id="run_classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
        <pathelement path="${build.classes.dir}" />

    <taskdef name="annotationc" classname="org.jboss.aop.ant.AnnotationC"
    <taskdef name="aopc" classname="org.jboss.aop.ant.AopC"
    classpathref="run_classpath" />

    <available property="junit.present" classname="junit.framework.TestCase" />

   | JUnit & ANT - a try to solve problem magically
<target name="junit-check">
    Every target using JUnit tests REQUIRES `junit.jar' in your ANT_HOME/lib
    This script will try to automatically handle the problem.
    If it fails, copy `junit.jar' into your ANT_HOME/lib.

    If it fails all the time you're probably running inside IDE. Check docs how
    to solve problem with Eclipse, IDEA (problems.html).
    <antcall target="junit-check-copy" />

<target name="junit-check-copy" depends="common:read_params"
        unless="junit.present" if="ant.home">
    <!-- solve great problem of Ant and JUnit - two most popular tools of
    development. Come on people! -->
    <copy todir="${ant.home}/lib" file="${lib.dir}/junit.jar" />
    <fail message="It's OK to fail Ant 1st time.." />

<target name="common:prepare" depends="common:read_params">
    <!-- create necessary directories -->
    <mkdir dir="${build.dir}" />
    <mkdir dir="${build.classes.dir}" />

    <!-- directories for all databases used by Ant targets -->
    <mkdir dir="${repository.dir}/tests" />
    <mkdir dir="${repository.dir}/demo" />
    <mkdir dir="${repository.dir}/skeleton-app" />
    <mkdir dir="${repository.dir}/performance" />

   | Other helpful targets...
<target name="common:resources" depends="common:read_params">
    <copy todir="${build.classes.dir}" includeEmptyDirs="no">
        <fileset dir="${etc.dir}">
                <include name="*.properties" />
                <include name="*.xml" />

<target name="clean" depends="common:read_params"
        description="Cleans ${build.classes.dir}">
    <delete dir="${build.classes.dir}" />
    <delete dir="${dist.dir}" />