<?xml version="1.0" encoding="UTF-8"?>
<!--
** This is a template build file for a JOSM  plugin.
**
** Maintaining versions
** ====================
** see README.template
**
** Usage
** =====
** To build it run
**
**    > ant  dist
**
** To install the generated plugin locally (in you default plugin directory) run
**
**    > ant  install
**
** The generated plugin jar is not automatically available in JOSMs plugin configuration
** dialog. You have to check it in first.
**
** Use the ant target 'publish' to check in the plugin and make it available to other
** JOSM users:
**    set the properties commit.message and plugin.main.version
** and run
**    > ant  publish
**
**
-->
<project name="smed_about" basedir=".">

	<!-- enter the SVN commit message -->
	<property name="commit.message" value="New release" />
	<!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
	<property name="plugin.main.version" value="3329" />

	<!-- Declaring	time-stamps-->
	<tstamp/>

	<!--
      ************************************************
      ** should not be necessary to change the following properties
     -->
	<property name="josm"                   location="../../core/dist/josm-custom.jar"/>
	<property name="smed"					location="../../dist/smed.jar/"/>
	<property name="plugin.build.dir"       value="build"/>
	<property name="plugin.src.dir"         value="src"/>
	<property name="smed.build.dir"         value="../smed/build"/>
	<property name="smed.src.dir"           value="../smed/src"/>
	<!-- this is the directory where the plugin jar is copied to -->
	<property name="ant.build.javac.target" value="1.5"/>
	<property name="plugin.dist.dir"        value="smed_dist"/>
	<property name="plugin.jar"             value="${plugin.dist.dir}/02_${DSTAMP}_${TSTAMP}_${ant.project.name}.jar"/>

	<!--
    **********************************************************
    ** init - initializes the build
    **********************************************************
    -->
	<target name="init">
		<mkdir dir="${plugin.build.dir}"/>
		<mkdir dir="${plugin.dist.dir}"/>
	</target>
	<!--
    **********************************************************
    ** init_smed - initializes the build of smed
    **********************************************************
    -->
	<target name="init_smed">
		<mkdir dir="${smed.build.dir}"/>
	</target>

	<!--
    **********************************************************
    ** compile_smed - compiles the source tree of smed
    **********************************************************
    -->
	<target name="compile_smed" depends="init_smed">
		<echo message="compiling sources for smed.jar ... "/>
		<javac srcdir="${smed.src.dir}" classpath="${josm}" debug="true" destdir="${smed.build.dir}">
			<compilerarg value="-Xlint:deprecation"/>
			<compilerarg value="-Xlint:unchecked"/>
		</javac>
	</target>

	<!--
    **********************************************************
    ** compile - complies the source tree
    **********************************************************
    -->
	<target name="compile" depends="init,dist_smed">
		<echo message="compiling sources for  ${plugin.jar} ... "/>
		<javac srcdir="src" classpath="${josm}:${smed}" debug="true" destdir="${plugin.build.dir}">
			<compilerarg value="-Xlint:deprecation"/>
			<compilerarg value="-Xlint:unchecked"/>
		</javac>
	</target>

	<!--
    **********************************************************
    ** dist_smed - creates smed.jar
    **********************************************************
    -->
	<target name="dist_smed" depends="compile_smed">
		<echo message="creating smed.jar ... "/>

		<copy todir="${smed.build.dir}/images">
			<fileset dir="${smed.src.dir}/images"/>
		</copy>
		
		<copy todir="${smed.build.dir}/images">
			<fileset dir="../smed/images"/>
		</copy>

		<copy todir="${smed.build.dir}/smed/msg">
			<fileset dir="${smed.src.dir}/smed/msg"/>
		</copy>

		<copy todir="${smed.build.dir}">
			<fileset dir="../smed">
                <include name="*.txt" />
			</fileset>
		</copy>

		<jar destfile="${smed}" basedir="${smed.build.dir}">
			<!--
        ************************************************
        ** configure these properties. Most of them will be copied to the plugins
        ** manifest file. Property values will also show up in the list available
        ** plugins: http://josm.openstreetmap.de/wiki/Plugins.
        **
        ************************************************
    -->
			<manifest>
				<attribute name="Author" value="Werner"/>
				<attribute name="Plugin-Class" value="smed.Smed"/>
				<attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
				<attribute name="Plugin-Description" value="Create and edit seamaps for OpenSeaMap"/>
				<attribute name="Plugin-Icon" value="images/Smed.png"/>
				<attribute name="Plugin-Link" value="http://openseamap.org/"/>
				<attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
				<attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
			</manifest>
		</jar>
	</target>

	<!--
    **********************************************************
    ** dist - creates the plugin jar
    **********************************************************
    -->
	<target name="dist" depends="compile">
		<echo message="creating ${ant.project.name}.jar ... "/>

        <copy todir="${plugin.build.dir}/images">
            <fileset dir="${plugin.src.dir}/images"/>
        </copy>

		<copy todir="${plugin.build.dir}/images">
			<fileset dir="images"/>
		</copy>
		<copy todir="${plugin.build.dir}/smed_ex/msg">
			<fileset dir="${plugin.src.dir}/smed_about/msg"/>
		</copy>
		<copy todir="${plugin.build.dir}">
			<fileset dir=".">
                <include name="copyright.txt" />
                <include name="LICENSE.txt" />
			</fileset>
		</copy>

		<delete>
			<fileset dir="${plugin.dist.dir}">
	    		<include name="*smed_about.jar"/>
			</fileset>
		</delete>

		
		<jar destfile="${plugin.jar}" basedir="${plugin.build.dir}">
			<!--
        ************************************************
        ** configure these properties. Most of them will be copied to the plugins
        ** manifest file. Property values will also show up in the list available
        ** plugins: http://josm.openstreetmap.de/wiki/Plugins.
        **
        ************************************************
    -->
			<manifest>
				<attribute name="Author" value="Werner"/>
				<attribute name="Plugin-Class" value="smed_ex.impl.SmedExImpl"/>
				<attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
				<attribute name="Plugin-Description" value="Plugin for Seamap Editor"/>
				<attribute name="Plugin-Icon" value="images/Smed.png"/>
				<attribute name="Plugin-Link" value="http://openseamap.org/"/>
				<attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
				<attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
				<attribute name="Class-Path" value="./tplug/ifc.jar"/>
			</manifest>
		</jar>
		
	</target>
	
	<!--
    **********************************************************
    ** clean - clean up the build environment
    **********************************************************
    -->
	<target name="clean">
		<delete dir="${smed.build.dir}"/>
		<delete file="${smed}"/>
		<delete>
			<fileset dir="${plugin.dist.dir}">
	    		<include name="*smed_about.jar"/>
			</fileset>
		</delete>

	</target>

	<!--
    **********************************************************
    ** install - install the plugin in your local JOSM installation
    **********************************************************
    -->
	<target name="install" depends="dist">
		<property environment="env"/>
		<condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins/splug/" else="${user.home}/.josm/plugins/splug/">
			<and>
				<os family="windows"/>
			</and>
		</condition>

		<delete>
			<fileset dir="${josm.plugins.dir}">
	    		<include name="*smed_about.jar"/>
			</fileset>
		</delete>
		<copy file="${plugin.jar}" todir="${josm.plugins.dir}"/>
	</target>

	
</project>