<!--

   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

-->
<!--


              A p a c h e   B a t i k   B u i l d   S y s t e m



Build Tools
..............................................................................

The Batik build system is based on Apache Ant, which is a Java building tool
used in Apache projects.
For more information refer to <http://ant.apache.org/>.

The distribution contains a precompiled version of Ant.

The only thing that you have to make sure, is that the "JAVA_HOME" environment
property should be set to match the JVM you want to use. 

If you are going to be doing development you may want to create a file
called 'build.properties' with the line 'debug=on' in it.  This will 
turn on the generation of debugging information when compiling Batik.

Building Instructions
..............................................................................

First, make sure your current working directory is where this file is located.
Then type:

  [unix]  ant compile
  [win32] .\build.bat compile

This action will compile the sources to the 'classes' directory.

You can now launch the SVG browser by typing:

  [unix]  ant squiggle
  [win32] .\build.bat squiggle


Build Targets
..............................................................................

To display the available targets type:

  [unix]  ant help
  [win32] .\build.bat help

 
 $Id: build.xml 1904071 2022-09-14 11:08:42Z ssteiner $

-->

<project default="help" name="batik" basedir=".">

  <!-- Configuring the build -->
  <property environment="env"/>
  <property file="${basedir}/build-local.properties"/>
  <property file="${basedir}/build.properties"/>

  <!-- Initializations .................................................... -->
  <target name="init">
    <tstamp>
      <format property="ts" pattern="yyyyMMdd-HHmmss-z"/>
    </tstamp>
    <property name="Project"            value="Apache Batik" />
    <property name="project"            value="batik" />
    <property name="year"               value="2022" />
    <property name="version"            value="1.15" />
    <property name="revisionType"       value="" />
    <property name="revisionNumber"     value="" />
    <property name="completeVersion"    value="${version}${revisionType}${revisionNumber}" />
    <property name="xgcVersion"         value="2.7" />
    <property name="fopVersion"         value="2.7" />
    <property name="vendor"             value="The Apache Software Foundation (http://xmlgraphics.apache.org/batik/)" />
    <property name="debug"              value="on"/>
    <property name="optimize"           value="on"/>
    <property name="deprecation"        value="on"/>
    <property name="javac.source" value="1.7"/>
    <property name="javac.target" value="1.7"/>
    <property name="src"                value="sources"/>
    <property name="src-internal-codec" value="sources-internal-codec"/>
    <property name="resources"          value="resources"/>
    <property name="testsrc"            value="batik-test-old/src/test/java"/>
    <property name="testresources"      value="test-resources"/>
    <property name="dest"               value="classes"/>
    <property name="dest-internal-codec" value="classes-internal-codec"/>
    <property name="build"              value="${project}-${completeVersion}"/>
    <property name="build.id"           value="${ts} (${user.name} [${os.name} ${os.version} ${os.arch}, Java ${java.runtime.version}])"/>
    <property name="docs"               value="${build}/docs"/>
    <property name="forrest-build"      value="${build}/forrest"/>
    <property name="app"                value="${build}/Squiggle.app"/>
    <property name="dmg"                value="${build}/Squiggle-${completeVersion}.dmg"/>
    <property name="lib"                value="lib"/>
    <property name="samples"            value="samples"/>
    <property name="package-prefix"     value="org/apache/${project}"/>
  
    <property name="class-prefix"       value="org.apache.${project}"/>
  
    <property name="dom.javadoc"        value="http://www.w3.org/2003/01/dom2-javadoc/"/>
    <property name="jdk.javadoc"        value="http://docs.oracle.com/javase/7/docs/api/"/>
    <property name="rhino.javadoc"      value="http://www.mozilla.org/rhino/apidocs/"/>
  
    <property name="site"               value="site"/>
  
    <property name="test-reports"       value="test-reports"/>
    <property name="test-references"    value="test-references"/>
    <property name="test-resources"     value="test-resources"/>
  
    <!-- For site deployment -->
    <property name="deploy.svn.url"     value="https://svn.apache.org/repos/asf/xmlgraphics/site/deploy/batik"/>
    <property name="build.site-dir"     value="${site}"/>
    
    <path id="source.files">
        <pathelement path="batik-anim/src/main/java"/>
        <pathelement path="batik-awt-util/src/main/java"/>
        <pathelement path="batik-bridge/src/main/java"/>
        <pathelement path="batik-codec/src/main/java"/>
        <pathelement path="batik-constants/src/main/java"/>
        <pathelement path="batik-css/src/main/java"/>
        <pathelement path="batik-dom/src/main/java"/>
        <pathelement path="batik-ext/src/main/java"/>
        <pathelement path="batik-extension/src/main/java"/>
        <pathelement path="batik-gui-util/src/main/java"/>
        <pathelement path="batik-gvt/src/main/java"/>
        <pathelement path="batik-i18n/src/main/java"/>
        <pathelement path="batik-parser/src/main/java"/>
        <pathelement path="batik-rasterizer/src/main/java"/>
        <pathelement path="batik-rasterizer-ext/src/main/java"/>
        <pathelement path="batik-script/src/main/java"/>
        <pathelement path="batik-slideshow/src/main/java"/>
        <pathelement path="batik-squiggle/src/main/java"/>
        <pathelement path="batik-svg-dom/src/main/java"/>
        <pathelement path="batik-svgbrowser/src/main/java"/>
        <pathelement path="batik-svggen/src/main/java"/>
        <pathelement path="batik-svgpp/src/main/java"/>
        <pathelement path="batik-svgrasterizer/src/main/java"/>
        <pathelement path="batik-swing/src/main/java"/>
        <pathelement path="batik-transcoder/src/main/java"/>
        <pathelement path="batik-ttf2svg/src/main/java"/>
        <pathelement path="batik-util/src/main/java"/>
        <pathelement path="batik-xml/src/main/java"/>
    </path>
  
    <pathconvert property="cwd">
      <path path="."/>
    </pathconvert>
  
    <path id="libs-classpath">
      <fileset dir="lib">
        <include name="*.jar"/>
      </fileset>
    </path>
  
    <path id="libs-build-classpath">
      <fileset dir="lib/build">
        <include name="stylebook*.jar"/>
      </fileset>
      <fileset dir="lib">
        <include name="xalan*.jar"/>
        <include name="xerces*.jar"/>
        <include name="xml-apis-1.3.04.jar"/>
        <include name="xml-apis-ext-1.3.04.jar"/>
        <include name="serializer-2.7.2.jar"/>
        <include name="xmlgraphics-commons*.jar"/>
      </fileset>
    </path>
  
    <available property="rhino.present" classname="org.mozilla.javascript.Context">
      <classpath refid="libs-classpath"/>
    </available>
    <available property="jpython.present" classname="org.python.util.PythonInterpreter">
      <classpath refid="libs-classpath"/>
    </available>
    <available property="jacl.present" classname="tcl.lang.Interp">
      <classpath refid="libs-classpath"/>
    </available>
    
    <!-- When compiling Batik under GNU Classpath, the Sun codecs are not available. -->
    <condition property="sun-codecs.present">
      <and>
        <available classname="com.sun.image.codec.jpeg.JPEGCodec" 
                   classpathref="libs-classpath"/>
        <!-- This became quite tricky in JDK 7, as the Sun codecs were "retired"
             (they are available in run-time although the "classes are not located when compiling")
             http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6527962 -->
        <not>
            <and>
                <equals arg1="${java.specification.vendor}" arg2="Oracle Corporation"/>
                <or>
                    <!-- According to Sun issue 6527962, the classes are to be completely removed in JDK 8
                         (so there should be no need to extend this list any longer) -->
                    <equals arg1="${java.specification.version}" arg2="1.7"/>
                    <equals arg1="${java.specification.version}" arg2="1.8"/>
                </or>
            </and>
        </not>
        <not>
          <equals arg1="${sun-codecs.disabled}" arg2="true"/>
        </not>
      </and>
    </condition>

    <condition property="javadoc-exclusion-rhino"
               value="org.apache.batik.script.rhino">
      <not>
        <equals arg1="${rhino.present}" arg2="true"/>
      </not>
    </condition>
    <condition property="javadoc-exclusion-jpython"
               value="org.apache.batik.script.jpython">
      <not>
        <equals arg1="${jpython.present}" arg2="true"/>
      </not>
    </condition>
    <condition property="javadoc-exclusion-jacl"
               value="org.apache.batik.script.jacl">
      <not>
        <equals arg1="${jacl.present}" arg2="true"/>
      </not>
    </condition>
  
    <property name="javadoc-exclusions"
              value="${javadoc-exclusion-rhino},${javadoc-exclusion-jpython},${javadoc-exclusion-jacl}"/>
  
    <uptodate property="IWasLoadedUpToDate" 
     targetfile="${testresources}/org/apache/batik/bridge/IWasLoaded.jar">
     <srcfiles dir="${testresources}/org/apache/batik/bridge"
               includes="IWasLoaded.java"/>
    </uptodate>
  
    <uptodate property="IWasLoadedTooUpToDate" 
     targetfile="${testresources}/org/apache/batik/bridge/IWasLoadedToo.jar">
     <srcfiles dir="${testresources}/org/apache/batik/bridge"
               includes="IWasLoadedToo.java"/>
    </uptodate>
  
    <condition property="forrest.call" value="cmd" else="${env.FORREST_HOME}/bin/forrest">
      <os family="windows"/>
    </condition>
  
    <condition property="forrest.args" value="/c &quot;${env.FORREST_HOME}\bin\forrest.bat&quot;" else="">
      <os family="windows"/>
    </condition>
  
    <!-- Info ............................................................... -->
    <echo message=" == ${Project} ${completeVersion} build file ================================"/>
    <echo message=""/>
    <echo message="    JAVA_HOME: ${env.JAVA_HOME}"/>
    <echo message="    VM:        ${java.vm.version}, ${java.vm.vendor}"/>
  </target>

  <!-- Help ............................................................... -->
  <target name="help" depends="init" description="Displays the usage">
    <echo message=""/>
    <echo message="The following build targets are available:"/>
    <echo message=""/>
    <echo message=" -- Running -------------------------------------------------------"/>
    <echo message=""/>
    <echo message="    squiggle"/>
    <echo message="        Runs the Squiggle SVG browser application."/>
    <echo message=""/>
    <echo message="    svgrasterizer"/>
    <echo message="        Runs the SVG rasterizer application."/>
    <echo message=""/>
    <echo message="    svgpp"/>
    <echo message="        Runs the SVG pretty-printer application."/>
    <echo message=""/>
    <echo message="    ttf2svg"/>
    <echo message="        Runs the TrueType Font to SVG Font convert application."/>
    <echo message=""/>
    <echo message=" -- Building ------------------------------------------------------"/>
    <echo message=""/>
    <echo message="    dist-zip"/>
    <echo message="        Builds the binary, source and documentation distributions"/>
    <echo message="        as ZIP files."/>
    <echo message="        (Creates ${project}-${completeVersion}.zip, ${project}-docs-${completeVersion}.zip"/>
    <echo message="        and ${project}-src-${completeVersion}.zip.)"/>
    <echo message=""/>
    <echo message="    dist-tgz"/>
    <echo message="        Builds the binary, source and documentation distributions"/>
    <echo message="        as .tar.gz files."/>
    <echo message="        (Creates ${project}-${completeVersion}.tar.gz, ${project}-docs-${completeVersion}.tar.gz"/>
    <echo message="        and ${project}-src-${completeVersion}.tar.gz.)"/>
    <echo message=""/>
    <echo message="    appbundle"/>
    <echo message="        Builds the Mac OS X Squiggle application bundle."/>
    <echo message="        (Creates ${app}.)"/>
    <echo message=""/>
    <echo message="    dmg"/>
    <echo message="        Builds the Mac OS X Squiggle application bundle disk image."/>
    <echo message="        (Creates ${dmg}.)"/>
    <echo message=""/>
    <echo message="    compile"/>
    <echo message="        Compiles all of Batik except the test infrastructure."/>
    <echo message="        (Creates class files in classes/ from files in sources/.)"/>
    <echo message=""/>
    <echo message="    compiletest"/>
    <echo message="        Compiles the Batik test infrastructure."/>
    <echo message="        (Creates class files in classes/ from files in"/>
    <echo message="        test-sources/.)"/>
    <echo message=""/>
    <echo message="    jars"/>
    <echo message="        Builds jar files for all Batik libraries and applications."/>
    <echo message="        (Creates ${build}/.)"/>
    <echo message=""/>
    <echo message="    all-jar"/>
    <echo message="        Builds a single jar that contains all Batik libraries."/>
    <echo message="        (Creates ${build}/lib/${project}-all.jar.)"/>
    <echo message=""/>
    <echo message="    javadoc"/>
    <echo message="        Generates the API documentation."/>
    <echo message="        (Creates ${docs}/javadoc/.)"/>
    <echo message=""/>
    <echo message="    site"/>
    <echo message="        Generates the http://xmlgraphics.apache.org/batik/ site,"/>
    <echo message="        including Javadocs."/>
    <echo message="        (Creates ${site}/.)"/>
    <echo message=""/>
    <echo message="    sitedoc"/>
    <echo message="        Generates the http://xmlgraphics.apache.org/batik/ site,"/>
    <echo message="        excluding Javadocs."/>
    <echo message="        (Creates ${site}/.)"/>
    <echo message=""/>
    <echo message="    html"/>
    <echo message="        Generates the HTML documentation, including Javadocs."/>
    <echo message="        (Creates ${docs}/.)"/>
    <echo message=""/>
    <echo message="    htmldoc"/>
    <echo message="        Generates the HTML documentation, excluding Javadocs."/>
    <echo message="        (Creates ${docs}/.)"/>
    <echo message=""/>
    <echo message="    splash"/>
    <echo message="        Regenerates the Squiggle browser splash screen."/>
    <echo message=""/>
    <echo message="    clean"/>
    <echo message="        Removes all output files and directories."/>
    <echo message="    "/>
    <echo message=" -- Testing -------------------------------------------------------"/>
    <echo message=""/>
    <echo message="    regard"/>
    <echo message="        Runs the Regard regression testing tool for all tests that"/>
    <echo message="        need no user interaction."/>
    <echo message="        (Creates HTML test reports in test-reports/.)"/>
    <echo message=""/>
    <echo message="    regard.manual"/>
    <echo message="        Runs the Regard regression testing tool for all test that"/>
    <echo message="        need user interaction."/>
    <echo message="        (Creates HTML test reports in test-reports/.)"/>
    <echo message=""/>
    <echo message="    runtestsuite"/>
    <echo message="        Runs a test suite, given an XML test suite document."/>
    <echo message=""/>
    <echo message="    runtest"/>
    <echo message="        Runs an individual test, given a class name."/>
    <echo message=""/>
    <echo message="    showpainter"/>
    <echo message="        Runs an SVG Generator painter test, given a class name."/>
    <echo message=""/>
    <echo message="See the comments in the build.xml file for more details."/>
  </target>

  <!-- Build .............................................................. -->
  <target name="dist-zip" depends="build-zip"/>
  <target name="build-zip" depends="doc-zip, bin-zip, src-zip"/>

  <target name="doc-zip" depends="init, html">
    <delete dir="${build}/docs/images/BE"/>
    <zip zipfile="${project}-docs-${completeVersion}.zip" basedir="${build}"
         includes="docs/javadoc/**"/>
    <delete dir="${build}/docs/javadoc"/>
  </target>

  <target name="copy-shared-resources">
    <copy todir="${basedir}">
      <fileset dir="${basedir}/batik-shared-resources/src/main/resources">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
      </fileset>
    </copy>
  </target>

  <target name="clean-shared-resources">
    <delete file="${basedir}/LICENSE" failonerror="false"/>
    <delete file="${basedir}/NOTICE" failonerror="false"/>
  </target>

  <target name="bin-zip" depends="init, copy-shared-resources, jars, bundle-script">
    <zip zipfile="${project}-bin-${completeVersion}.zip">
      <zipfileset dir="." prefix="${project}-${completeVersion}">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
        <include name="README"/>
        <include name="CHANGES"/>
      </zipfileset>
      <zipfileset dir="${build}" prefix="${project}-${completeVersion}">
        <include name="*.jar"/>
        <include name="docs/**"/>
        <include name="extensions/**"/>
        <include name="lib/*.jar"/>
        <include name="lib/make-squiggle-app.sh"/>
      </zipfileset>
      <zipfileset dir="lib" prefix="${project}-${completeVersion}/lib">
        <include name="LICENSE.*.txt"/>
        <include name="README.*.txt"/>
        <include name="NOTICE.*.txt"/>
      </zipfileset>
      <zipfileset dir="batik-extension/src/main/resources/${package-prefix}/extensions"
                  prefix="${project}-${completeVersion}/extensions">
        <include name="README.txt"/>
      </zipfileset>
      <zipfileset dir="${src}" prefix="${project}-${completeVersion}/lib">
        <include name="Squiggle.icns"/>
      </zipfileset>
      <zipfileset dir="." includes="samples/**" prefix="${project}-${completeVersion}"/>
    </zip>
  </target>

  <target name="src-zip" depends="init, copy-shared-resources, record-svn-revision">
    <zip zipfile="${project}-src-${completeVersion}.zip">
      <zipfileset dir="." prefix="${project}-${completeVersion}">
        <include name="LICENSE"/>
        <include name="KEYS"/>
        <include name="MAINTAIN"/>
        <include name="NOTICE"/>
        <include name="README"/>
        <include name="CHANGES"/>
        <include name="build.bat"/>
        <include name="build.sh"/>
        <include name="build.xml"/>
        <include name="**/pom.xml"/>
        <include name="forrest.properties"/>
        <include name="svn-revision"/>
        <include name="contrib/**"/>
        <include name="lib/**"/>
        <include name="documentation-sources/**"/>
        <include name="resources/**"/>
        <include name="samples/**"/>
        <include name="*/src/**"/>
        <include name="test-resources/**"/>
        <include name="test-sources/**"/>
      </zipfileset>
    </zip>
    <delete file="svn-revision" failonerror="false"/>
  </target>

  <target name="dist-tgz" depends="build-tgz"/>
  <target name="build-tgz" depends="doc-tgz, bin-tgz, src-tgz"/>

  <target name="doc-tgz" depends="init, html">
    <delete dir="${build}/docs/images/BE"/>
    <tar tarfile="${project}-docs-${completeVersion}.tar.gz" compression="gzip"
         basedir="${build}" includes="docs/javadoc/**"/>
    <delete dir="${build}/docs/javadoc"/>
  </target>

  <target name="bin-tgz" depends="init, copy-shared-resources, jars, bundle-script">
    <tar tarfile="${project}-bin-${completeVersion}.tar.gz" compression="gzip">
      <tarfileset dir="." prefix="${project}-${completeVersion}">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
        <include name="README"/>
        <include name="CHANGES"/>
      </tarfileset>
      <tarfileset dir="${build}" prefix="${project}-${completeVersion}">
        <include name="*.jar"/>
        <include name="docs/**"/>
        <include name="extensions/**"/>
        <include name="lib/*.jar"/>
        <include name="lib/make-squiggle-app.sh"/>
      </tarfileset>
      <tarfileset dir="lib" prefix="${project}-${completeVersion}/lib">
        <include name="LICENSE.*.txt"/>
        <include name="README.*.txt"/>
        <include name="NOTICE.*.txt"/>
      </tarfileset>
      <tarfileset dir="batik-extension/src/main/resources/${package-prefix}/extensions"
                  prefix="${project}-${completeVersion}/extensions">
        <include name="README.txt"/>
      </tarfileset>
      <tarfileset dir="${src}" prefix="${project}-${completeVersion}/lib">
        <include name="Squiggle.icns"/>
      </tarfileset>
      <tarfileset dir="." includes="samples/**" prefix="${project}-${completeVersion}"/>
    </tar>
  </target>

  <target name="src-tgz" depends="init, copy-shared-resources, record-svn-revision">
    <tar tarfile="${project}-src-${completeVersion}.tar.gz" compression="gzip">
      <tarfileset dir="." prefix="${project}-${completeVersion}">
        <include name="LICENSE"/>
        <include name="KEYS"/>
        <include name="MAINTAIN"/>
        <include name="NOTICE"/>
        <include name="README"/>
        <include name="CHANGES"/>
        <include name="build.bat"/>
        <include name="build.sh"/>
        <include name="build.xml"/>
        <include name="**/pom.xml"/>
        <include name="forrest.properties"/>
        <include name="svn-revision"/>
        <include name="contrib/**"/>
        <include name="lib/**"/>
        <include name="documentation-sources/**"/>
        <include name="resources/**"/>
        <include name="samples/**"/>
        <include name="*/src/**"/>
        <include name="test-resources/**"/>
        <include name="test-sources/**"/>
      </tarfileset>
    </tar>
    <delete file="svn-revision" failonerror="false"/>
  </target>
  
  <target name="release-dist" depends="dist-zip,dist-tgz" description="Generates the distribution package and signs the release">
    <input message="Passphrase for your default private key" addproperty="pwd">
      <handler classname="org.apache.tools.ant.input.SecureInputHandler" />
    </input>
    <antcall target="sha512">
      <param name="sign.archive" value="${project}-docs-${completeVersion}.zip"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${project}-docs-${completeVersion}.zip"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="sha512">
      <param name="sign.archive" value="${project}-docs-${completeVersion}.tar.gz"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${project}-docs-${completeVersion}.tar.gz"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>   
    <antcall target="sha512">
      <param name="sign.archive" value="${project}-bin-${completeVersion}.zip"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${project}-bin-${completeVersion}.zip"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="sha512">
      <param name="sign.archive" value="${project}-bin-${completeVersion}.tar.gz"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${project}-bin-${completeVersion}.tar.gz"/>
      <param name="pwd" value="${pwd}"/>
    </antcall> 
    <antcall target="sha512">
      <param name="sign.archive" value="${project}-src-${completeVersion}.zip"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${project}-src-${completeVersion}.zip"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>
    <antcall target="sha512">
      <param name="sign.archive" value="${project}-src-${completeVersion}.tar.gz"/>
    </antcall>
    <antcall target="sign-file">
      <param name="sign.archive" value="${project}-src-${completeVersion}.tar.gz"/>
      <param name="pwd" value="${pwd}"/>
    </antcall>     
  </target>  
  
  <target name="sha512">
    <property name="sha512sum.exec" value="sha512sum"/>
    <property name="sha512sum.options" value=""/>
    <exec executable="${sha512sum.exec}" output="${sign.archive}.sha512">
      <arg line="${sha512sum.options} ${sign.archive}"/>
    </exec>
  </target>
  
  <target name="sign-file">
    <property name="gpg.exec" value="gpg"/>
    <property name="gpg.options" value="--armor --detach-sign --force-v3-sigs --batch --verbose --passphrase-fd 0"/>
    <delete file="${sign.archive}.asc"/>
    <exec executable="${gpg.exec}" inputstring="${pwd}">
      <arg line="${gpg.options} ${sign.archive}"/>
    </exec>
  </target>  

  <target name="src-jar" depends="init, copy-shared-resources, record-svn-revision">
    <jar jarfile="${build}/lib/${project}-src-${completeVersion}.jar">
      <fileset dir=".">
        <include name="LICENSE"/>
        <include name="KEYS"/>
        <include name="MAINTAIN"/>
        <include name="NOTICE"/>
        <include name="README"/>
        <include name="CHANGES"/>
        <include name="build.bat"/>
        <include name="build.sh"/>
        <include name="build.xml"/>
        <include name="forrest.properties"/>
        <include name="svn-revision"/>
        <include name="contrib/**"/>
        <include name="lib/**"/>
        <include name="documentation-sources/**"/>
        <include name="resources/**"/>
        <include name="samples/**"/>
        <include name="*/src/**"/>
        <include name="test-resources/**"/>
        <include name="test-sources/**"/>
      </fileset>
    </jar>
    <delete file="svn-revision" failonerror="false"/>
  </target>

  <target name="dmg" depends="appbundle">
    <exec executable="hdiutil">
      <arg line="create -srcfolder ${app} ${dmg}"/>
    </exec>
  </target>

  <target name="appbundle" depends="init, jars, determine-svn-revision">
    <mkdir dir="${app}/Contents/MacOS"/>
    <mkdir dir="${app}/Contents/Resources"/>
    <echo file="${app}/Contents/Info.plist"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundleExecutable</key>
  <string>Squiggle</string>
  <key>CFBundleVersion</key>
  <string>${completeVersion}</string>
  <key>CFBundleShortVersionString</key>
  <string>${completeVersion}</string>
  <key>CFBundleIconFile</key>
  <string>Squiggle.icns</string>
  <key>CFBundleIdentifier</key>
  <string>org.apache.batik</string>
  <key>CFBundleInfoDictionaryVersion</key>
  <string>6.0</string>
  <key>CFBundleName</key>
  <string>Squiggle</string>
  <key>CFBundlePackageType</key>
  <string>APPL</string>
  <key>CFBundleSignature</key>
  <string>????</string>
  <key>NSHumanReadableCopyright</key>
  <string>Copyright © ${year} Apache Software Foundation. All Rights Reserved.</string>
</dict>
</plist>]]></echo>
    <echo file="${app}/Contents/MacOS/Squiggle"><![CDATA[#!/bin/sh

JAVA=/usr/bin/java
[ -e "$JAVA_HOME/bin/java" ] && JAVA="$JAVA_HOME/bin/java"

"$JAVA" -Dcom.apple.mrj.application.apple.menu.about.name=Squiggle -jar "`dirname \"$0\"`/../Resources/batik-squiggle.jar"
]]></echo>
    <chmod perm="a+x" file="${app}/Contents/MacOS/Squiggle"/>
    <copy todir="${app}/Contents/Resources">
      <fileset dir=".">
        <include name="LICENSE"/>
        <include name="NOTICE"/>
        <include name="README"/>
      </fileset>
      <fileset dir="${build}">
        <include name="*.jar"/>
        <include name="lib/**"/>
        <include name="extensions/**"/>
      </fileset>
      <fileset dir="${src}">
        <include name="Squiggle.icns"/>
      </fileset>
    </copy>
    <copy todir="${app}/Contents/Resources/lib">
      <fileset dir="${lib}">
        <include name="LICENSE.*.txt"/>
        <include name="README.*.txt"/>
      </fileset>
    </copy>
    <copy todir="${app}/Contents/Resources/extensions">
      <fileset dir="${resources}/${package-prefix}/extensions">
        <include name="README.txt"/>
      </fileset>
    </copy>
  </target>

  <target name="bundle-script" depends="init, determine-svn-revision">
<!--     <copy file="${src}/make-squiggle-app.sh.template"
          tofile="${build}/lib/make-squiggle-app.sh">
      <filterset>
        <filter token="VERSION" value="${completeVersion}"/>
        <filter token="YEAR" value="${year}"/>
      </filterset>
    </copy>
    <chmod perm="a+x" file="${build}/lib/make-squiggle-app.sh"/> -->
  </target>

  <!-- Compilation ........................................................ -->
  <target name="compiletest" depends="init, compile"
          description="Compiles the tests infrastructure source files">
    <mkdir dir="${dest}"/>

    <echo message="debug ${debug}, optimize ${optimize}, deprecation ${deprecation}"/>

    <javac source="${javac.source}" target="${javac.target}" destdir="${dest}"  deprecation="${deprecation}" 
           debug="${debug}" optimize="${optimize}" encoding="UTF-8">
      <src path="${testsrc}"/>
      <src path="batik-test/src/main/java"/>
      <src path="batik-test-svg/src/main/java"/>
      <src path="batik-test-swing/src/main/java"/>
      <src path="batik-util/src/test/java"/>
      <exclude name="org/apache/batik/util/*TestCases.java"/>
      <exclude name="org/apache/batik/util/*TestSuite.java"/>
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <path refid="libs-build-classpath"/>
      </classpath>
    </javac>
  </target>

  <!-- Builds Jar Files needed for test purposes. Note that compilation of jars is done -->
  <!-- in a different directory than the usual 'classes' directory ({$dest}).           -->
  <!-- Note that this is needed to avoid having the class files in the classes          -->
  <!-- subdirectory, which interferes with the tests, because classes in that directory -->
  <!-- are loaded first in the development version.                                     -->
  <target name="testjars" depends="security2.jar, IWasLoaded.jar, IWasLoadedToo.jar, JarCheckPermissionsGranted.jar, JarCheckPermissionsDenied.jar, java-binding.jar"/>

  <target name="compiletestjars" depends="init, compile"
          description="Compiles the source files for the samples scripts and the test-resources">
    <mkdir dir="${testresources}/classes"/>
    <mkdir dir="${samples}/tests/resources/java/classes"/>

    <echo message="debug ${debug}, optimize ${optimize}, deprecation ${deprecation}"/>

    <javac source="${javac.source}" target="${javac.target}" srcdir="${samples}/tests/resources/java/sources" destdir="${samples}/tests/resources/java/classes"  deprecation="${deprecation}" 
           debug="${debug}" optimize="${optimize}" encoding="UTF-8">
      <classpath>
        <pathelement location="${dest}"/>
        <pathelement location="${samples}/tests/resources/java/classes"/>
        <path refid="libs-classpath"/>
        <path refid="libs-build-classpath"/>
      </classpath>
    </javac>

    <javac source="${javac.source}" target="${javac.target}" srcdir="${testresources}" destdir="${testresources}/classes"  deprecation="${deprecation}" 
           debug="${debug}" optimize="${optimize}" encoding="UTF-8">
      <classpath>
        <pathelement location="${dest}"/>
        <pathelement location="${testresources}/classes"/>
        <path refid="libs-classpath"/>
        <path refid="libs-build-classpath"/>
      </classpath>
    </javac>
  </target>

  <target name="security2.jar" depends="init, compiletestjars">
    <jar manifest="${samples}/tests/resources/java/resources/com/untrusted/script/security2.mf"
         jarfile="samples/tests/spec/scripting/security2.jar">
      <fileset dir="${samples}/tests/resources/java/classes">
        <include name="com/untrusted/script/**/*.class"/>
      </fileset>
    </jar>
  </target>

  <target name="IWasLoaded.jar" depends="init, compiletestjars" 
          unless="IWasLoadedUpToDate">
    <jar manifest="${testresources}/org/apache/batik/bridge/IWasLoaded.mf"
         jarfile="${testresources}/org/apache/batik/bridge/IWasLoaded.jar">
      <fileset dir="${testresources}/classes">
        <include name="org/apache/batik/bridge/IWasLoaded.class"/>
        <include name="org/apache/batik/bridge/IWasLoaded$*.class"/>
      </fileset>
    </jar>
  </target>

  <target name="IWasLoadedToo.jar" depends="init, compiletestjars" 
          unless="IWasLoadedTooUpToDate">
    <jar manifest="${testresources}/org/apache/batik/bridge/IWasLoadedToo.mf"
         jarfile="${testresources}/org/apache/batik/bridge/IWasLoadedToo.jar">
      <fileset dir="${testresources}/classes">
        <include name="org/apache/batik/bridge/IWasLoadedToo.class"/>
        <include name="org/apache/batik/bridge/IWasLoadedToo$*.class"/>
      </fileset>
    </jar>
  </target>

  <target name="JarCheckPermissionsDenied.jar" depends="init, compiletestjars">
    <jar manifest="${testresources}/org/apache/batik/bridge/JarCheckPermissionsDenied.mf"
         jarfile="${testresources}/org/apache/batik/bridge/JarCheckPermissionsDenied.jar">
      <fileset dir="${testresources}/classes">
        <include name="org/apache/batik/bridge/JarCheckPermissionsDenied*.class"/>
      </fileset>
    </jar>
  </target>

  <target name="JarCheckPermissionsGranted.jar" depends="init, compiletestjars">
    <jar manifest="${testresources}/org/apache/batik/bridge/JarCheckPermissionsGranted.mf"
         jarfile="${testresources}/org/apache/batik/bridge/JarCheckPermissionsGranted.jar">
      <fileset dir="${testresources}/classes">
        <include name="org/apache/batik/bridge/JarCheckPermissionsGranted*.class"/>
      </fileset>
    </jar>
  </target>

  <target name="java-binding.jar" depends="init, compiletestjars">
    <jar manifest="${samples}/tests/resources/java/resources/com/test/script/java-binding.mf"
         jarfile="${samples}/tests/spec/scripting/java-binding.jar">
      <fileset dir="${samples}/tests/resources/java/classes">
        <include name="com/test/script/EventListenerInitializerImpl*.class"/>
      </fileset>
    </jar>
  </target>

  <target name="record-svn-revision" depends="determine-svn-revision"
          if="svn-revision-determined">
    <echo message="${svn-revision-number}" file="svn-revision"/>
  </target>

  <target name="determine-svn-revision"
          depends="determine-svn-revision-svn-info,
                   determine-svn-revision-transform,
                   determine-svn-revision-from-file,
                   determine-svn-revision-set"/>

  <target name="determine-svn-revision-svn-info" depends="init">
    <dirset id="dirs" dir="${basedir}">
      <include name="batik-anim/src/main/java/${package-prefix}/**"/>
      <include name="batik-awt-util/src/main/java/${package-prefix}/**"/>
      <include name="batik-bridge/src/main/java/${package-prefix}/**"/>
      <include name="batik-codec/src/main/java/${package-prefix}/**"/>
      <include name="batik-constants/src/main/java/${package-prefix}/**"/>
      <include name="batik-css/src/main/java/${package-prefix}/**"/>
      <include name="batik-dom/src/main/java/${package-prefix}/**"/>
      <include name="batik-ext/src/main/java/${package-prefix}/**"/>
      <include name="batik-extension/src/main/java/${package-prefix}/**"/>
      <include name="batik-gui-util/src/main/java/${package-prefix}/**"/>
      <include name="batik-gvt/src/main/java/${package-prefix}/**"/>
      <include name="batik-i18n/src/main/java/${package-prefix}/**"/>
      <include name="batik-parser/src/main/java/${package-prefix}/**"/>
      <include name="batik-rasterizer/src/main/java/${package-prefix}/**"/>
      <include name="batik-rasterizer-ext/src/main/java/${package-prefix}/**"/>
      <include name="batik-script/src/main/java/${package-prefix}/**"/>
      <include name="batik-slideshow/src/main/java/${package-prefix}/**"/>
      <include name="batik-squiggle/src/main/java/${package-prefix}/**"/>
      <include name="batik-svg-dom/src/main/java/${package-prefix}/**"/>
      <include name="batik-svgbrowser/src/main/java/${package-prefix}/**"/>
      <include name="batik-svggen/src/main/java/${package-prefix}/**"/>
      <include name="batik-svgpp/src/main/java/${package-prefix}/**"/>
      <include name="batik-svgrasterizer/src/main/java/${package-prefix}/**"/>
      <include name="batik-swing/src/main/java/${package-prefix}/**"/>
      <include name="batik-transcoder/src/main/java/${package-prefix}/**"/>
      <include name="batik-ttf2svg/src/main/java/${package-prefix}/**"/>
      <include name="batik-util/src/main/java/${package-prefix}/**"/>
      <include name="batik-xml/src/main/java/${package-prefix}/**"/>
    </dirset>
    <pathconvert refid="dirs" pathsep=" " property="svn-info-dirs"/>
    <exec executable="svn" output="svn-info.xml"
          resultproperty="svn-info-result" failifexecutionfails="false">
      <arg line="info --xml . ${svn-info-dirs}"/>
    </exec>
    <condition property="should-transform-svn-info">
      <equals arg1="${svn-info-result}" arg2="0"/>
    </condition>
  </target>

  <target name="determine-svn-revision-transform" depends="init"
          if="should-transform-svn-info">
    <java fork="yes" classname="org.apache.xalan.xslt.Process"
          outputproperty="svn-revision-number"
          errorproperty="svn-revision-transform-error"
          resultproperty="svn-revision-transform-result">
      <classpath>
        <path refid="libs-build-classpath"/>
      </classpath>
      <arg line="-in svn-info.xml -xsl ${lib}/build/svn-info-revision.xsl"/>
    </java>
    <condition property="svn-revision-determined">
      <equals arg1="${svn-revision-transform-result}" arg2="0"/>
    </condition>
  </target>

  <target name="determine-svn-revision-from-file"
          unless="svn-revision-determined">
    <loadfile property="svn-revision-number" srcFile="svn-revision"
              failonerror="false"/>
    <condition property="svn-revision-determined">
      <not>
        <equals arg1="${svn-revision-suffix-string}" arg2=""/>
      </not>
    </condition>
  </target>

  <target name="determine-svn-revision-set"
          if="svn-revision-determined">
    <property name="svn-revision-suffix" value="+r${svn-revision-number}"/>
    <delete file="svn-info.xml" failonerror="false"/>
  </target>


  <target name="compile-prepare" depends="init" unless="compile-prepare.done">
    <mkdir dir="${dest}"/>
    <echo message="debug ${debug}, optimize ${optimize}, deprecation ${deprecation}"/>
    <property name="compile-prepare.done" value="true"/>
  </target>

  <target name="compile-copy-resources" depends="init, compile-prepare" unless="compile-copy-resources.done">
    <property name="compile-copy-resources.done" value="true"/>
    <copy todir="${dest}">
      <fileset dir="batik-anim/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-awt-util/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-bridge/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-codec/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-css/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-dom/src/main/resources">
        <include name="**"/>
      </fileset>
<!--       <fileset dir="batik-ext/src/main/resources">
        <include name="**"/>
      </fileset> -->
      <fileset dir="batik-extension/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-gui-util/src/main/resources">
        <include name="**"/>
      </fileset>
<!--       <fileset dir="batik-gvt/src/main/resources">
        <include name="**"/>
      </fileset> -->
      <fileset dir="batik-parser/src/main/resources">
        <include name="**"/>
      </fileset>
<!--       <fileset dir="batik-rasterizer/src/main/resources">
        <include name="**"/>
      </fileset> -->
<!--       <fileset dir="batik-rasterizer-ext/src/main/resources">
        <include name="**"/>
      </fileset> -->
      <fileset dir="batik-script/src/main/resources">
        <include name="**"/>
      </fileset>
<!--       <fileset dir="batik-slideshow/src/main/resources">
        <include name="**"/>
      </fileset> -->
<!--       <fileset dir="batik-squiggle/src/main/resources">
        <include name="**"/>
      </fileset> -->
      <fileset dir="batik-svg-dom/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-svgbrowser/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-svggen/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-svgpp/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-svgrasterizer/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-swing/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-transcoder/src/main/resources">
        <include name="**"/>
      </fileset>
<!--       <fileset dir="batik-ttf2svg/src/main/resources">
        <include name="**"/>
      </fileset> -->
      <fileset dir="batik-util/src/main/resources">
        <include name="**"/>
      </fileset>
      <fileset dir="batik-xml/src/main/resources">
        <include name="**"/>
      </fileset>
    </copy>
  </target>

  <target name="compile" depends="init, compile-prepare, compile-copy-resources" unless="compile.done">
    <javac source="${javac.source}" target="${javac.target}" destdir="${dest}" deprecation="${deprecation}" 
           debug="${debug}" optimize="${optimize}" encoding="UTF-8"
           includeAntRuntime="true">
      <src path="batik-anim/src/main/java"/>
      <src path="batik-awt-util/src/main/java"/>
      <src path="batik-bridge/src/main/java"/>
      <src path="batik-codec/src/main/java"/>
      <src path="batik-constants/src/main/java"/>
      <src path="batik-css/src/main/java"/>
      <src path="batik-dom/src/main/java"/>
      <src path="batik-ext/src/main/java"/>
      <src path="batik-extension/src/main/java"/>
      <src path="batik-gui-util/src/main/java"/>
      <src path="batik-gvt/src/main/java"/>
      <src path="batik-i18n/src/main/java"/>
      <src path="batik-parser/src/main/java"/>
      <!-- <src path="batik-rasterizer/src/main/java"/> -->
      <!-- <src path="batik-rasterizer-ext/src/main/java"/> -->
      <src path="batik-script/src/main/java"/>
      <src path="batik-slideshow/src/main/java"/>
      <!-- <src path="batik-squiggle/src/main/java"/> -->
      <src path="batik-svg-dom/src/main/java"/>
      <src path="batik-svgbrowser/src/main/java"/>
      <src path="batik-svggen/src/main/java"/>
      <src path="batik-svgpp/src/main/java"/>
      <src path="batik-svgrasterizer/src/main/java"/>
      <src path="batik-swing/src/main/java"/>
      <src path="batik-transcoder/src/main/java"/>
      <src path="batik-ttf2svg/src/main/java"/>
      <src path="batik-util/src/main/java"/>
      <src path="batik-xml/src/main/java"/>
      <classpath refid="libs-classpath"/>
      <exclude name="**/*.html"/>
      <exclude name="**/rhino/*"   unless="rhino.present"/>      
      <exclude name="**/jpython/*" unless="jpython.present"/>
      <exclude name="**/jacl/*"    unless="jacl.present"/>
      <exclude name="${package-prefix}/ext/awt/image/codec/jpeg/*"
               unless="sun-codecs.present"/>
      <exclude name="${package-prefix}/ext/awt/image/codec/tiff/*"
               unless="sun-codecs.present"/>
    </javac>
    <property name="compile.done" value="true"/>
  </target>

  <target name="clean-compile" depends="init"
          description="Cleans the files generated by compile">
    <delete dir="${dest}"/>
  </target>

  <target name="clean-apache" depends="init"
          description="Cleans the Apache files generated by compile">
    <delete dir="${dest}/org/apache"/>
  </target>

  <target name="clean-test" depends="init"
          description="Cleans files generated by running tests">
    <delete file="${samples}/tests/spec/scripting/security2.jar"/>
    <delete file="${samples}/tests/spec/scripting/java-binding.jar"/>
    <delete file="${samples}/anne.pdf"/>
    <delete file="${samples}/anne.png"/>
    <delete dir="${test-references}" includes="**/candidate-reference/**" includeemptydirs="true"/>
    <delete dir="${test-references}" includes="**/candidate-reference" includeemptydirs="true"/>
    <delete dir="${test-references}" includes="**/candidate-variation/**" includeemptydirs="true"/>
    <delete dir="${test-references}" includes="**/candidate-variation" includeemptydirs="true"/>
    <delete dir="${test-references}" includes="${package-prefix}/ext/awt/geom/candidate" includeemptydirs="true"/>
    <delete dir="${test-references}" includes="${package-prefix}/ext/awt/geom/variation" includeemptydirs="true"/>
    <delete dir="${test-references}" includes="${package-prefix}/gvt/candidate" includeemptydirs="true"/>
    <delete dir="${test-references}" includes="${package-prefix}/gvt/variation" includeemptydirs="true"/>
    <delete dir="${test-references}" includes="${package-prefix}/svggen/candidate-ref/**" includeemptydirs="true"/>
    <delete dir="${test-references}" includes="${package-prefix}/transcoder/wmf/candidate/**" includeemptydirs="true"/>
    <delete dir="${test-resources}" includes="**/JarCheckPermissions*.jar"/>
    <delete file="${test-resources}/${package-prefix}/apps/rasterizer/invalidSVG.png"/>
    <delete file="${test-resources}/${package-prefix}/bridge/IWasLoaded.jar"/>
    <delete file="${test-resources}/${package-prefix}/bridge/IWasLoadedToo.jar"/>
    <delete dir="${test-resources}/classes"/>
    <delete dir="${samples}/tests/resources/java/classes"/>
    <delete dir="${test-reports}"/>
  </target>


  <!-- Jars ............................................................... -->
  <target name="prepare-build" depends="init, determine-svn-revision">
    <mkdir dir="${build}"/>
    <mkdir dir="${build}/docs"/>
    <mkdir dir="${build}/lib"/>
  </target>

  <!-- Generates all the jars except all-jar -->
  <target name="jars" depends="init">
    <copy todir="${build}/lib">
      <fileset dir="${lib}">
        <include name="*.jar"/>
      </fileset>
    </copy>
    <available file="batik-all/target/batik-all-${version}.jar" property="batik-all.exists" />
    <fail message="Run 'mvn clean install' first" unless="batik-all.exists" />
    <copy todir="${build}/lib" flatten="true">
      <fileset dir=".">
        <include name="*/target/*.jar"/>
        <exclude name="*/target/batik-rasterizer-*.jar"/>
        <exclude name="*/target/batik-slideshow-*.jar"/>
        <exclude name="*/target/batik-squiggle-*.jar"/>
        <exclude name="*/target/batik-svgpp-*.jar"/>
        <exclude name="*/target/batik-ttf2svg-*.jar"/>
      </fileset>
    </copy>
    <copy todir="${build}/extensions" flatten="true">
      <fileset dir=".">
        <include name="*/target/batik-rasterizer-ext-*.jar"/>
        <include name="*/target/batik-squiggle-ext-*.jar"/>
      </fileset>
    </copy>
    <copy todir="${build}" flatten="true">
      <fileset dir=".">
        <include name="*/target/batik-rasterizer-${version}.jar"/>
        <include name="*/target/batik-slideshow-${version}.jar"/>
        <include name="*/target/batik-squiggle-${version}.jar"/>
        <include name="*/target/batik-svgpp-${version}.jar"/>
        <include name="*/target/batik-ttf2svg-${version}.jar"/>
      </fileset>
    </copy>    
  </target>


  <!-- All batik in a single jar (dependencies: none) -->
  <target name="all-jar" depends="init, copy-shared-resources, compile, prepare-build"
          description="Creates a combined JAR file of the Batik libraries in ${build}/lib">
    <jar jarfile="${build}/lib/${project}-all-${completeVersion}.jar">
      <manifest>
        <attribute name="Implementation-Title" value="Batik all-in-one JAR"/>
        <attribute name="Implementation-Version" value="${completeVersion}"/>
        <attribute name="Implementation-Vendor" value="${vendor}"/>
        <attribute name="Build-Id" value="${build.id}"/>
        <attribute name="Main-Class" value="${class-prefix}.apps.svgbrowser.Main"/>
      </manifest>
      <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
      <fileset dir="${dest}" excludes="**/.svn/">
        <include name="**"/>
      </fileset>
    </jar>
  </target>

  <!-- Applications ....................................................... -->
  <target name="squiggle" depends="init, compile"
          description="Runs Squiggle - the SVG browser">
    <condition property="squiggle-suffix" value="osx" else="others">
      <os name="Mac OS X"/>
    </condition>
    <antcall target="squiggle-${squiggle-suffix}" inheritRefs="true"/>
  </target>

  <target name="squiggle-osx" depends="appbundle">
    <exec executable="open">
      <arg value="${app}"/>
    </exec>
  </target>

  <target name="squiggle-others">
    <java fork="yes" 
          classname="${class-prefix}.apps.svgbrowser.Main">
<!--          jvm="C:\Documents and Settings\<user>\.netbeans\4.0\modules\profiler-ea-vm\jre\bin\java"> -->
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <pathelement location="resources"/>
      </classpath>
      <arg line="${args}"/> 
      <!-- <jvmarg value="-Xmx512m"/>  <jvmarg value="-Xms64m"/> -->
      <!-- <jvmarg value="-Djava.security.debug=all"/>  
           <jvmarg value="-verbose"/> -->
     <!-- 
      <jvmarg value="-Djava.security.debug=access failure"/> 
      <jvmarg value="-Djava.security.debug=policy"/> 
      <jvmarg value="-Djava.security.manager"/> 
      <jvmarg value="-Djava.security.policy=resources/org/apache/batik/apps/svgbrowser/resources/svgbrowser.policy"/> 
      -->
    </java>
  </target>

  <target name="svgbrowser" depends="squiggle"
          description="Runs Squiggle - the SVG browser"/>

  <target name="svgrasterizer" depends="init, compile"
          description="Runs the SVG rasterizer">
    <java fork="yes"
          classname="${class-prefix}.apps.rasterizer.Main">
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <pathelement location="resources"/>
      </classpath>
<!--      <jvmarg value="-Xmx512m"/>  <jvmarg value="-Xms64m"/>  -->
<!--      <jvmarg value="-Djava.awt.headless=true"/>  -->
      <arg line="${args}"/>
    </java>
  </target>

  <target name="svgpp" depends="init, compile"
          description="Runs the SVG pretty-printer">
    <java fork="yes"
          classname="${class-prefix}.apps.svgpp.Main">
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <pathelement location="resources"/>
      </classpath>
      <arg line="${args}"/>
    </java>
  </target>

  <target name="testdirs" depends="init"
          description="Created directories needed for test suite">

    <mkdir dir="${test-reports}"/>
    <mkdir dir="${test-reports}/style"/>
    <mkdir dir="${test-reports}/images"/>
    <copy todir="${test-reports}/style">
      <fileset dir="${test-resources}/org/apache/batik/test/svg/resources/style"/>
    </copy>
    <copy todir="${test-reports}/images">
      <fileset dir="${test-resources}/org/apache/batik/test/svg/resources/images"/>
    </copy>

    <mkdir dir="${test-references}/samples/candidate-variation"/>
    <mkdir dir="${test-references}/samples/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/coordinates/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/coordinates/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/fonts/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/fonts/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/masking/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/masking/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/paints/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/paints/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/shapes/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/shapes/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/styling/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/styling/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/color/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/color/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/filters/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/filters/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/linking/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/linking/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/painting/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/painting/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/rendering/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/rendering/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/structure/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/structure/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/text/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/text/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/interactivity/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/interactivity/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec/scripting/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec/scripting/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec12/filters/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec12/filters/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec12/paints/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec12/paints/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec12/structure/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec12/structure/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec12/structure/opera/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec12/structure/opera/candidate-reference"/>
    <mkdir dir="${test-references}/samples/tests/spec12/text/candidate-variation"/>
    <mkdir dir="${test-references}/samples/tests/spec12/text/candidate-reference"/>
    <mkdir dir="${test-references}/samples/extensions/candidate-variation"/>
    <mkdir dir="${test-references}/samples/extensions/candidate-reference"/>
    <mkdir dir="${test-references}/samples/extensions/opera/candidate-variation"/>
    <mkdir dir="${test-references}/samples/extensions/opera/candidate-reference"/>
    <mkdir dir="${test-references}/svgbe/candidate-variation"/>
    <mkdir dir="${test-references}/svgbe/candidate-reference"/>
    <mkdir dir="${test-references}/org/apache/batik/transcoder/wmf/candidate"/>
    <mkdir dir="${test-references}/org/apache/batik/svggen/candidate-ref"/>
    <mkdir dir="${test-references}/org/apache/batik/svggen/rendering/candidate-variation"/>
    <mkdir dir="${test-references}/org/apache/batik/svggen/rendering/candidate-reference"/>
    <mkdir dir="${test-references}/org/apache/batik/gvt/candidate"/>
    <mkdir dir="${test-references}/org/apache/batik/gvt/variation"/>
    <mkdir dir="${test-references}/org/apache/batik/ext/awt/geom/candidate"/>
    <mkdir dir="${test-references}/org/apache/batik/ext/awt/geom/variation"/>
    <mkdir dir="${test-references}/org/apache/batik/transcoder/image/candidate-reference"/>
    <mkdir dir="${test-references}/org/apache/batik/transcoder/image/candidate-variation"/>
    <mkdir dir="${test-references}/test-resources/org/apache/batik/test/svg/candidate-variation"/>
    <mkdir dir="${test-references}/test-resources/org/apache/batik/test/svg/candidate-reference"/>

  </target>

  <target name="ttf2svg" depends="init, compile, testdirs"
          description="converts selected glyphs from a True Type Font file to the SVG Font format">
    <java fork="yes"
          classname="${class-prefix}.apps.ttf2svg.Main">
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <pathelement location="resources"/>
      </classpath>
      <arg line="${args}"/>
    </java>
  </target>

  <target name="regard" depends="init, compiletest, testdirs, testjars"
          description="Runs test suite whose file or uri is passed as an input">
    <java fork="yes"
          classname="${class-prefix}.test.xml.XMLTestSuiteRunner">
<!-- Using -Xincgc makes the memory leak tests _much_ more accurate but
     Also slows down the regard run by 3-4x,  In general I suggest running
     just the memory leak tests with -Xincgc, I might also experiment with
     a higher -Xms setting. -->
<!--      <jvmarg value="-Xincgc"/> -->
<!--      <jvmarg value="-Xrunhprof:format=b"/> -->
<!--      <jvmarg value="-Xrunhprof:net=localhost:1234,format=b"/> -->
      <jvmarg value="-Xmx1024m"/>  <jvmarg value="-Xms64m"/>
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <path refid="libs-build-classpath"/>
        <pathelement location="resources"/>
        <pathelement location="test-resources"/>
      </classpath>
      <arg line="test-resources/org/apache/batik/test/regard.xml ${args}"/>
    </java>
  </target>

  <target name="regard.manual" depends="init, compiletest, testdirs, testjars"
          description="Runs test suite whose file or uri is passed as an input">
    <java fork="yes"
          classname="${class-prefix}.test.xml.XMLTestSuiteRunner">
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <path refid="libs-build-classpath"/>
        <pathelement location="resources"/>
        <pathelement location="test-resources"/>
      </classpath>
      <arg line="test-resources/org/apache/batik/test/regardManual.xml ${args}"/>
    </java>
  </target>

  <target name="showpainter" depends="init, compiletest, testdirs"
          description="Runs test suite whose file or uri is passed as an input">
    <java fork="yes"
          classname="${class-prefix}.svggen.JPainterCompare">
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <path refid="libs-build-classpath"/>
        <pathelement location="resources"/>
        <pathelement location="test-resources"/>
      </classpath>
      <arg line="${args}"/>
    </java>
  </target>

  <target name="runtestsuite" depends="init, compiletest, testdirs"
          description="Runs test suite whose file or uri is passed as an input">
    <mkdir dir="${test-reports}"/>
    <java fork="yes"
          classname="${class-prefix}.test.xml.XMLTestSuiteRunner">
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <path refid="libs-build-classpath"/>
        <pathelement location="resources"/>
        <pathelement location="test-resources"/>
      </classpath>
      <arg line="${args}"/>
    </java>
  </target>

  <target name="runtest" depends="init, compiletest, testdirs"
          description="Runs test whose class name is passed as an input">
    <java fork="yes"
          classname="${args}">
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <path refid="libs-build-classpath"/>
        <pathelement location="resources"/>
        <pathelement location="test-resources"/>
      </classpath>
    </java>
  </target>

  <!-- Documentation ...................................................... -->
  <target name="html" depends="javadoc"
          description="Generates the HTML documentation, including javadocs, in ${build}/docs/"/>
  <target name="htmldoc" depends="init"
          description="Generates HTML documentation">
    <mkdir dir="${docs}"/>
    <copy todir="${docs}">
      <fileset dir="${forrest-build}/site" excludes="doap.rdf, download.cgi"/>
    </copy>
  </target>

  <target name="site" depends="site-javadoc, sitedoc"/>
  <target name="sitedoc" depends="init"
          description="Generates the http://xmlgraphics.apache.org/batik/ site">
    <mkdir dir="${site}"/>
    <copy todir="${site}">
      <fileset dir="${forrest-build}/site"/>
    </copy>
  </target>

  <target name="site-javadoc" depends="init, javadoc">
    <mkdir dir="${site}/javadoc"/>
    <copy todir="${site}/javadoc">
      <fileset dir="${docs}/javadoc"/>
    </copy>
  </target>

  <target name="forrest" depends="init">
    <property name="forrest-build.dir" value="${cwd}${file.separator}${forrest-build}"/>
    <exec executable="${forrest.call}">
      <arg line="${forrest.args}"/>
      <arg value="-Dproject.build-dir=${forrest-build.dir}"/>
      <arg value="-Dproject.temp-dir=${forrest-build.dir}${file.separator}tmp"/>
      <arg value="-Dproject.webapp=${forrest-build.dir}${file.separator}webapp"/>
    </exec>
    <delete dir="${forrest-build}/tmp"/>
    <!-- Ideally Forrest would put its log files in ${forrest-build}, but it
         insists on creating a directory called 'build' for these. -->
    <delete dir="build"/>
  </target>

  <target name="javadocs" depends="javadoc"/>
  <target name="javadoc" depends="init">
    <mkdir dir="${docs}/javadoc"/>
    <javadoc packagenames="${class-prefix}.*,
                           org.xml.*,
                           org.w3c.css.*,
                           org.w3c.dom.*"
             excludepackagenames="${javadoc-exclusions}"
             maxmemory="512m"
             failonerror="yes"
             destdir="${docs}/javadoc"
             encoding="UTF-8"
             docencoding="UTF-8"
             author="false"
             version="false"
             use="true"
             splitindex="true"
             windowtitle="${Project} Javadoc"
             doctitle="${Project} API Specification ${completeVersion}"
             bottom="Copyright &#169; ${year} &lt;a href='http://www.apache.org/'&gt;Apache Software Foundation&lt;/a&gt;. All Rights Reserved."
             sourcepathref="source.files">
      <arg value="-notimestamp"/>
      <sourcepath path="${src}"/>
      <classpath refid="libs-classpath"/>
      <link href="${dom.javadoc}"/>
      <link href="${jdk.javadoc}"/>
      <link href="${rhino.javadoc}"/>
    </javadoc>
  </target>

  <target name="prepare-publish" depends="init">
    <mkdir dir="${site}"/>
    <mkdir dir="${forrest-build}"/>
    <exec executable="svn" dir="${site}" output="${forrest-build}/publish.info"
          failonerror="false">
      <arg value="info"/>
    </exec>
    <loadfile srcfile="${forrest-build}/publish.info" property="publish.info">
      <filterchain>
        <linecontains>
          <contains value="URL:"/>
        </linecontains>
        <tokenfilter>
          <replacestring from="URL: " to=""/>
        </tokenfilter>
        <striplinebreaks/>
      </filterchain>
    </loadfile>
    <delete file="${forrest-build}/publish.info"/>
    <condition property="publish-checkout-task" value="prepare-publish-up" else="prepare-publish-co">
      <equals arg1="${publish.info}" arg2="${deploy.svn.url}"/>
    </condition>
    <antcall target="${publish-checkout-task}"/>
  </target>

  <target name="prepare-publish-up">
    <exec executable="svn" dir="${site}" failonerror="true">
      <arg value="update"/>
    </exec>
  </target>

  <target name="prepare-publish-co">
    <exec executable="svn" dir="." failonerror="true">
      <arg value="checkout"/>
      <arg value="${deploy.svn.url}"/>
      <arg value="${site}"/>
    </exec>
  </target>

  <target name="do-publish" depends="init">
    <property name="deploy.svn.svn-filestoadd" location="${forrest-build}/publish.toadd"/>
    <exec executable="svn" dir="${site}" output="${deploy.svn.svn-filestoadd}"
          failonerror="true">
      <arg value="status"/>
    </exec>
    <replace file="${deploy.svn.svn-filestoadd}" token="?      " value=""/>
    <replace file="${deploy.svn.svn-filestoadd}" token="M      " value=""/>
    <exec executable="svn" dir="${site}" failonerror="true">
      <arg value="add"/>
      <arg value="--targets"/>
      <arg value="${deploy.svn.svn-filestoadd}"/>
    </exec>
    <exec executable="svn" dir="${site}" failonerror="true">
      <arg value="commit"/>
      <arg value="-m"/>
      <arg value="Automatic publish"/>
    </exec>
    <delete file="${forrest-build}/publish.toadd}"/>
    <echo message=""/>
    <echo message="Site has been committed to .../repos/asf/xmlgraphics/site/deploy/batik/."/>
    <echo message=""/>
    <echo message="Don't forget to run 'svn up' from /www/xmlgraphics.apache.org/batik on"/>
    <echo message="people.apache.org now."/>
  </target>

  <target name="publishdoc" depends="prepare-publish,sitedoc,do-publish"
          description="Generates the http://xmlgraphics.apache.org/batik/ site without the javadocs and commits it to SVN"/>

  <target name="publish" depends="prepare-publish,site,do-publish"
          description="Generates the http://xmlgraphics.apache.org/batik/ site including the javadocs and commits it to SVN"/>

  <target name="clean-docs" depends="init">
    <delete dir="${forrest-build}"/>
    <delete dir="${docs}"/>
    <delete dir="${site}"/>
    <delete dir="build"/>  <!-- In case it's left behind by Forrest. -->
  </target>

  <!-- Generates splash screens for the browser ........................... -->

  <target name="splash" depends="init, compile" 
          description="Updates browser splash screen">
    <java fork="yes"
          classname="${class-prefix}.apps.rasterizer.Main">
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <pathelement location="resources"/>
      </classpath>
      <arg line="${resources}/org/apache/batik/apps/svgbrowser/resources/squiggle.svg"/>
    </java>
  </target>

  <target name="jarDependImg" depends="init, compile"
          description="Updates jarDependImg PNG">
    <java fork="yes"
          classname="${class-prefix}.apps.rasterizer.Main">
      <classpath>
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <pathelement location="resources"/>
      </classpath>
      <arg line="documentation-sources/resources/images/jarDependImg.source.svg -d documentation-sources/resources/images/jarDependImg.png"/>
    </java>
  </target>

  <!-- Cleans everything .................................................. -->
  <target name="clean"
          depends="init, clean-compile, clean-docs, clean-test, clean-shared-resources"
          description="Cleans everything">
    <delete dir="${build}"/>
    <delete file="${project}-bin-${completeVersion}.zip"/>
    <delete file="${project}-docs-${completeVersion}.zip"/>
    <delete file="${project}-src-${completeVersion}.zip"/>
    <delete file="${project}-bin-${completeVersion}.tar.gz"/>
    <delete file="${project}-docs-${completeVersion}.tar.gz"/>
    <delete file="${project}-src-${completeVersion}.tar.gz"/>
  </target>

  <target name="junit" depends="init, compiletest, testdirs">
    <property name="junit.reports.dir" value="${build}/test-reports"/>   
    <path id="standard-junit-classpath">
        <pathelement location="${dest}"/>
        <path refid="libs-classpath"/>
        <path refid="libs-build-classpath"/>
        <pathelement location="resources"/>
        <pathelement location="test-resources"/>
    </path>               
    <mkdir dir="${junit.reports.dir}"/>
    <junit dir="${basedir}" haltonfailure="yes" fork="true" forkmode="once" printsummary="yes" showoutput="true">
      <sysproperty key="jawa.awt.headless" value="true"/>
      <formatter type="brief" usefile="false"/>
      <formatter type="plain" usefile="true"/>
      <formatter type="xml" usefile="true"/>
      <classpath>
        <path refid="standard-junit-classpath"/>
      </classpath>
      <assertions>
        <enable/>
      </assertions>
      <batchtest todir="${junit.reports.dir}">
        <fileset dir="classes" includes="**/*TestCase.class"/>
      </batchtest>
    </junit>
  </target>

  <target name="checkstyle" depends="init" description="Runs Checkstyle for a code quality report">
    <property name="checkstyle.location" value="lib/checkstyle-5.6-all.jar" />
    <property name="checkstyle.config" value="checkstyle.xml" />
    <path id="checkstyle-classpath">
      <pathelement location="${checkstyle.location}"/>
    </path>
    <taskdef name="checkstyle" classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" classpathref="checkstyle-classpath"/>
    <mkdir dir="${build}"/>
    <checkstyle config="${checkstyle.config}" failonviolation="true" maxWarnings="0">
      <classpath>
        <path refid="checkstyle-classpath"/>
      </classpath>
      <fileset dir="." includes="**/*.java"/>
      <formatter type="xml" toFile="${build}/report_checkstyle.xml"/>
      <formatter type="plain"/>
    </checkstyle>
  </target>  
</project>
