<?xml version="1.0" encoding="UTF-8"?>
<project name="iscwt" default="jar" basedir=".">
    <description>
        This is a window toolkit and basic rendering abstraction layer
    </description>
  
  <!-- set global properties for this build -->
  <property name="user.name" value="intarsys consulting GmbH"/>
  <property name="iscwt.src.dir" location="src"/>
  <property name="iscwt.resource.dir" location="resource"/>
  
  <target name="init">
  	<property file="build.properties" />

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

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

    <!-- Compile the java code -->
    <javac compiler="javac1.4" target="1.4" source="1.4" srcdir="${iscwt.src.dir}" destdir="${iscwt.build.dir}" debug="true">
    	<classpath refid="iscwt.classpath"/>
    </javac>
  </target>
	
  <target name="jar" depends="compile" description="generate the distribution" >

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

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


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

</project>