<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<project name="xmlimplsrc" basedir=".." default="compile">
  <!--
    Properties which affect this build file:

    no-e4x: Will cause E4X not to be built
  -->

  <property file="build.local.properties"/>
  <property file="build.properties"/>

  <!--
    Provide support for the old name for skipping E4X compilation, in case someone is still using it
  -->
  <condition property="no-e4x">
    <isset property="without-xmlimpl" />
  </condition>

  <target name="compile" unless="no-e4x">
    <antcall target="e4x-compile" />
    <antcall target="no-e4x-compile" />
  </target>

  <available property="jdk1.5?" classname="java.lang.ProcessBuilder" />

  <target name="e4x-compile" if="jdk1.5?">
    <javac
      srcdir="xmlimplsrc"
      destdir="${classes}"
      deprecation="on"
      debug="${debug}"
      includeAntRuntime="false"
      target="${target-jvm}"
      source="${source-level}"
    />
  </target>

  <target name="no-e4x-compile" unless="jdk1.5?">
    <echo>
      Skipping DOM E4X implementation; JDK 1.5+ currently required for compilation.
      <!--
        If the compiler is outfitted with DOM3 using the endorsed standards
        override mechanism, presumably the code could be built under 1.4.
        Not tested.
      -->
    </echo>
  </target>

  <target name="copy-source">
    <mkdir dir="${dist.dir}/xmlimplsrc"/>
    <copy todir="${dist.dir}/xmlimplsrc">
      <fileset dir="xmlimplsrc"
               includes="**/*.java,**/*.properties,**/*.xml"
      />
    </copy>
  </target>

  <target name="clean">
    <delete includeEmptyDirs="true">
      <fileset dir="${classes}"
               includes="org/mozilla/javascript/xmlimpl/**"
      />
    </delete>
  </target>
</project>
