<project name="osmarender" default="install" 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="josm" location="../../core/dist/josm-custom.jar" />
  <property name="stylesheets" location="./stylesheets" />
  <property name="xslt" location="./xslt" />
  <property name="ant.build.javac.target" value="1.5"/>

  <target name="compile">
    <echo message="creating ${plugin.jar}"/>
    <mkdir dir="${plugin.build.dir}"></mkdir>
    <mkdir dir="${plugin.dist.dir}"></mkdir>
    <javac srcdir="src" debug="true" classpath="${josm}" destdir="${plugin.build.dir}">
      <include name="**/*.java" />
    </javac>
  </target>

  <target name="dist"  depends="compile">
    <copy todir="${plugin.build.dir}" file="${xslt}/osmarender.xsl"/>
    <copy tofile="${plugin.build.dir}/osm-map-features.xml"
	  file="${stylesheets}/osm-map-features-z17.xml"/>
    <exec append="false" output="REVISION" executable="perl" failifexecutionfails="false">
      <env key="LANG" value="C"/>
      <arg value="../getrevision.pl"/>
      <arg value="xslt"/>
      <arg value="stylesheets"/>
    </exec>
    <xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/>
    <delete file="REVISION"/>
    <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
      <manifest>
	<attribute name="Plugin-Class" value="OsmarenderPlugin" />
	<attribute name="Plugin-Description" value="Launches FireFox to display the current visible screen as a nice SVG image" />
	<attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
	<attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
      </manifest>
    </jar>
  </target>

  <target name="clean">
    <delete dir="${plugin.build.dir}" />
    <delete file="${plugin.jar}" />
  </target>

  <target name="install" depends="compile,dist">
    <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
  </target>  

</project>
