<project name="surveyor" default="dist" basedir=".">
<!-- josm "user home" directory depends on the platform used (windows has a different place than unix/linux) -->
    <property environment="env"/>
    <condition property="josm.home.dir" value="${env.APPDATA}/JOSM" else="${user.home}/.josm">
        <and>
            <os family="windows"/>
        </and>
    </condition>
<!-- compilation properties -->
    <property name="josm.build.dir"   value="../../core"/>
    <property name="josm.plugins.dir" value="${josm.home.dir}/plugins"/>
    <property name="josm"         location="../../core/dist/josm-custom.jar" />
    <property name="plugin.build.dir" value="build"/>
    <property name="plugin.dist.dir"  value="../../dist"/>
    <property name="plugin.name"      value="${ant.project.name}"/>
    <property name="plugin.jar"       value="../../dist/${plugin.name}.jar"/>
    <property name="livegpsplugin.jar" value="../../dist/livegps.jar"/>
    <property name="plugin.description" value="Allow adding markers/nodes on current gps positions."/>
    <property name="plugin.stage" value="60"/>
    <property name="plugin.class" value="at.dallermassl.josm.plugin.surveyor.SurveyorPlugin"/>
    <property name="ant.build.javac.target" value="1.5"/>
    <target name="dist" depends="compile">
        <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
            <env key="LANG" value="C"/>
            <arg value="info"/>
            <arg value="--xml"/>
            <arg value="."/>
        </exec>
        <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
        <delete file="REVISION"/>
<!-- images -->
        <copy todir="${plugin.build.dir}/">
            <fileset dir="resources">
                <include name="*.xml"/>
                <include name="audio/*"/>
            </fileset>
        </copy>
<!-- create jar file -->
        <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
            <manifest>
                <attribute name="Plugin-Class" value="${plugin.class}" />
                <attribute name="Plugin-Description" value="${plugin.description}" />
                <attribute name="Plugin-Stage" value="${plugin.stage}" />
                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
                <attribute name="Plugin-Mainversion" value="1180" />
            </manifest>
        </jar>
    </target>
    <target name="compile" depends="init">
        <echo message="creating ${plugin.jar}"/>
        <mkdir dir="${plugin.build.dir}"/>
        <copy todir="build/images" >
            <fileset dir="images" />
        </copy>
        <javac srcdir="src" destdir="${plugin.build.dir}" debug="true" source="1.5" target="1.5">
            <compilerarg value="-Xlint:deprecation"/>
            <compilerarg value="-Xlint:unchecked"/>
            <classpath>
                <pathelement path="${josm.build.dir}/build"/>
                <fileset dir="${josm.build.dir}/lib">
                    <include name="**/*.jar"/>
                </fileset>
                <pathelement location="${livegpsplugin.jar}"/>
            </classpath>
        </javac>
    </target>
    <target name="install" depends="dist">
        <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
    </target>
    <target name="init">
        <echo>java version: ${java.version}</echo>
    </target>
    <target name="clean">
        <delete dir="${plugin.build.dir}" />
        <delete file="${plugin.jar}" />
    </target>
</project>
