<?xml version="1.0" encoding="utf-8"?>
<project name="geotools" default="dist" basedir=".">
    <!-- enter the SVN commit message -->
    <property name="commit.message" value="Commit message"/>
    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    <property name="plugin.main.version" value="10580"/>
    
    <property name="plugin.author" value="Don-vip"/>
    <property name="plugin.class" value="org.openstreetmap.josm.plugins.geotools.GeoToolsPlugin"/>
    <property name="plugin.description" value="Provides parts of the GeoTools library for other JOSM plugins. Not meant to be installed directly by users, but rather as a dependency for other plugins."/>
    <property name="plugin.icon" value="images/compass.png"/>
    <property name="plugin.canloadatruntime" value="true"/>
    <property name="plugin.requires" value="jts;ejml"/>
    <property name="plugin.stage" value="20"/>

    <!-- ** include targets that all plugins have in common ** -->
    <import file="../build-common.xml"/>

	<fileset id="plugin.requires.jars" dir="${plugin.dist.dir}">
        <include name="jts.jar"/>
        <include name="ejml.jar"/>
    </fileset>

    <target name="merge-geotools-services">
        <taskdef resource="org/pescuma/mergeservices/antlib.xml" classpath="tools/merge-services.jar" />
    	<delete dir="jar/META-INF/services"/>
    	<merge-services dest="jar">
    	    <fileset dir="lib">
    	        <include name="**/*.jar" />
    	        <exclude name="**/*-javadoc.jar" />
    	        <exclude name="**/*-source.jar" />
    	    </fileset>
    	</merge-services>
    </target>

    <!--
    **********************************************************
    ** post-dist - replaces files from the generated jar
    **********************************************************
    -->
    <target name="post-dist">
        <move file="${plugin.jar}" todir="${plugin.build.dir}" />
        <jar destfile="${plugin.jar}" filesetmanifest="merge" manifestencoding="UTF-8">
            <fileset dir="jar"/>
            <zipfileset src="${plugin.build.dir}/${ant.project.name}.jar">
                <exclude name="*.class"/>
                <exclude name="*.html"/>
                <exclude name="META-INF/**/*"/>
                <exclude name="javax/*.txt"/>
            </zipfileset>
            <zipfileset src="${plugin.build.dir}/${ant.project.name}.jar">
                <include name="META-INF/MANIFEST.MF"/>
                <include name="META-INF/javax.media.jai.registryFile.jai"/>
            </zipfileset>
        </jar>
        <delete file="${plugin.build.dir}/${ant.project.name}.jar" />
    </target>

    <!--
    **********************************************************
    ** additional-manifest - add additional manifest entries 
    **********************************************************
    -->
    <target name="additional-manifest">
        <manifest file="MANIFEST" mode="update">
        	<!-- JAI requires a vendor name for some of its deep internals, 
        	     see http://stackoverflow.com/a/18495658/2257172 -->
            <attribute name="Specification-Title" value="JOSM GeoTools plugin"/>
            <attribute name="Specification-Version" value="15.1"/>
            <attribute name="Specification-Vendor" value="JOSM developers" />
            <attribute name="Implementation-Title" value="org.openstreetmap.josm.plugins.geotools" />
            <attribute name="Implementation-Version" value="15.1" />
            <attribute name="Implementation-Vendor" value="JOSM developers"/>
        </manifest>
    </target>
</project>
