<!--
	$Id: build.xml,v 1.1 2008/10/25 10:22:34 robinrowe Exp $

	Need to do:
	- Add Javah task to output the JNI header file
	- Split out the plug-in build files and add as sub-projects to this one
	- Separate builds for jython, without jython... Should be selectable
	  via configure script switch...
-->
<project name="JGimp" default="all" basedir=".">
	<description>
		JGimp's Ant build file to build the Java portion of JGimp
	</description>

<!--
	<property name="GIMP_install_dir"              location="D:\Program Files\GIMP"/>
	<property name="GIMP_version_number"           value="1.2"/>
	<property name="GIMP_lib_dir"                  value="${GIMP_install_dir}/lib/gimp/${GIMP_version_number}"/>
	<property name="GIMP_jarfile_extension_dir"    value="${GIMP_lib_dir}/jar_files/extensions"/>
	<property name="GIMP_jarfile_plugins_dir"      value="${GIMP_lib_dir}/jar_files/plugins"/>
-->
	<!-- Our directories -->
	<property name="src_dir"                       location="."                          />
    <property name="ant_ext_dir"                   location="./ant_extension"            />
	<property name="output_dir"                    location="output"                     />
	<property name="jgimp_output_dir"              location="${output_dir}/jgimp"        />
	<property name="jython_output_dir"             location="${output_dir}/jython"       />
	<property name="desaturate_output_dir"         location="${output_dir}/desaturate"   />
	<property name="image_divider_output_dir"      location="${output_dir}/image_divider"/>
	<property name="dist_dir"                      location="dist"                       />
	<property name="docs_dir"                      location="dist/javadoc"               />

	<!-- Our jar file names -->
	<property name="JGimp_jarfile_name"                 value="jgimp.jar"/>

    <!-- Build and define the custom ant-task to build the constants file -->
    <target
      name="build-jgimp-ant-task"
      description="Makes the custom ant task used to generate the C constants file.">
        <mkdir dir="${ant_ext_dir}"/>
        <javac
          deprecation="on"
          srcdir="${src_dir}"
          destdir="${ant_ext_dir}"
          excludes="edu/**, org/gimp/jgimp/*java, org/gimp/jgimp/extension/**, org/gimp/jgimp/jython/**, org/gimp/jgimp/nativewrappers/**, org/gimp/jgimp/paint/**, org/gimp/jgimp/pdb/**, org/gimp/jgimp/plugin/**, org/gimp/jgimp/proxy/**, org/gimp/jgimp/utils/**"
          includes="org/gimp/jgimp/ant/*java"/>
    </target>
    <target name="declare_custom_ant_task" depends="build-jgimp-ant-task">
        <taskdef
          name="generate_constants"
          classname="org.gimp.jgimp.ant.JGimpCConstantsTask"
          classpath="${ant_ext_dir}"/>
    </target>

	<!-- Targets to compile the source -->
	<target
	  name="compile_jgimp"
      depends="declare_custom_ant_task">
	    <mkdir dir="${jgimp_output_dir}"/>
	    <javac
          deprecation="on"
		  srcdir="${src_dir}"
		  destdir="${jgimp_output_dir}"
	      excludes="edu/**, org/gimp/jgimp/jython/**, org/gimp/jgimp/proxy/JGimpExtendedProxyImpl.java"/>
		<javah
		  class="org.gimp.jgimp.proxy.JGimpPlugInProxy"
	      classpath="${jgimp_output_dir}:"
	      outputFile="../JGimpPlugInProxy.h"
		/>
        <generate_constants/>
	</target>
	
	<target
	 name="jython_support"
	 depends="compile_jgimp, make_dist_dir">
	    <mkdir dir="${jython_output_dir}"/>
		<javac
          deprecation="on"
		  srcdir="${src_dir}"
		  destdir="${jython_output_dir}"
	      classpath="${jgimp_output_dir}:."
	      includes="org/gimp/jgimp/jython/*.java"/>
	    <jar destfile="${dist_dir}/jython_extension.jar" basedir="${jython_output_dir}"/>
	</target>

	<target
	  name="make_dist_dir">
		<tstamp/>
		<mkdir dir="${dist_dir}"/>
	</target>
	
	<!-- The targets to make the jar files -->
	<target
	  name="jgimp"
	  depends="compile_jgimp, make_dist_dir"
	  description="Creates the jgimp.jar library, without jython support">
	    <jar destfile="${dist_dir}/${JGimp_jarfile_name}" basedir="${jgimp_output_dir}"/>
	</target>

	<target
	  name="desaturate"
	  depends="compile_jgimp, make_dist_dir">
	    <mkdir dir="${desaturate_output_dir}"/>
	    <javac
          deprecation="on"
		  srcdir="${src_dir}"
		  destdir="${desaturate_output_dir}"
	      classpath="${jgimp_output_dir}:."
	      includes="edu/gatech/cc/mterry/plugin/DesaturatePlugIn.java"/>
	    <jar destfile="${dist_dir}/desaturate.jar" basedir="${desaturate_output_dir}"/>
	</target>

	<target
	  name="image_divider"
	  depends="compile_jgimp, make_dist_dir">
	    <mkdir dir="${image_divider_output_dir}"/>
	    <javac
          deprecation="on"
		  srcdir="${src_dir}"
		  destdir="${image_divider_output_dir}"
	      classpath="${jgimp_output_dir}:."
	      includes="edu/gatech/cc/mterry/plugin/ImageDividerPlugIn.java"/>
	    <jar destfile="${dist_dir}/image_divider.jar" basedir="${image_divider_output_dir}"/>
	</target>
	
	<target
	  name="all"
	  depends="jgimp, desaturate, image_divider"
	  description="Creates JGimp library plus sample plug-ins, without jython support. Output placed in the dist directory."/>

	<target
	  name="all-jython"
	  depends="jython_support, jgimp, desaturate, image_divider"
	  description="Creates JGimp library plus sample plug-ins, WITH jython support. Output placed in the dist directory."/>
	  
<!--
	<target
	  name="install"
	  depends="all"
	  description="Makes and installs the jar files to the GIMP's directory">
	    <mkdir dir="${GIMP_jarfile_extension_dir}"/>
	    <mkdir dir="${GIMP_jarfile_plugins_dir}"/>
		<copy file="${dist_dir}/${JGimp_jarfile_name}" toDir="${GIMP_jarfile_extension_dir}"/>
		<copy file="${dist_dir}/${desaturate_plugin_jarfile_filename}" toDir="${GIMP_jarfile_plugins_dir}"/>
		<copy file="${dist_dir}/${image_divider_plugin_jarfile_name}" toDir="${GIMP_jarfile_plugins_dir}"/>
	</target>
-->
	
	<target
	  name="clean"
	  description="Removes all outputed files">
	    <delete>
	        <fileset dir="${output_dir}" includes="**/*.class,**/*.jar"/>
			<fileset dir="${dist_dir}" includes="**/*.jar, **/*.class"/>
			<fileset dir="${ant_ext_dir}" includes="**/*.jar, **/*.class"/>
	    </delete>
		<delete file="../JGimpPlugInProxy.h"/>
		<delete file="../jgimp_constants.h"/>
		<delete dir="${docs_dir}"/>
	</target>

	<target
	  name="cleanall"
	  description="Completely removes all output from this build"
	  depends="clean">
	    <delete dir="${output_dir}"/>
		<delete dir="${dist_dir}"/>
	</target>
	
	<target
	  name="javadocs"
	  description="Generates the javadocs for the source">
	  <mkdir dir="${docs_dir}"/>
	  <javadoc
	    sourcepath="${src_dir}"
	    packagenames="org.gimp.jgimp.*"
	    destdir="${docs_dir}">
	    <tag name="pdb" description="GIMP PDB command(s) called:"/>
	    </javadoc>
	</target>
	
</project>
