<?xml version="1.0" encoding="UTF-8"?>
<project name="isnativec" default="jar" basedir=".">
    <description>
        This is a generic native code wrapper
    </description>
  
  <!-- set global properties for this build -->
  <property name="user.name" value="intarsys consulting GmbH"/>
  <property name="isnativec.src.dir" location="src"/>
  <property name="isnativec.resource.dir" location="resource"/>
  
  <target name="init">
  	<property file="build.properties" />

	<property name="isnativec.build.root" location="${build.dir}/isnativec"/>
  	<property name="isnativec.build.dir" location="${isnativec.build.root}/build"/>
    <property name="isnativec.dist.dir"  location="${isnativec.build.root}/dist"/>  	
    <property name="isnativec.javadoc.dir"  location="${isnativec.build.root}/javadoc"/>

  </target>
	
	<target name="make-structure" depends="init">  	
	    <!-- Create the build directory structure used by compile -->
	    <mkdir dir="${isnativec.build.dir}"/>
	  	<mkdir dir="${isnativec.dist.dir}"/>
	    <mkdir dir="${isnativec.javadoc.dir}"/>
	</target>
	
	<target name="clean" depends="init" description="clean up" >
	    <!-- Delete the ${dist} directory trees -->
	    <delete dir="${isnativec.javadoc.dir}"/>
	    <delete dir="${isnativec.dist.dir}"/>
	    <delete dir="${isnativec.build.dir}"/>
	</target>
	
  <target name="compile" depends="make-structure" description="isnativec compile" >
    <!-- Construct classpath -->
    <path id="isnativec.classpath">
	 	<fileset dir="${libs.dir}">
	        <include name="**/${isrt.jar.name}.jar"/>
	        <include name="**/${jna.jar.name}.jar"/>
	        <include name="**/${jna.platform.jar.name}.jar"/>
	    </fileset>
    	<pathelement path="${isnativec.build.dir}"/>
    </path>

    <!-- Compile the java code -->
    <javac compiler="javac1.7" target="1.7" source="1.7" srcdir="${isnativec.src.dir}" destdir="${isnativec.build.dir}" debug="true" encoding="iso-8859-1">
    	<classpath refid="isnativec.classpath"/>
    </javac>
  </target>
	
  <target name="jar" depends="compile" description="generate the distribution" >

    <jar jarfile="${isnativec.dist.dir}/${isnativec.jar.name}.jar" basedir="${isnativec.build.dir}">
	    <manifest>
			<attribute name="Built-By" value="${user.name}"/>
			<attribute name="Main-Class" value=""/>
		    <attribute name="Class-Path" value="${isrt.jar.name}.jar ${jna.jar.name}.jar"/>
	    </manifest>
	    <fileset dir="${isnativec.resource.dir}">
        <include name="**/*"/>
    </fileset>
    </jar>
    
  </target>

  <!-- Javadoc -->
  <target name="javadoc" depends="make-structure">
    <javadoc
      packagenames="de.intarsys.nativec.*"
      sourcepath="${isnativec.src.dir}"
      destdir="${isnativec.javadoc.dir}"
      author="true"
      version="true"
      use="true"
      windowtitle="nativec API"
      doctitle="nativec API" >
    <classpath refid="isnativec.classpath"/>
    </javadoc>
  </target>


  
  <target name="buildZipSrcPackage" depends="javadoc" description="generate build sources zip package" >
    <zip destfile="${isnativec.dist.dir}/${isnativec.jar.name}-build-src.zip">
		<fileset dir="..">
	    	<include name="isnativec/src/**/*"/>
    	</fileset>
		<fileset dir="${build.dir}">
	    	<include name="isnativec/javadoc/**/*.*"/>
    	</fileset>
    	<fileset dir="..">
    		<include name="isnativec/ant/**/*.*"/>
    	</fileset>
     </zip>
  </target>

</project>