<?xml version="1.0"?>
<project name="Processing PDE" default="build">

  <target name="clean" description="Clean the build directories">
    <delete dir="bin" />
    <delete file="pde.jar" />
  </target>

  <target name="compile" description="Compile sources">
    <condition property="core-built">
      <available file="../core/library/core.jar" />
    </condition>
    <fail unless="core-built" message="Please build the core library first and make sure it is located at ../core/library/core.jar" />

    <mkdir dir="bin" />
    
    <!-- copy languages files -->
    <copy todir="bin">
      <fileset dir="src">
        <include name="processing/app/languages/*.properties" />
      </fileset>
    </copy>
    
    <!-- in some cases, pde.jar was not getting built
	 https://github.com/processing/processing/issues/1792 -->
    <delete file="pde.jar" />

    <!-- env used to set classpath below -->
    <property environment="env" />

    <javac source="1.7"
	   target="1.7"
	   destdir="bin" 
	   excludes="**/tools/format/**" 
	   encoding="UTF-8" 
	   includeAntRuntime="false" 
	   classpath="../core/library/core.jar; 
                      ../core/apple.jar; 
                      lib/ant.jar; 
                      lib/ant-launcher.jar; 
                      lib/jna.jar"
	   debug="on"
	   nowarn="true"
	   compiler="org.eclipse.jdt.core.JDTCompilerAdapter">
      <src path="src" />
      <compilerclasspath path="../java/mode/org.eclipse.jdt.core.jar; 
                               ../java/mode/jdtCompilerAdapter.jar" />
    </javac>
  </target>

  <target name="build" depends="compile" description="Build PDE">
    <jar basedir="bin" destfile="pde.jar" />
  </target>
</project>
