<project name="common">
    <!-- This file contains scriptdefs, properties, targets, etc that are common
         to both build.xml and tests/build.xml. It also loads ant-contrib, where
         each desired task needs to be defined below as both ant-contrib and
         Android's anttasks.jar define different 'if' tasks. -->


    <!-- ANT-CONTRIB -->

    <!-- jar file from where the tasks are loaded -->
    <if>
        <condition>
            <isset property="tested.project.dir" />
        </condition>
        <then>
            <path id="antcontrib">
                <pathelement path="${tested.project.dir}/tools/ant-contrib.jar" />
            </path>
        </then>
        <else>
            <path id="antcontrib">
                <pathelement path="tools/ant-contrib.jar" />
            </path>
        </else>
    </if>

    <!-- ant-contrib tasks -->
    <!-- this is normally named propertyregex -->
    <taskdef name="regex"
            classname="net.sf.antcontrib.property.RegexTask"
            classpathref="antcontrib" />
    <taskdef name="math"
            classname="net.sf.antcontrib.math.MathTask"
            classpathref="antcontrib" />
    <taskdef name="runtarget"
            classname="net.sf.antcontrib.logic.RunTargetTask"
            classpathref="antcontrib" />
    <taskdef name="var"
            classname="net.sf.antcontrib.property.Variable"
            classpathref="antcontrib" />
    <!-- renamed to not conflict with android -->
    <taskdef name="if.contrib"
            classname="net.sf.antcontrib.logic.IfTask"
            classpathref="antcontrib" />


    <!-- SCRIPTDEFS -->


    <!-- PROPERTIES -->

    <!-- allow environment variables to be accessable by prepending "env." -->
    <property environment="env" />

    <!-- javadoc folder relative to ${basedir} -->
    <property name="javadoc-dir" location="javadoc" />

    <!-- path to lint -->
    <property name="lint" location="${android.tools.dir}/lint${bat}" />


    <!-- TARGETS -->

    <!-- create javadoc in ${javadoc-dir} -->
    <target name="javadoc" description="build javadoc">
        <mkdir dir="${javadoc-dir}"/>
        <javadoc
            destdir="${javadoc-dir}"
            doctitle="K-9 Mail"
            verbose="on"
            use="true"
            classpath="${env.ANDROID_HOME}/platforms/${target}/android.jar"
            sourcepath="gen;src"
            linkoffline="http://d.android.com/reference ${env.ANDROID_HOME}/docs/reference/"
        />
    </target>

    <!-- create lint-results.xml -->
    <target name="lint-xml">
        <exec executable="${lint}" failonerror="true">
            <arg value="--xml" />
            <arg value="lint-results.xml" />
            <arg path="${basedir}" />
        </exec>
    </target>

    <!-- create lint-results.html and lint-results_files/ -->
    <target name="lint-html">
        <exec executable="${lint}" failonerror="true">
            <arg value="--html" />
            <arg value="lint-results.html" />
            <arg path="${basedir}" />
        </exec>
    </target>

</project>
