<?xml version="1.0"?>
<!-- build.xml

     Sweet Home 3D, Copyright (c) 2007-2023 Emmanuel PUYBARET / eTeks <info@eteks.com>.

     Ant build file. Available targets :
     - build       : Builds SweetHome3D.jar file in build directory
     - application : Builds SweetHome3D.jar file without applet classes in build directory
     - furniture   : Builds Furniture.jar file in build directory
     - textures    : Builds Textures.jar file in build directory
     - examples    : Builds Examples.jar file in build directory
     - help        : Builds Help.jar file in build directory

     - java3dLibraries            : Builds JNLP Java 3D libraries in deploy/lib subdirectories
     - javaWebStart               : Builds Java Web Start signed files in deploy/lib directory
     - applet                     : Builds applet signed files in deploy/lib directory
     - viewer                     : Builds viewer signed files in deploy/lib directory
     - jarExecutable              : Builds SweetHome3D-version.jar file in install directory
     - windowsInstaller           : Builds SweetHome3D-version-windows.exe file in install directory
     - windowsSignedInstaller     : Builds signed SweetHome3D-version-windows.exe file in install directory
     - macosx10.4Installer        : Builds SweetHome3D-version-macosx-10.4-10.9.dmg file in install directory
     - macosx10.4SignedInstaller  : Builds signed SweetHome3D-version-macosx-10.4-10.9.dmg file in install directory
     - macosxInstaller            : Builds SweetHome3D-version-macosx.dmg file in install directory
     - macosxSignedInstaller      : Builds signed SweetHome3D-version-macosx.dmg file in install directory
     - linux32Installer           : Builds SweetHome3D-version-linux-x86.tgz file in install directory
     - linux64Installer           : Builds SweetHome3D-version-linux-x64.tgz file in install directory
     - portableArchive            : Builds SweetHome3D-version-portable files in install/portable directory
     - viewerInstaller            : Builds SweetHome3DViewer-version.zip file in install directory
     - sourceArchive              : Builds SweetHome3D-version-src.zip file in install directory
     - javadoc                    : Builds SweetHome3D-version-javadoc.zip file install directory

     - jdepend : Launchs a JDepend graphical UI to help update dependencies in PackageDependenciesTest
-->
<project basedir="." default="jarExecutable" name="SweetHome3D">
  <!-- Current version of Sweet Home 3D -->
  <property name="version" value="7.1"/>
  <!-- Java source and target compatiblity (Java 9 and higher doesn't support 1.5) -->
  <condition property="appletClassSource" value="1.2" else="1.7">
    <matches string="${ant.java.version}" pattern="1\.5|1\.6|1\7|1\.8"/>
  </condition>
  <condition property="appletClassTarget" value="1.1" else="1.7">
    <matches string="${ant.java.version}" pattern="1\.5|1\.6|1\7|1\.8"/>
  </condition>
  <condition property="classSource" value="1.5" else="1.7">
    <matches string="${ant.java.version}" pattern="1\.5|1\.6|1\7|1\.8"/>
  </condition>
  <condition property="classTarget" value="1.5" else="1.7">
    <matches string="${ant.java.version}" pattern="1\.5|1\.6|1\7|1\.8"/>
  </condition>
  <!-- JRE or OpenJDK home for Windows, Mac OS X and Linux -->
  <property name="javaHome_windows_x86" value="C:\Program Files (x86)\Java\jre1.8.0_202"/>
  <property name="javaHome_windows_x64" value="C:\Program Files\OpenJDK\zulu11.62.17-ca-jdk11.0.18-win_x64"/>
  <property name="javaHome_macosx_x86_64" value="/Library/Java/JavaVirtualMachines/zulu-15.0.10-macosx_x86_64.jdk/Contents/Home"/>
  <property name="javaHome_macosx_arm64" value="/Library/Java/JavaVirtualMachines/zulu-15.0.10-macosx_aarch64.jdk/Contents/Home"/>
  <property name="javaHome_linux_x86" value="jre1.8.0_202"/>
  <property name="javaHome_linux_x64" value="jre1.8.0_202"/>

  <target name="build"
          description="Builds build/SweetHome3D.jar with all its classes">
    <echo message="compiling Sweet Home 3D for Java ${classTarget} minimum version"/>
    <!-- Compile Sweet Home 3D -->
    <mkdir dir="build/classes"/>
    <!-- Compile Sweet Home 3D applets first with javac 1.1 to be able to detect current Java version
         during applet launch (otherwise Java 1.1 to 1.4 plug-ins refuse to load Applet class) -->
    <javac srcdir="src" destdir="build/classes"
           includes="com/eteks/sweethome3d/applet/SweetHome3D*.java"
           encoding="ISO-8859-1" target="${appletClassTarget}" source="${appletClassSource}"
           debug="false" debuglevel="lines,vars,source"/>
    <!-- Compile other classes -->
    <javac srcdir="src" destdir="build/classes"
           encoding="ISO-8859-1" target="${classTarget}" source="${classSource}"
           debug="false" debuglevel="lines,vars,source">
      <!-- Use lib as an extension directory to override default Java 3D libraries -->
      <extdirs>
        <pathelement location="lib"/>
      </extdirs>
      <classpath>
        <pathelement location="libtest/AppleJavaExtensions.jar"/>
        <pathelement location="libtest/javaAwtDesktop.jar"/>
        <pathelement location="libtest/jnlp.jar"/>
      </classpath>
    </javac>

    <!-- Copy resources excepted furniture, textures and help files -->
    <copy todir="build/classes">
      <fileset dir="src">
        <include name="**"/>
        <exclude name="**/*.java"/>
        <exclude name="**/*.cpp"/>
        <exclude name="**/*.h"/>
        <exclude name="**/package.html"/>
        <exclude name="com/eteks/sweethome3d/io/*Catalog*.properties"/>
        <exclude name="com/eteks/sweethome3d/io/resources/**"/>
        <exclude name="**/help/**"/>
        <exclude name="**/*.svg"/>
      </fileset>
      <fileset dir="src">
        <include name="com/eteks/sweethome3d/io/resources/patterns/**"/>
      </fileset>
    </copy>

    <!-- Create SweetHome3D.jar -->
    <zip destfile="build/SweetHome3D.jar"
         basedir="build/classes"/>
    <delete dir="build/classes"/>
  </target>

  <target name="application" depends="build"
          description="Builds build/SweetHome3D.jar application with all its classes">
    <zip destfile="build/SweetHome3DStandalone.jar">
      <zipfileset src="build/SweetHome3D.jar"
                  excludes="com/eteks/sweethome3d/applet/**"/>
    </zip>
    <move file="build/SweetHome3DStandalone.jar" tofile="build/SweetHome3D.jar"/>
  </target>

  <target name="furniture"
          description="Builds build/Furniture.jar that contains the furniture files">
    <mkdir dir="build"/>
    <zip destfile="build/Furniture.jar" basedir="src">
      <include name="com/eteks/sweethome3d/io/*FurnitureCatalog*.properties"/>
      <include name="com/eteks/sweethome3d/io/resources/**"/>
      <exclude name="com/eteks/sweethome3d/io/resources/textures/**"/>
      <exclude name="com/eteks/sweethome3d/io/resources/patterns/**"/>
      <exclude name="com/eteks/sweethome3d/io/resources/examples/**"/>
    </zip>
  </target>

  <target name="textures"
          description="Builds build/Textures.jar that contains the textures files">
    <mkdir dir="build"/>
    <zip destfile="build/Textures.jar" basedir="src">
      <include name="com/eteks/sweethome3d/io/*TexturesCatalog*.properties"/>
      <include name="com/eteks/sweethome3d/io/resources/textures/**"/>
    </zip>
  </target>

  <target name="examples"
          description="Builds build/Examples.jar that contains the examples files">
    <mkdir dir="build"/>
    <zip destfile="build/Examples.jar" basedir="src">
      <include name="com/eteks/sweethome3d/io/resources/examples/**"/>
    </zip>
  </target>

  <target name="help"
          description="Builds build/Help.jar that contains the help files">
    <mkdir dir="build"/>
    <zip destfile="build/Help.jar" basedir="src">
      <include name="**/help/**"/>
    </zip>
  </target>

  <target name="jogl-java3d"
          description="Builds jogl-java3d.jar that contains only packages required for Java 3D">
    <mkdir dir="build"/>
    <zip destfile="build/java3d-1.6/jogl-java3d.jar">
      <zipfileset src="lib/java3d-1.6/jogl-all.jar"
        excludes="com/jogamp/graph/**, com/jogamp/newt/**, com/jogamp/opengl/swt/**, com/jogamp/opengl/util/**,
                  javax/media/opengl/Debug*, javax/media/opengl/Trace*,
                  jogamp/graph/**, jogamp/newt/**, jogl/util/data/av/**"/>
      <zipfileset src="lib/java3d-1.6/jogl-all.jar"
        includes="com/jogamp/opengl/util/GLBuffers.class"/>
    </zip>
  </target>

  <target name="manifest"
          description="Builds build/META-INF/MANIFEST.MF with security attributes">
    <mkdir dir="build/META-INF"/>
    <manifest file="build/META-INF/MANIFEST.MF">
      <attribute name="Permissions"               value="all-permissions"/>
      <attribute name="Codebase"                  value="*"/>
      <attribute name="Caller-Allowable-Codebase" value="*"/>
    </manifest>
  </target>

  <target name="java3dLibraries" depends="jogl-java3d,manifest"
          description="Builds JNLP Java 3D libraries in deploy/lib subdirectories">
    <!-- Create java3d.jar containing Windows 32 bit Java 3D DLLs and jars -->
    <mkdir dir="deploy/lib/windows/i386"/>
    <jar destfile="deploy/lib/windows/i386/java3d.jar" manifest="build/META-INF/MANIFEST.MF">
      <fileset dir="lib">
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
      <fileset dir="lib">
        <include name="java3d-1.6/windows/i586/*.dll"/>
      </fileset>
    </jar>

    <!-- Create java3d.jar containing Windows 64 bit Java 3D DLLs and jars -->
    <mkdir dir="deploy/lib/windows/x64"/>
    <jar destfile="deploy/lib/windows/x64/java3d.jar" manifest="build/META-INF/MANIFEST.MF">
      <fileset dir="lib">
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
      <fileset dir="lib">
        <include name="java3d-1.6/windows/amd64/*.dll"/>
      </fileset>
    </jar>

    <!-- Create java3d.jar containing Linux 32 bit Java 3D DLLs and jars -->
    <mkdir dir="deploy/lib/linux/i386"/>
    <jar destfile="deploy/lib/linux/i386/java3d.jar" manifest="build/META-INF/MANIFEST.MF">
      <fileset dir="lib">
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
      <fileset dir="lib">
        <include name="java3d-1.6/linux/i586/*.so"/>
      </fileset>
    </jar>

    <!-- Create java3d.jar containing Linux 64 bit Java 3D DLLs and jars -->
    <mkdir dir="deploy/lib/linux/x64"/>
    <jar destfile="deploy/lib/linux/x64/java3d.jar" manifest="build/META-INF/MANIFEST.MF">
      <fileset dir="lib">
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
      <fileset dir="lib">
        <include name="java3d-1.6/linux/amd64/*.so"/>
      </fileset>
    </jar>

    <!-- Create java3d.jar containing Mac OS X Java 3D DLLs and jars -->
    <mkdir dir="deploy/lib/macosx"/>
    <jar destfile="deploy/lib/macosx/java3d.jar" manifest="build/META-INF/MANIFEST.MF">
      <fileset dir="lib">
        <include name="j3dcore.jar"/>
        <include name="j3dutils.jar"/>
        <include name="vecmath.jar"/>
        <include name="macosx/*.jar"/>
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
      <fileset dir="lib">
        <include name="macosx/*.jnilib"/>
        <include name="java3d-1.6/macosx/*.dylib"/>
      </fileset>
    </jar>
  </target>

  <target name="java3dAllSystemsLibrary" depends="jogl-java3d"
          description="Builds applet Java 3D library suitable for all systems in deploy/lib subdirectory">
    <mkdir dir="deploy/lib"/>
    <!-- Create java3d.jar containing Java 3D DLLs and jars for Windows, Linux and Mac OS X
         (this library is used for Java versions older than Java SE 6 update 10) -->
    <jar destfile="deploy/lib/java3d.jar" manifest="build/META-INF/MANIFEST.MF">
      <fileset dir="lib">
        <include name="j3dcore.jar"/>
        <include name="j3dutils.jar"/>
        <include name="vecmath.jar"/>
        <include name="macosx/*.jar"/>
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
      <fileset dir="lib">
        <include name="java3d-1.6/windows/**/*.dll"/>
        <include name="java3d-1.6/linux/**/*.so"/>
        <include name="macosx/*.jnilib"/>
        <include name="java3d-1.6/macosx/*.dylib"/>
      </fileset>
    </jar>
  </target>

  <target name="viewerLibraries"
          description="Copies to deploy/lib the base libraries used by Sweet Home 3D Viewer">
    <mkdir dir="deploy/lib"/>
    <!-- Copy jar files adding to their manifest security attributes
         (these attributes are necessary to be able to call applet methods from JavaScript) -->
    <jar destfile="deploy/lib/batik-svgpathparser-1.7.jar">
      <manifest>
        <attribute name="Permissions"               value="all-permissions"/>
        <attribute name="Codebase"                  value="*"/>
        <attribute name="Caller-Allowable-Codebase" value="*"/>
      </manifest>
      <zipfileset src="lib/batik-svgpathparser-1.7.jar"/>
    </jar>
    <!-- No Print to PDF, Export to SVG, Export to PNG and Create video in viewer -->
  </target>

  <target name="otherLibraries" depends="viewerLibraries"
          description="Copies to deploy/lib the libraries used by Sweet Home 3D">
    <mkdir dir="deploy/lib"/>
    <!-- Copy jar files adding to their manifest attributes necessary
         to be able to call applet methods from JavaScript -->
    <jar destfile="deploy/lib/jeksparser-calculator.jar" filesetmanifest="merge">
      <manifest>
        <attribute name="Permissions"               value="all-permissions"/>
        <attribute name="Codebase"                  value="*"/>
        <attribute name="Caller-Allowable-Codebase" value="*"/>
      </manifest>
      <zipfileset src="lib/jeksparser-calculator.jar"/>
    </jar>
    <jar destfile="deploy/lib/freehep-vectorgraphics-svg-2.1.1c.jar" filesetmanifest="merge">
      <manifest>
        <attribute name="Permissions"               value="all-permissions"/>
        <attribute name="Codebase"                  value="*"/>
        <attribute name="Caller-Allowable-Codebase" value="*"/>
      </manifest>
      <zipfileset src="lib/freehep-vectorgraphics-svg-2.1.1c.jar"/>
    </jar>
    <jar destfile="deploy/lib/sunflow-0.07.3i.jar" filesetmanifest="merge">
      <manifest>
        <attribute name="Permissions"               value="all-permissions"/>
        <attribute name="Codebase"                  value="*"/>
        <attribute name="Caller-Allowable-Codebase" value="*"/>
      </manifest>
      <zipfileset src="lib/sunflow-0.07.3i.jar"/>
    </jar>
    <jar destfile="deploy/lib/iText-2.1.7.jar" filesetmanifest="merge">
      <manifest>
        <attribute name="Permissions"               value="all-permissions"/>
        <attribute name="Codebase"                  value="*"/>
        <attribute name="Caller-Allowable-Codebase" value="*"/>
      </manifest>
      <zipfileset src="lib/iText-2.1.7.jar"/>
    </jar>
    <jar destfile="deploy/lib/jmf.jar">
      <manifest>
        <attribute name="Permissions"               value="all-permissions"/>
        <attribute name="Codebase"                  value="*"/>
        <attribute name="Caller-Allowable-Codebase" value="*"/>
      </manifest>
      <zipfileset src="lib/jmf.jar"/>
    </jar>
  </target>

  <target name="javaWebStart" depends="application,furniture,textures,examples,help,java3dLibraries,otherLibraries,manifest"
          description="Builds deploy/lib/SweetHome3D.jar and signs jars required by Sweet Home 3D with Java Web Start">
    <!-- Build SweetHome3DJavaWebStart.jar file containing signed JNLP file -->
    <mkdir dir="build/JNLP-INF"/>
    <copy file="deploy/SweetHome3D.jnlp" tofile="build/JNLP-INF/APPLICATION.JNLP"/>
    <mkdir dir="deploy/lib"/>
    <jar destfile="deploy/lib/SweetHome3DJavaWebStart.jar" manifest="build/META-INF/MANIFEST.MF" filesetmanifest="merge">
      <manifest>
        <attribute name="Application-Name" value="Sweet Home 3D"/>
      </manifest>
      <fileset dir="build" includes="JNLP-INF/APPLICATION.JNLP"/>
    </jar>
    <!-- Build SweetHome3D.jar file from the content of built jars -->
    <jar destfile="deploy/lib/SweetHome3D.jar" manifest="build/META-INF/MANIFEST.MF" filesetmanifest="merge">
      <manifest>
        <attribute name="Application-Name" value="Sweet Home 3D"/>
      </manifest>
      <zipfileset src="build/SweetHome3D.jar"/>
      <zipfileset src="build/Furniture.jar"/>
      <zipfileset src="build/Textures.jar"/>
      <zipfileset src="build/Examples.jar"/>
      <zipfileset src="build/Help.jar"/>
    </jar>

    <!-- Clean build directory -->
    <delete dir="build"/>

    <input message="Enter Passphrase for keystore:" addproperty="password"/>
    <input message="Enter URL of timestamp authority:" addproperty="timestampAuthorityURL" defaultvalue="http://time.certum.pl/"/>
    <!-- Sign jar files in deploy/lib dir -->
    <signjar keystore="keys.p12" alias="SweetHome3D" storepass="${password}" tsaurl="${timestampAuthorityURL}" storetype="pkcs12">
      <fileset dir="deploy/lib">
        <include name="**/*.jar"/>
      </fileset>
    </signjar>

    <echo message="deploy dir ready for ftp"/>
  </target>

  <target name="applet" depends="build,java3dLibraries,java3dAllSystemsLibrary,otherLibraries"
          description="Builds deploy/lib/SweetHome3DApplet.jar and signs jars required by Sweet Home 3D applet">
    <!-- Create SweetHome3DApplet.jar containing Sweet Home 3D classes and resources -->
    <mkdir dir="deploy/lib"/>
    <copy file="deploy/SweetHome3DApplet.jnlp" tofile="build/JNLP-INF/APPLICATION.JNLP"/>
    <input message="Enter domain name where applet will be hosted:" addproperty="domain"/>
    <jar destfile="deploy/lib/SweetHome3DApplet.jar">
      <manifest>
        <attribute name="Application-Name"          value="Sweet Home 3D Online"/>
        <attribute name="Permissions"               value="all-permissions"/>
        <attribute name="Codebase"                  value="*"/>
        <!-- From Java 7u55, specifying domain is mandatory to call applet methods from JavaScript
             without security warning -->
        <attribute name="Caller-Allowable-Codebase" value="${domain}"/>
      </manifest>
      <fileset dir="build" includes="JNLP-INF/APPLICATION.JNLP"/>
      <zipfileset src="build/SweetHome3D.jar"
                  excludes="com/eteks/sweethome3d/*.*, com/eteks/sweethome3d/resources/**, com/eteks/sweethome3d/applet/*Viewer*.*"/>
    </jar>

    <!-- Clean build directory -->
    <delete dir="build"/>

    <input message="Enter Passphrase for keystore:" addproperty="password"/>
    <input message="Enter URL of timestamp authority:" addproperty="timestampAuthorityURL" defaultvalue="http://time.certum.pl/"/>
    <!-- Sign jar files in deploy/lib dir -->
    <signjar keystore="keys.p12" alias="SweetHome3D" storepass="${password}" tsaurl="${timestampAuthorityURL}" storetype="pkcs12">
      <fileset dir="deploy/lib">
        <include name="**/*.jar"/>
      </fileset>
    </signjar>

    <echo message="deploy dir ready for ftp"/>
  </target>

  <target name="viewer" depends="java3dLibraries,java3dAllSystemsLibrary,viewerLibraries,manifest"
          description="Builds deploy/lib/SweetHome3DViewer.jar and signs jars required by Sweet Home 3D viewer">
    <!-- Compile Sweet Home 3D Viewer-->
    <mkdir dir="build/classes"/>
    <!-- Compile Sweet Home 3D Viewer applet first with javac 1.1 to be able to detect current Java version
         during applet launch (otherwise Java 1.1 to 1.4 plug-ins refuse to load Applet class) -->
    <javac srcdir="src" destdir="build/classes"
           includes="com/eteks/sweethome3d/applet/SweetHome3DViewer.java"
           encoding="ISO-8859-1" target="${appletClassTarget}" source="${appletClassSource}"
           debug="false" debuglevel="lines,vars,source"/>
    <!-- Compile only classes depending on ViewerHelper to reduce Jar size -->
    <javac srcdir="src" destdir="build/classes"
           encoding="ISO-8859-1" target="${classTarget}" source="${classSource}"
           debug="false" debuglevel="lines,vars,source">
      <include name="com/eteks/sweethome3d/applet/ViewerHelper.java"/>
      <include name="com/eteks/sweethome3d/io/DefaultPatternTexture.java"/>
      <!-- Use lib as an extension directory to override default Java 3D libraries -->
      <extdirs>
        <pathelement location="lib"/>
      </extdirs>
      <classpath>
        <pathelement location="libtest/AppleJavaExtensions.jar"/>
        <pathelement location="libtest/javaAwtDesktop.jar"/>
        <pathelement location="libtest/jnlp.jar"/>
      </classpath>
    </javac>

    <!-- Copy only resources used by viewer -->
    <copy todir="build/classes">
      <fileset dir="src">
        <include name="com/eteks/sweethome3d/applet/*.properties"/>
        <include name="com/eteks/sweethome3d/model/*.properties"/>
        <include name="com/eteks/sweethome3d/tools/*.properties"/>
        <include name="com/eteks/sweethome3d/io/resources/patterns/*.png"/>
        <include name="com/eteks/sweethome3d/swing/resources/icons/tango/go-*.png"/>
        <include name="com/eteks/sweethome3d/swing/HomeComponent3D.properties"/>
      </fileset>
    </copy>

    <!-- Create SweetHome3DViewer.jar containing only classes and resources required by Sweet Home 3D Viewer -->
    <mkdir dir="deploy/lib"/>
    <copy file="deploy/SweetHome3DViewer.jnlp" tofile="build/JNLP-INF/APPLICATION.JNLP"/>
    <jar destfile="deploy/lib/SweetHome3DViewer.jar"
         basedir="build/classes" manifest="build/META-INF/MANIFEST.MF" filesetmanifest="merge">
      <manifest>
        <attribute name="Application-Name" value="Sweet Home 3D Viewer"/>
      </manifest>
      <fileset dir="build" includes="JNLP-INF/APPLICATION.JNLP"/>
      <include name="com/eteks/sweethome3d/applet/*"/>
      <include name="com/eteks/sweethome3d/io/**"/>
      <include name="com/eteks/sweethome3d/j3d/*"/>
      <include name="com/eteks/sweethome3d/model/*"/>
      <include name="com/eteks/sweethome3d/swing/**"/>
      <include name="com/eteks/sweethome3d/tools/*"/>
      <include name="com/eteks/sweethome3d/viewcontroller/*View*"/>
      <include name="com/eteks/sweethome3d/viewcontroller/Controller.*"/>
      <include name="com/eteks/sweethome3d/viewcontroller/ContentManager*"/>
      <include name="com/eteks/sweethome3d/viewcontroller/HomeController3D*"/>
      <include name="com/eteks/sweethome3d/viewcontroller/Object3DFactory*"/>
      <include name="com/eteks/sweethome3d/viewcontroller/ThreadedTaskController*"/>
    </jar>

    <!-- Clean build directory -->
    <delete dir="build"/>

    <input message="Enter Passphrase for keystore:" addproperty="password"/>
    <input message="Enter URL of timestamp authority:" addproperty="timestampAuthorityURL" defaultvalue="http://time.certum.pl/"/>
    <!-- Sign jar files in deploy/lib dir -->
    <signjar keystore="keys.p12" alias="SweetHome3D" storepass="${password}" tsaurl="${timestampAuthorityURL}" storetype="pkcs12">
      <fileset dir="deploy/lib">
        <include name="**/*.jar"/>
      </fileset>
    </signjar>

    <echo message="deploy dir ready for ftp"/>
  </target>

  <target name="jarExecutable" depends="application,furniture,textures,examples,help,jogl-java3d"
          description="Builds install/SweetHome3D-version.jar executable Jar">
    <!-- Create SweetHome3D-version.jar containing Sweet Home 3D classes and resources,
         and other DLLs and jars -->
    <jar destfile="install/SweetHome3D-${version}.jar">
      <manifest>
        <attribute name="Add-opens" value="java.desktop/java.awt java.desktop/sun.awt java.desktop/com.apple.eio java.desktop/com.apple.eawt"/>
      	<attribute name="Main-Class" value="com.eteks.sweethome3d.SweetHome3DBootstrap"/>
      </manifest>
      <zipfileset src="build/SweetHome3D.jar"/>
      <zipfileset src="build/Furniture.jar"/>
      <zipfileset src="build/Textures.jar"/>
      <zipfileset src="build/Examples.jar"/>
      <zipfileset src="build/Help.jar"/>
      <fileset dir="lib">
        <include name="*.jar"/>
        <include name="macosx/*.jar"/>
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
      <fileset dir="lib">
        <include name="windows/**/*.dll"/>
        <include name="java3d-1.6/windows/**/*.dll"/>
        <include name="yafaray/windows/**/*.dll"/>
        <include name="linux/**/*.so"/>
        <include name="java3d-1.6/linux/**/*.so"/>
        <include name="yafaray/linux/**/*.so"/>
        <include name="macosx/*.jnilib"/>
        <include name="java3d-1.6/macosx/*.dylib"/>
        <include name="yafaray/macosx/**/*.dylib"/>
      </fileset>
      <fileset dir="libtest">
        <include name="jnlp.jar"/>
      </fileset>
      <fileset dir=".">
        <include name="LICENSE.TXT"/>
        <include name="COPYING.TXT"/>
        <include name="THIRDPARTY-LICENSE-JAVA3D.TXT"/>
        <include name="THIRDPARTY-LICENSE-JOGL.TXT"/>
        <include name="THIRDPARTY-LICENSE-BATIK.TXT"/>
        <include name="THIRDPARTY-LICENSE-JEKSPARSER.TXT"/>
        <include name="THIRDPARTY-LICENSE-ITEXT.TXT"/>
        <include name="THIRDPARTY-LICENSE-VECTORGRAPHICS.TXT"/>
        <include name="THIRDPARTY-LICENSE-SUNFLOW.TXT"/>
        <include name="THIRDPARTY-LICENSE-YAFARAY.TXT"/>
        <include name="THIRDPARTY-LICENSE-JMF.HTML"/>
      </fileset>
    </jar>

    <!-- Clean build directory -->
    <delete dir="build"/>

    <echo message="install/SweetHome3D-${version}.jar ready for ftp"/>
  </target>

  <!-- Builds Sweet Home 3D Windows launcher in install/windows/build directory.
       CAUTION : May be run only under Windows 64 bit and requires Windows 32 bit JRE 1.8.0_202,
                 64 bit OpenJDK and launch4j installed in their default location -->
  <target name="windowsLauncher" depends="application,furniture,textures,examples,help,jogl-java3d"
          description="Builds Sweet Home 3D Windows launcher">
    <!-- Copy SweetHome3D JARs and Windows Java 3D DLLs and JARs for Java 3D
         to install/windows/build/lib -->
    <mkdir dir="install/windows/build/lib/java3d-1.6/x86"/>
    <move file="build/SweetHome3D.jar" todir="install/windows/build/lib" />
    <move file="build/Furniture.jar"   todir="install/windows/build/lib" />
    <move file="build/Textures.jar"    todir="install/windows/build/lib" />
    <move file="build/Examples.jar"    todir="install/windows/build/lib" />
    <move file="build/Help.jar"        todir="install/windows/build/lib" />
    <copy todir="install/windows/build/lib" >
      <fileset dir="lib">
        <include name="*.jar"/>
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
    </copy>
    <copy file="libtest/jnlp.jar" todir="install/windows/build/lib"/>
    <copy todir="install/windows/build/lib/x86" >
      <fileset dir="lib/windows/i386">
        <include name="*.dll"/>
      </fileset>
    </copy>
    <mkdir dir="install/windows/build/lib/yafaray/i386"/>
    <copy todir="install/windows/build/lib/yafaray/i386" >
      <fileset dir="lib/yafaray/windows/i386">
        <include name="**/*.dll"/>
      </fileset>
    </copy>
    <mkdir dir="install/windows/build/lib/x64"/>
    <copy todir="install/windows/build/lib/x64" >
      <fileset dir="lib/windows/x64">
        <include name="*.dll"/>
      </fileset>
    </copy>
    <copy todir="install/windows/build/lib/java3d-1.6/x86" >
      <fileset dir="lib/java3d-1.6/windows/i586">
        <include name="*.dll"/>
      </fileset>
    </copy>
    <mkdir dir="install/windows/build/lib/java3d-1.6/x64"/>
    <copy todir="install/windows/build/lib/java3d-1.6/x64" >
      <fileset dir="lib/java3d-1.6/windows/amd64">
        <include name="*.dll"/>
      </fileset>
    </copy>
    <mkdir dir="install/windows/build/lib/yafaray/x64"/>
    <copy todir="install/windows/build/lib/yafaray/x64" >
      <fileset dir="lib/yafaray/windows/x64">
        <include name="**/*.dll"/>
      </fileset>
    </copy>
    <!-- Copy COPYING.TXT and licenses texts to install/windows/build/ -->
    <copy file="COPYING.TXT" todir="install/windows/build"/>
    <copy file="LICENSE.TXT" todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-JAVA.TXT"      todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-OPENJDK.TXT"   todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-JAVA3D.TXT"    todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-JOGL.TXT"      todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-BATIK.TXT"     todir="install/windows/build"/>
    <copy file="THIRDPARTY-LICENSE-JEKSPARSER.TXT"     todir="install/windows/build"/>
    <copy file="THIRDPARTY-LICENSE-ITEXT.TXT"          todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-VECTORGRAPHICS.TXT" todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-SUNFLOW.TXT"   todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-YAFARAY.TXT"   todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-JMF.HTML"      todir="install/windows/build"/>
    <copy file="THIRDPARTY-LICENSE-LAUNCH4J.TXT"  todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-INNOSETUP.TXT" todir="install/windows/build" />

    <!-- Copy 32 bit JRE to install/windows/build/runtime/x86... excluding files mentioned
         in JRE README.TXT file (JRE bin/javaw.exe command excepted) -->
    <copy todir="install/windows/build/runtime/x86">
      <fileset dir="${javaHome_windows_x86}">
        <include name="*"/>
        <include name="bin/**"/>
        <include name="lib/**"/>

        <exclude name="lib/ext/sunec.jar"/>
        <exclude name="lib/ext/sunpkcs11.jar"/>
        <exclude name="bin/rmid.exe"/>
        <exclude name="bin/rmiregistry.exe"/>
        <exclude name="bin/tnameserv.exe"/>
        <exclude name="bin/keytool.exe"/>
        <exclude name="bin/kinit.exe"/>
        <exclude name="bin/klist.exe"/>
        <exclude name="bin/ktab.exe"/>
        <exclude name="bin/policytool.exe"/>
        <exclude name="bin/orbd.exe"/>
        <exclude name="bin/servertool.exe"/>
        <exclude name="lib/jfr/**"/>
        <exclude name="lib/jfr.jar"/>

        <exclude name="bin/java.exe"/>
        <exclude name="bin/javaws.exe"/>
        <exclude name="bin/javacpl.exe"/>
        <exclude name="bin/jucheck.exe"/>
        <exclude name="bin/dtplugin/**"/>
        <exclude name="bin/jabswitch.exe"/>
        <exclude name="bin/java_crw_demo.dll"/>
        <exclude name="bin/wsdetect.dll"/>
        <exclude name="bin/plugin2/**"/>
        <exclude name="bin/deploy.dll"/>
        <exclude name="bin/jfr.dll"/>
        <exclude name="bin/javacpl.dll"/>
        <exclude name="lib/deploy.jar"/>
        <exclude name="lib/plugin.jar"/>
        <exclude name="lib/deploy/**"/>
        <exclude name="lib/cmm/PYCC.pf"/>
        <!-- No need of JavaFX support -->
        <exclude name="THIRDPARTYLICENSEREADME-JAVAFX.txt"/>
        <exclude name="lib/javafx.properties"/>
        <exclude name="lib/jfxswt.jar"/>
        <exclude name="bin/decora_sse.dll"/>
        <exclude name="bin/fxplugins.dll"/>
        <exclude name="bin/glass.dll"/>
        <exclude name="bin/glib-lite.dll"/>
        <exclude name="bin/gstreamer-lite.dll"/>
        <exclude name="bin/javafx_font.dll"/>
        <exclude name="bin/javafx_font_t2k.dll"/>
        <exclude name="bin/javafx_iio.dll"/>
        <exclude name="bin/jfxmedia.dll"/>
        <exclude name="bin/jfxwebkit.dll"/>
        <exclude name="bin/prism_common.dll"/>
        <exclude name="bin/prism_d3d.dll"/>
        <exclude name="bin/prism_es2.dll"/>
        <exclude name="bin/prism_sw.dll"/>
        <exclude name="lib/ext/jfxrt.jar"/>
        <exclude name="lib/ext/nashorn.jar"/>
      </fileset>
    </copy>

     <!-- Copy 64 bit OpenJDK to install/windows/build/runtime/x64... -->
    <copy todir="install/windows/build/runtime/x64">
      <fileset dir="${javaHome_windows_x64}">
        <include name="release"/>
        <include name="readme.txt"/>
        <include name="DISCLAIMER"/>
        <include name="bin/*.dll"/>
        <include name="bin/server/*.dll"/>
        <include name="bin/javaw.exe"/>
        <include name="conf/**"/>
        <include name="lib/**"/>
        <include name="legal/**"/>
        <exclude name="bin/jabsysinfo.dll"/>
        <exclude name="bin/saproc.dll"/>
        <exclude name="lib/src.zip"/>
      </fileset>
    </copy>
    <!-- Remove legal files not exported by jpackage -->
    <delete dir="install/windows/build/runtime/x64/legal/jdk.jcmd"/>
    <delete dir="install/windows/build/runtime/x64/legal/jdk.hotspot.agent"/>
    <delete dir="install/windows/build/runtime/x64/legal/java.se"/>

    <!-- Create SweetHome3D-x86.exe and SweetHome3D-x64.exe with launch4j -->
    <exec executable="C:\Program Files (x86)\Launch4j\launch4jc.exe" failonerror="yes">
      <arg value="${basedir}\install\windows\installerLaunch4j-java3d-1.5.2-x86.xml"/>
    </exec>
    <exec executable="C:\Program Files (x86)\Launch4j\launch4jc.exe" failonerror="yes">
      <arg value="${basedir}\install\windows\installerLaunch4j-java3d-1.5.2-x86-d3d.xml"/>
    </exec>
    <exec executable="C:\Program Files (x86)\Launch4j\launch4jc.exe" failonerror="yes">
      <arg value="${basedir}\install\windows\installerLaunch4j-java3d-1.5.2-x64.xml"/>
    </exec>
    <exec executable="C:\Program Files (x86)\Launch4j\launch4jc.exe" failonerror="yes">
      <arg value="${basedir}\install\windows\installerLaunch4j-x86.xml"/>
    </exec>
    <exec executable="C:\Program Files (x86)\Launch4j\launch4jc.exe" failonerror="yes">
      <arg value="${basedir}\install\windows\installerLaunch4j-x64.xml"/>
    </exec>

    <!-- Pack 32 bit JRE rt.jar -->
    <exec executable="${javaHome_windows_x86}\bin\pack200.exe" failonerror="yes">
      <arg value="-J-Xmx512m"/>
      <arg value="${basedir}\install\windows\build\runtime\x86\lib\rt.pack.gz"/>
      <arg value="${basedir}\install\windows\build\runtime\x86\lib\rt.jar"/>
    </exec>
    <delete file="${basedir}\install\windows\build\runtime\x86\lib\rt.jar"/>
  </target>

  <!-- Builds install/SweetHome3D-version-windows.exe installer able to install SweetHome3D.exe
       with a Windows JRE and Sweet Home 3D libraries.
       CAUTION : May be run only under Windows 64 bit and requires Windows 32 bit JRE 1.8.0_202,
                 64 bit JRE 1.8.0_202, launch4j and Inno Setup 5 Unicode installed in their default location -->
  <target name="windowsInstaller" depends="windowsLauncher"
          description="Builds install/SweetHome3D-version-windows.exe installer">
    <!-- Create SweetHome3D-version-windows.exe with Inno Setup 5 Unicode -->
    <exec executable="C:\Program Files (x86)\Inno Setup 5\ISCC.exe" failonerror="yes">
      <arg value="${basedir}\install\windows\installerInnoSetup.iss"/>
    </exec>

    <move todir="${basedir}\install">
      <fileset dir="${basedir}\install\windows">
        <include name="SweetHome3D*.exe"/>
      </fileset>
    </move>

    <!-- Clean build directories -->
    <delete dir="build"/>
    <delete dir="install/windows/build"/>

    <echo message="install/SweetHome3D-${version}-windows.exe ready for ftp"/>
  </target>

  <!-- Builds install/SweetHome3D-version-windows.exe signed installer able to install SweetHome3D.exe
       with a Windows JRE and Sweet Home 3D libraries.
       CAUTION : May be run only under Windows 64 bit and requires Windows 32 bit JRE 1.8.0_202,
                 64 bit JRE 1.8.0_202, launch4j, Inno Setup 5 Unicode and SignTool included in Windows platform SDK
                 installed in their default location -->
  <target name="windowsSignedInstaller" depends="windowsLauncher"
          description="Builds install/SweetHome3D-version-windows.exe installer">
    <input message="Enter signature password:" addproperty="password"/>
    <input message="Enter URL of timestamp authority:" addproperty="timestampAuthorityURL" defaultvalue="http://time.certum.pl/"/>
    <!-- Sign Sweet Home 3D launchers -->
    <exec executable="C:\Program Files (x86)\Windows Kits\8.1\bin\x86\signtool.exe" failonerror="yes">
      <arg value="sign"/>
      <arg value="/f"/>
      <arg value="${basedir}\keys.p12"/>
      <arg value="/p"/>
      <arg value="${password}"/>
      <arg value="/t"/>
      <arg value="${timestampAuthorityURL}"/>
      <arg value="${basedir}\install\windows\build\SweetHome3D-java3d-1.5.2-x86-d3d.exe"/>
      <arg value="${basedir}\install\windows\build\SweetHome3D-java3d-1.5.2-x86.exe"/>
      <arg value="${basedir}\install\windows\build\SweetHome3D-java3d-1.5.2-x64.exe"/>
      <arg value="${basedir}\install\windows\build\SweetHome3D-x86.exe"/>
      <arg value="${basedir}\install\windows\build\SweetHome3D-x64.exe"/>
    </exec>
    <!-- Create signed SweetHome3D-version-windows.exe with Inno Setup 5 Unicode -->
    <exec executable="C:\Program Files (x86)\Inno Setup 5\ISCC.exe" failonerror="yes">
      <arg value="/sSignToolPgm=$$qC:\Program Files (x86)\Windows Kits\8.1\bin\x86\signtool.exe$$q sign /f $$q${basedir}\keys.p12$$q /p ${password} /t ${timestampAuthorityURL} $p"/>
      <arg value="${basedir}\install\windows\signedInstallerInnoSetup.iss"/>
    </exec>

    <move todir="${basedir}\install">
      <fileset dir="${basedir}\install\windows">
        <include name="SweetHome3D*.exe"/>
      </fileset>
    </move>

    <!-- Clean build directories -->
    <delete dir="build"/>
    <delete dir="install/windows/build"/>

    <echo message="signed install/SweetHome3D-${version}-windows.exe ready for ftp"/>
  </target>

  <!-- Builds Sweet Home 3D Mac OS X application bundle in install/macosx/10.4/SweetHome3D-version directory. -->
  <target name="macosx10.4Bundle" depends="application,furniture,textures,examples,help"
          description="Builds Sweet Home 3D Mac OS X application bundle">
    <!-- Build Sweet Home 3D version for Mac OS X 10.4 to 10.9 based on Apple Java and Java 3D 1.5.2-->
    <mkdir dir="install/macosx/10.4/SweetHome3D-${version}"/>
    <copy todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app">
      <fileset dir="install/macosx/10.4/Sweet Home 3D"/>
    </copy>
    <!-- Copy ICNS files of Mac OS X standard version -->
    <copy todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources">
      <fileset dir="install/macosx/Sweet Home 3D/Contents/Resources"/>
    </copy>

    <!-- Change executable permission of SweetHome3D lost during copy task -->
    <chmod perm="+x" file="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/MacOS/SweetHome3D"/>

    <!-- Copy SweetHome3D JARs and its direct libs
         to install/macosx/10.4/SweetHome3D-version/Sweet Home 3D.app/Contents/Resources/Java -->
    <mkdir dir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java/ext"/>
    <move file="build/SweetHome3D.jar" todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" />
    <move file="build/Furniture.jar"   todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" />
    <move file="build/Textures.jar"    todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" />
    <move file="build/Examples.jar"    todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" />
    <move file="build/Help.jar"        todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" />
    <copy todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" >
      <fileset dir="lib">
        <include name="*.jar"/>
        <exclude name="jmf.jar"/>
        <exclude name="j3dcore.jar"/>
        <exclude name="j3dutils.jar"/>
        <exclude name="vecmath.jar"/>
        <!-- Print to PDF menu item isn't available under Mac OS X as it's already in standard print dialog -->
        <exclude name="iText-2.1.7.jar"/>
      </fileset>
    </copy>
    <!-- Copy jnlp.jar, JMF and Mac OS X Java 3D 1.5.2 DLLs and JARs for Java 3D
         to install/macosx/10.4/SweetHome3D-version/Sweet Home 3D.app/Contents/Resources/Java/ext -->
    <copy file="libtest/jnlp.jar" todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java/ext"/>
    <copy file="lib/jmf.jar" todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java/ext"/>
    <copy todir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java/ext" >
      <fileset dir="lib">
        <include name="j3dcore.jar"/>
        <include name="j3dutils.jar"/>
        <include name="vecmath.jar"/>
      </fileset>
      <fileset dir="lib/macosx">
        <include name="*.jar"/>
        <include name="*.jnilib"/>
      </fileset>
      <fileset dir="lib/yafaray/macosx">
        <include name="**/*.dylib"/>
      </fileset>
    </copy>

    <!-- Keep only x86_64 arch in YafaRay .dylib files of Java/ext folder with lipo -->
    <exec executable="find" dir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java/ext" failonerror="yes">
      <arg value="."/>
      <arg value="-type"/>
      <arg value="f"/>
      <arg value="-name"/>
      <arg value="libyafaray*.dylib"/>
      <arg value="-exec"/>
      <arg value="lipo"/>
      <arg value="{}"/>
      <arg value="-thin"/>
      <arg value="x86_64"/>
      <arg value="-output"/>
      <arg value="{}"/>
      <arg value=";"/>
    </exec>
    <exec executable="find" dir="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java/ext/yafaray-plugins" failonerror="yes">
      <arg value="."/>
      <arg value="-type"/>
      <arg value="f"/>
      <arg value="-name"/>
      <arg value="*.dylib"/>
      <arg value="-exec"/>
      <arg value="lipo"/>
      <arg value="{}"/>
      <arg value="-thin"/>
      <arg value="x86_64"/>
      <arg value="-output"/>
      <arg value="{}"/>
      <arg value=";"/>
    </exec>

    <!-- Copy COPYING.TXT and licenses texts to install/macosx/10.4/SweetHome3D-version/ -->
    <copy file="COPYING.TXT" todir="install/macosx/10.4/SweetHome3D-${version}"/>
    <copy file="LICENSE.TXT" todir="install/macosx/10.4/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JAVA3D.TXT"     todir="install/macosx/10.4/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-BATIK.TXT"      todir="install/macosx/10.4/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JEKSPARSER.TXT"     todir="install/macosx/10.4/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-VECTORGRAPHICS.TXT" todir="install/macosx/10.4/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-SUNFLOW.TXT"    todir="install/macosx/10.4/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-YAFARAY.TXT"    todir="install/macosx/10.4/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JMF.HTML"       todir="install/macosx/10.4/SweetHome3D-${version}" />
  </target>

  <!-- Builds install/SweetHome3D-version-macosx-10.4-10.9.dmg archive that contains SweetHome3D.app
       and Sweet Home 3D libraries.
       CAUTION : May be run only under Mac OS X and requires Disk Utility -->
  <target name="macosx10.4Installer" depends="macosx10.4Bundle"
          description="Builds install/SweetHome3D-version-macosx-10.4-10.9.dmg archive">
    <!-- Create install/SweetHome3D-version-macosx-10.4-10.9.dmg with Disk Utility -->
    <delete file="install/SweetHome3D-${version}-macosx-10.4-10.9.dmg"/>
    <exec executable="hdiutil" failonerror="yes">
      <arg value="create"/>
      <arg value="-fs"/>
      <arg value="HFS+"/>
      <arg value="-srcfolder"/>
      <arg value="install/macosx/10.4/SweetHome3D-${version}"/>
      <arg value="install/SweetHome3D-${version}-macosx-10.4-10.9.dmg"/>
    </exec>

    <!-- Clean build directories -->
    <delete dir="build"/>
    <delete dir="install/macosx/10.4/SweetHome3D-${version}"/>

    <echo message="install/SweetHome3D-${version}-macosx-10.4-10.9.dmg ready for ftp"/>
  </target>

  <!-- Builds install/SweetHome3D-version-macosx-10.4-10.9.dmg signed archive that contains SweetHome3D.app
       and Sweet Home 3D libraries.
       CAUTION : May be run only under Mac OS X and requires hdiutil, codesign
                 and a certificate imported in Keychain Access -->
  <target name="macosx10.4SignedInstaller" depends="macosx10.4Bundle"
          description="Builds install/SweetHome3D-version-macosx-10.4-10.9.dmg archive">
    <input message="Enter Developer ID Application certificate name:" addproperty="certificateName"/>
    <!-- Sign Sweet Home 3D application bundle -->
    <exec executable="codesign" failonerror="yes">
      <arg value="-f"/>
      <arg value="-s"/>
      <arg value="${certificateName}"/>
      <arg value="install/macosx/10.4/SweetHome3D-${version}/Sweet Home 3D.app"/>
    </exec>

    <!-- Create install/SweetHome3D-version-macosx-10.4-10.9.dmg with Disk Utility -->
    <delete file="install/SweetHome3D-${version}-macosx-10.4-10.9.dmg"/>
    <exec executable="hdiutil" failonerror="yes">
      <arg value="create"/>
      <arg value="-fs"/>
      <arg value="HFS+"/>
      <arg value="-format"/>
      <arg value="UDBZ"/>
      <arg value="-srcfolder"/>
      <arg value="install/macosx/10.4/SweetHome3D-${version}"/>
      <arg value="install/SweetHome3D-${version}-macosx-10.4-10.9.dmg"/>
    </exec>

    <!-- Sign Sweet Home 3D DMG image -->
    <exec executable="codesign" failonerror="yes">
      <arg value="-s"/>
      <arg value="${certificateName}"/>
      <arg value="install/SweetHome3D-${version}-macosx-10.4-10.9.dmg"/>
    </exec>

    <!-- Clean build directories -->
    <delete dir="build"/>
    <delete dir="install/macosx/10.4/SweetHome3D-${version}"/>

    <echo message="signed install/SweetHome3D-${version}-macosx-10.4-10.9.dmg ready for ftp"/>
  </target>

  <!-- Builds Sweet Home 3D Mac OS X application bundle in install/macosx/SweetHome3D-version directory.
       CAUTION : May be run only under Mac OS X and requires
       OpenJDK 15.0.2 for x86_64 installed in /Library/Java/JavaVirtualMachines/zulu-15.0.2-macosx_x86_64.jdk and
       OpenJDK 15.0.2 for arm64  installed in /Library/Java/JavaVirtualMachines/zulu-15.0.2-macosx_aarch64.jdk -->
  <target name="macosxBundle" depends="application,furniture,textures,examples,help,jogl-java3d"
          description="Builds Sweet Home 3D Mac OS X application bundle">
    <!-- Copy Sweet Home 3D files to install/macosx/SweetHome3D-version/Sweet Home 3D.app -->
    <mkdir dir="install/macosx/SweetHome3D-${version}"/>
    <copy todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app">
      <fileset dir="install/macosx/Sweet Home 3D"/>
    </copy>

    <!-- Change executable permission of SweetHome3D lost during copy task -->
    <chmod perm="+x" file="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/MacOS/SweetHome3D"/>

    <!-- Copy SweetHome3D JARs and its direct libs
         to install/macosx/SweetHome3D-version/Sweet Home 3D.app/Contents/app -->
    <move file="build/SweetHome3D.jar" todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/app" />
    <move file="build/Furniture.jar"   todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/app" />
    <move file="build/Textures.jar"    todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/app" />
    <move file="build/Examples.jar"    todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/app" />
    <move file="build/Help.jar"        todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/app" />
    <copy todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/app" >
      <fileset dir="lib">
        <include name="*.jar"/>
        <exclude name="j3dcore.jar"/>
        <exclude name="j3dutils.jar"/>
        <exclude name="vecmath.jar"/>
        <!-- Print to PDF menu item isn't available under Mac OS X as it's already in standard print dialog -->
        <exclude name="iText-2.1.7.jar"/>
      </fileset>
    </copy>
    <!-- Copy jnlp.jar, JARs for Java 3D, Mac OS X Java 3D 1.6 and YafaRay DLLs and
         to install/macosx/SweetHome3D-version/Sweet Home 3D.app/Contents/app -->
    <copy file="libtest/jnlp.jar" todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/app"/>
    <copy todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/app" >
      <fileset dir="lib/java3d-1.6">
        <include name="*.jar"/>
        <exclude name="jogl-all.jar"/>
      </fileset>
      <fileset dir="build/java3d-1.6">
        <include name="jogl-java3d.jar"/>
      </fileset>
      <fileset dir="lib/java3d-1.6/macosx">
        <include name="*.dylib"/>
      </fileset>
      <fileset dir="lib/yafaray/macosx">
        <include name="**/*.dylib"/>
      </fileset>
    </copy>

    <!-- Create directories required by OpenJDK AppBundler -->
    <mkdir dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home" />
    <mkdir dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/MacOS" />
    <!-- Copy OpenJDK files generated by jpackage to install/macosx/SweetHome3D-version/Contents/runtime/Contents/Home -->
    <copy file="${javaHome_macosx_arm64}/../MacOS/libjli.dylib"
          todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/MacOS"/>
    <copy todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home">
      <fileset dir="${javaHome_macosx_arm64}">
        <include name="readme.txt"/>
        <include name="DISCLAIMER"/>
        <include name="conf/**"/>
        <include name="lib/**"/>
        <exclude name="lib/libsaproc.dylib"/>
        <exclude name="lib/src.zip"/>
      </fileset>
    </copy>
    <!-- Copy legal files with their symlinks -->
    <exec executable="cp" failonerror="yes">
      <arg value="-R"/>
      <arg value="${javaHome_macosx_arm64}/legal"/>
      <arg value="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home"/>
    </exec>
    <!-- Remove legal files not exported by jpackage -->
    <delete dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home/legal/jdk.jcmd"/>
    <delete dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home/legal/jdk.internal.vm.compiler"/>
    <delete dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home/legal/jdk.internal.vm.ci"/>
    <delete dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home/legal/jdk.hotspot.agent"/>
    <delete dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home/legal/jdk.aot"/>
    <delete dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home/legal/java.se"/>

    <!-- Build Universal OpenJDK with lipo -->
    <exec executable="find" dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents" failonerror="yes">
      <arg value="."/>
      <arg value="-type"/>
      <arg value="f"/>
      <arg value="("/>
      <arg value="-name"/>
      <arg value="*.dylib"/>
      <arg value="-or"/>
      <arg value="-name"/>
      <arg value="jspawnhelper"/>
      <arg value=")"/>
      <arg value="-exec"/>
      <arg value="lipo"/>
      <arg value="${javaHome_macosx_arm64}/../{}"/>
      <arg value="${javaHome_macosx_x86_64}/../{}"/>
      <arg value="-output"/>
      <arg value="{}"/>
      <arg value="-create"/>
      <arg value=";"/>
    </exec>

    <!-- Change executable permission of jspawnhelper lost during copy task -->
    <chmod perm="+x" file="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/runtime/Contents/Home/lib/jspawnhelper"/>

    <!-- Copy COPYING.TXT and licenses texts to install/macosx/SweetHome3D-version/ -->
    <copy file="COPYING.TXT" todir="install/macosx/SweetHome3D-${version}"/>
    <copy file="LICENSE.TXT" todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-OPENJDK.TXT"   todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JAVA3D.TXT"     todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JOGL.TXT"       todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-BATIK.TXT"      todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JEKSPARSER.TXT"     todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-VECTORGRAPHICS.TXT" todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-SUNFLOW.TXT"    todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-YAFARAY.TXT"    todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JMF.HTML"       todir="install/macosx/SweetHome3D-${version}" />
  </target>

  <!-- Builds install/SweetHome3D-version-macosx.dmg archive that contains SweetHome3D.app
       and Sweet Home 3D libraries.
       CAUTION : May be run only under Mac OS X and requires Disk Utility,
                 OpenJDK 15.0.2 for x86_64 installed in /Library/Java/JavaVirtualMachines/zulu-15.0.2-macosx_x86_64.jdk and
                 OpenJDK 15.0.2 for arm64  installed in /Library/Java/JavaVirtualMachines/zulu-15.0.2-macosx_aarch64.jdk -->
  <target name="macosxInstaller" depends="macosxBundle"
          description="Builds install/SweetHome3D-version-macosx.dmg archive">
    <!-- Create install/SweetHome3D-version-macosx.dmg with Disk Utility -->
    <delete file="install/SweetHome3D-${version}-macosx.dmg"/>
    <exec executable="hdiutil" failonerror="yes">
      <arg value="create"/>
      <arg value="-fs"/>
      <arg value="HFS+"/>
      <arg value="-format"/>
      <arg value="UDBZ"/>
      <arg value="-srcfolder"/>
      <arg value="install/macosx/SweetHome3D-${version}"/>
      <arg value="install/SweetHome3D-${version}-macosx.dmg"/>
    </exec>

    <!-- Clean build directories -->
    <delete dir="build"/>
    <delete dir="install/macosx/SweetHome3D-${version}"/>

    <echo message="install/SweetHome3D-${version}-macosx.dmg ready for ftp"/>
  </target>

  <!-- Builds install/SweetHome3D-version-macosx.dmg signed archive that contains SweetHome3D.app
       and Sweet Home 3D libraries.
       CAUTION : May be run only under Mac OS X and requires
                 OpenJDK 15.0.2 for x86_64 installed in /Library/Java/JavaVirtualMachines/zulu-15.0.2-macosx_x86_64.jdk,
                 OpenJDK 15.0.2 for arm64  installed in /Library/Java/JavaVirtualMachines/zulu-15.0.2-macosx_aarch64.jdk,
                 lipo, hdiutil, codesign and a certificate imported in Keychain Access -->
  <target name="macosxSignedInstaller" depends="macosxBundle"
          description="Builds install/SweetHome3D-version-macosx.dmg archive">
    <input message="Enter Developer ID Application certificate name:" addproperty="certificateName"/>
    <!-- Sign libraries, executables then Sweet Home 3D application bundle for notarization -->
    <exec executable="find" failonerror="yes">
      <arg value="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents"/>
      <arg value="-type"/>
      <arg value="f"/>
      <arg value="("/>
      <arg value="-name"/>
      <arg value="*.dylib"/>
      <arg value="-or"/>
      <arg value="-name"/>
      <arg value="SweetHome3D"/>
      <arg value="-or"/>
      <arg value="-name"/>
      <arg value="JavaNativeFoundation"/>
      <arg value="-or"/>
      <arg value="-name"/>
      <arg value="jspawnhelper"/>
      <arg value=")"/>
      <arg value="-exec"/>
      <arg value="codesign"/>
      <arg value="-v"/>
      <arg value="-f"/>
      <arg value="-s"/>
      <arg value="${certificateName}"/>
      <arg value="--options=runtime"/>
      <arg value="--entitlements"/>
      <arg value="install/macosx/SweetHome3D.entitlements"/>
      <arg value="{}"/>
      <arg value=";"/>
    </exec>

    <!-- Sign Sweet Home 3D application bundle -->
    <exec executable="codesign" failonerror="yes">
      <arg value="-f"/>
      <arg value="-s"/>
      <arg value="${certificateName}"/>
      <arg value="--options=runtime"/>
      <arg value="--entitlements"/>
      <arg value="install/macosx/SweetHome3D.entitlements"/>
      <arg value="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app"/>
    </exec>

    <!-- Create install/SweetHome3D-version-macosx.dmg with Disk Utility -->
    <delete file="install/SweetHome3D-${version}-macosx.dmg"/>
    <exec executable="hdiutil" failonerror="yes">
      <arg value="create"/>
      <arg value="-fs"/>
      <arg value="HFS+"/>
      <arg value="-format"/>
      <arg value="UDBZ"/>
      <arg value="-srcfolder"/>
      <arg value="install/macosx/SweetHome3D-${version}"/>
      <arg value="install/SweetHome3D-${version}-macosx.dmg"/>
    </exec>

    <!-- Sign Sweet Home 3D DMG image -->
    <exec executable="codesign" failonerror="yes">
      <arg value="-s"/>
      <arg value="${certificateName}"/>
      <arg value="--options=runtime"/>
      <arg value="--entitlements"/>
      <arg value="install/macosx/SweetHome3D.entitlements"/>
      <arg value="install/SweetHome3D-${version}-macosx.dmg"/>
    </exec>

    <!-- Clean build directories -->
    <delete dir="build"/>
    <delete dir="install/macosx/SweetHome3D-${version}"/>

    <echo message="signed install/SweetHome3D-${version}-macosx.dmg ready for ftp"/>
  </target>

  <!-- Builds install/SweetHome3D-version-linux-x86.tgz archive that contains SweetHome3D command
       with a Linux JRE and Sweet Home 3D libraries.
       CAUTION : Requires a Linux 32 bit JRE installed in jre1.8.0_202 -->
  <target name="linux32Installer" depends="application,furniture,textures,examples,help,jogl-java3d"
          description="Builds install/SweetHome3D-version-linux-x86.tgz archive">
    <!-- Copy SweetHome3D.jar and Linux Java 3D DLLs and JARs for Java 3D
         to install/linux/x86/SweetHome3D-version/lib -->
    <mkdir dir="install/linux/x86/SweetHome3D-${version}/lib"/>
    <!-- Copy SweetHome3D commands -->
    <copy todir="install/linux/x86/SweetHome3D-${version}" file="install/linux/SweetHome3D"/>
    <copy todir="install/linux/x86/SweetHome3D-${version}" file="install/linux/SweetHome3D-Java3D-1_5_2"/>

    <!-- Copy SweetHome3D JARs and its direct libs
         to install/linux/x86/SweetHome3D-version/lib -->
    <move file="build/SweetHome3D.jar" todir="install/linux/x86/SweetHome3D-${version}/lib" />
    <move file="build/Furniture.jar"   todir="install/linux/x86/SweetHome3D-${version}/lib" />
    <move file="build/Textures.jar"    todir="install/linux/x86/SweetHome3D-${version}/lib" />
    <move file="build/Examples.jar"    todir="install/linux/x86/SweetHome3D-${version}/lib" />
    <move file="build/Help.jar"        todir="install/linux/x86/SweetHome3D-${version}/lib" />
    <copy todir="install/linux/x86/SweetHome3D-${version}/lib" >
      <fileset dir="lib">
        <include name="*.jar"/>
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
    </copy>
    <copy file="libtest/jnlp.jar" todir="install/linux/x86/SweetHome3D-${version}/lib"/>
    <copy todir="install/linux/x86/SweetHome3D-${version}/lib" >
      <fileset dir="lib/linux/i386">
        <include name="*.so"/>
      </fileset>
    </copy>
    <copy todir="install/linux/x86/SweetHome3D-${version}/lib/java3d-1.6" >
      <fileset dir="lib/java3d-1.6/linux/i586">
        <include name="*.so"/>
      </fileset>
    </copy>
    <copy todir="install/linux/x86/SweetHome3D-${version}/lib/yafaray" >
      <fileset dir="lib/yafaray/linux/i386">
        <include name="**/*.so"/>
      </fileset>
    </copy>
    <copy file="COPYING.TXT" todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="LICENSE.TXT" todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JAVA.TXT"      todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JAVA3D.TXT"    todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JOGL.TXT"      todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-BATIK.TXT"     todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JEKSPARSER.TXT"     todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-ITEXT.TXT"          todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-VECTORGRAPHICS.TXT" todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-SUNFLOW.TXT"   todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-YAFARAY.TXT"   todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JMF.HTML"      todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="src/com/eteks/sweethome3d/swing/resources/aboutIcon.png"
        tofile="install/linux/x86/SweetHome3D-${version}/SweetHome3DIcon.png"/>

    <!-- Copy JRE to install/linux/x86/SweetHome3D-version/runtime... excluding files mentioned
         in JRE README.TXT file (JRE bin/java command excepted) -->
    <copy todir="install/linux/x86/SweetHome3D-${version}/runtime">
      <fileset dir="${javaHome_linux_x86}">
        <include name="**"/>
        <exclude name="lib/ext/sunec.jar"/>
        <exclude name="lib/ext/sunpkcs11.jar"/>
        <exclude name="bin/rmid"/>
        <exclude name="bin/rmiregistry"/>
        <exclude name="bin/tnameserv"/>
        <exclude name="bin/keytool"/>
        <exclude name="bin/policytool"/>
        <exclude name="bin/orbd"/>
        <exclude name="bin/servertool"/>
        <exclude name="lib/cmm/PYCC.pf"/>
        <exclude name="lib/jfr"/>
        <exclude name="lib/jfr.jar"/>
        <!-- No need of JavaFX support -->
        <exclude name="THIRDPARTYLICENSEREADME-JAVAFX.txt"/>
        <exclude name="lib/javafx.properties"/>
        <exclude name="lib/i386/libdecora_sse.so"/>
        <exclude name="lib/i386/libfxplugins.so"/>
        <exclude name="lib/i386/libglass.so"/>
        <exclude name="lib/i386/libgstreamer-lite.so"/>
        <exclude name="lib/i386/libjavafx_font_freetype.so"/>
        <exclude name="lib/i386/libjavafx_font_pango.so"/>
        <exclude name="lib/i386/libjavafx_font_t2k.so"/>
        <exclude name="lib/i386/libjavafx_font.so"/>
        <exclude name="lib/i386/libjavafx_iio.so"/>
        <exclude name="lib/i386/libjfxmedia.so"/>
        <exclude name="lib/i386/libjfxwebkit.so"/>
        <exclude name="lib/i386/libprism_common.so"/>
        <exclude name="lib/i386/libprism_es2.so"/>
        <exclude name="lib/i386/libprism_sw.so"/>
        <exclude name="lib/ext/jfxrt.jar"/>
        <exclude name="lib/ext/nashorn.jar"/>
      </fileset>
    </copy>

    <!-- Create SweetHome3D-version-linux-x86.tgz archive -->
    <tar destfile="install/SweetHome3D-${version}-linux-x86.tgz"
         compression="gzip">
      <tarfileset dir="install/linux/x86"
                  includes="SweetHome3D-${version}/**">
        <exclude name="SweetHome3D-${version}/SweetHome3D"/>
        <exclude name="SweetHome3D-${version}/SweetHome3D-Java3D-1_5_2"/>
        <exclude name="SweetHome3D-${version}/runtime/bin/java"/>
      </tarfileset>
      <!-- Change executable permission of SweetHome3D and java commands -->
      <tarfileset dir="install/linux/x86" mode="755">
        <include name="SweetHome3D-${version}/SweetHome3D"/>
        <include name="SweetHome3D-${version}/SweetHome3D-Java3D-1_5_2"/>
        <include name="SweetHome3D-${version}/runtime/bin/java"/>
      </tarfileset>
    </tar>

    <!-- Clean build directories -->
    <delete dir="build"/>
    <delete dir="install/linux/x86"/>

    <echo message="install/SweetHome3D-${version}-linux-x86.tgz ready for ftp"/>
  </target>

  <!-- Builds install/SweetHome3D-version-linux-x64.tgz archive that contains SweetHome3D command
       with a Linux JRE and Sweet Home 3D libraries.
       CAUTION : Requires a Linux 64 bit JRE installed in jre1.8.0_202 -->
  <target name="linux64Installer" depends="application,furniture,textures,examples,help,jogl-java3d"
          description="Builds install/SweetHome3D-version-linux-x64.tgz archive">
    <!-- Copy SweetHome3D.jar and Linux Java 3D DLLs and JARs for Java 3D
         to install/linux/x64/SweetHome3D-version/lib -->
    <mkdir dir="install/linux/x64/SweetHome3D-${version}/lib"/>
    <!-- Copy SweetHome3D commands -->
    <copy todir="install/linux/x64/SweetHome3D-${version}" file="install/linux/SweetHome3D" />
    <copy todir="install/linux/x64/SweetHome3D-${version}" file="install/linux/SweetHome3D-Java3D-1_5_2"/>
    <!-- Change max memory Java parameter -->
    <replace dir="install/linux/x64" token=" -Xmx1024m " value=" -Xmx2g "/>

    <!-- Copy SweetHome3D JARs and its direct libs
         to install/linux/x64/SweetHome3D-version/lib -->
    <move file="build/SweetHome3D.jar" todir="install/linux/x64/SweetHome3D-${version}/lib" />
    <move file="build/Furniture.jar"   todir="install/linux/x64/SweetHome3D-${version}/lib" />
    <move file="build/Textures.jar"    todir="install/linux/x64/SweetHome3D-${version}/lib" />
    <move file="build/Examples.jar"    todir="install/linux/x64/SweetHome3D-${version}/lib" />
    <move file="build/Help.jar"        todir="install/linux/x64/SweetHome3D-${version}/lib" />
    <copy todir="install/linux/x64/SweetHome3D-${version}/lib" >
      <fileset dir="lib">
        <include name="*.jar"/>
        <include name="java3d-1.6/*.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
    </copy>
    <copy file="libtest/jnlp.jar" todir="install/linux/x64/SweetHome3D-${version}/lib"/>
    <copy todir="install/linux/x64/SweetHome3D-${version}/lib" >
      <fileset dir="lib/linux/x64">
        <include name="*.so"/>
      </fileset>
    </copy>
    <copy todir="install/linux/x64/SweetHome3D-${version}/lib/java3d-1.6" >
      <fileset dir="lib/java3d-1.6/linux/amd64">
        <include name="*.so"/>
      </fileset>
    </copy>
    <copy todir="install/linux/x64/SweetHome3D-${version}/lib/yafaray" >
      <fileset dir="lib/yafaray/linux/x64">
        <include name="**/*.so"/>
      </fileset>
    </copy>
    <copy file="COPYING.TXT" todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="LICENSE.TXT" todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JAVA.TXT"      todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JAVA3D.TXT"    todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JOGL.TXT"      todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-BATIK.TXT"     todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JEKSPARSER.TXT"     todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-ITEXT.TXT"          todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-VECTORGRAPHICS.TXT" todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-SUNFLOW.TXT"   todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-YAFARAY.TXT"   todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-JMF.HTML"      todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="src/com/eteks/sweethome3d/swing/resources/aboutIcon.png"
        tofile="install/linux/x64/SweetHome3D-${version}/SweetHome3DIcon.png"/>

    <!-- Copy JRE to install/linux/x64/SweetHome3D-version/runtime... excluding files mentioned
         in JRE README.TXT file (JRE bin/java command excepted) -->
    <copy todir="install/linux/x64/SweetHome3D-${version}/runtime">
      <fileset dir="${javaHome_linux_x64}">
        <include name="**"/>
        <exclude name="lib/ext/sunec.jar"/>
        <exclude name="lib/ext/sunpkcs11.jar"/>
        <exclude name="bin/rmid"/>
        <exclude name="bin/rmiregistry"/>
        <exclude name="bin/tnameserv"/>
        <exclude name="bin/keytool"/>
        <exclude name="bin/policytool"/>
        <exclude name="bin/orbd"/>
        <exclude name="bin/servertool"/>
        <exclude name="lib/cmm/PYCC.pf"/>
        <exclude name="lib/jfr"/>
        <exclude name="lib/jfr.jar"/>
        <!-- No need of JavaFX support -->
        <exclude name="THIRDPARTYLICENSEREADME-JAVAFX.txt"/>
        <exclude name="lib/javafx.properties"/>
        <exclude name="lib/amd64/libdecora_sse.so"/>
        <exclude name="lib/amd64/libprism_common.so"/>
        <exclude name="lib/amd64/libprism_es2.so"/>
        <exclude name="lib/amd64/libprism_sw.so"/>
        <exclude name="lib/amd64/libfxplugins.so"/>
        <exclude name="lib/amd64/libglass.so"/>
        <exclude name="lib/amd64/libgstreamer-lite.so"/>
        <exclude name="lib/amd64/libjavafx_font_freetype.so"/>
        <exclude name="lib/amd64/libjavafx_font_pango.so"/>
        <exclude name="lib/amd64/libjavafx_font_t2k.so"/>
        <exclude name="lib/amd64/libjavafx_font.so"/>
        <exclude name="lib/amd64/libjavafx_iio.so"/>
        <exclude name="lib/amd64/libjfxmedia.so"/>
        <exclude name="lib/amd64/libjfxwebkit.so"/>
        <exclude name="lib/ext/jfxrt.jar"/>
        <exclude name="lib/ext/nashorn.jar"/>
      </fileset>
    </copy>

    <!-- Create SweetHome3D-version-linux-x64.tgz archive -->
    <tar destfile="install/SweetHome3D-${version}-linux-x64.tgz"
         compression="gzip">
      <tarfileset dir="install/linux/x64"
                  includes="SweetHome3D-${version}/**">
        <exclude name="SweetHome3D-${version}/SweetHome3D"/>
        <exclude name="SweetHome3D-${version}/SweetHome3D-Java3D-1_5_2"/>
        <exclude name="SweetHome3D-${version}/runtime/bin/java"/>
      </tarfileset>
      <!-- Change executable permission of SweetHome3D and java commands -->
      <tarfileset dir="install/linux/x64" mode="755">
        <include name="SweetHome3D-${version}/SweetHome3D"/>
        <include name="SweetHome3D-${version}/SweetHome3D-Java3D-1_5_2"/>
        <include name="SweetHome3D-${version}/runtime/bin/java"/>
      </tarfileset>
    </tar>

    <!-- Clean build directories -->
    <delete dir="build"/>
    <delete dir="install/linux/x64"/>

    <echo message="install/SweetHome3D-${version}-linux-x64.tgz ready for ftp"/>
  </target>

  <!-- Builds Sweet Home 3D Windows signed portable launchers in install/portable/SweetHome3D-version-portable directory.
       CAUTION : May be run only under Windows and requires launch4j and SignTool
                 included in Windows platform SDK installed in their default location -->
  <target name="windowsSignedPortableLaunchers"
          description="Builds Sweet Home 3D Windows portable launchers">
    <!-- Create portable executable files with launch4j -->
    <exec executable="C:\Program Files (x86)\Launch4j\launch4jc.exe" failonerror="yes">
      <arg value="${basedir}\install\portable\SweetHome3D-windows-x86.xml"/>
    </exec>
    <exec executable="C:\Program Files (x86)\Launch4j\launch4jc.exe" failonerror="yes">
      <arg value="${basedir}\install\portable\SweetHome3D-windows-x64.xml"/>
    </exec>

    <input message="Enter signature password:" addproperty="password"/>
    <input message="Enter URL of timestamp authority:" addproperty="timestampAuthorityURL" defaultvalue="http://time.certum.pl/"/>
    <!-- Sign launchers -->
    <exec executable="C:\Program Files (x86)\Windows Kits\8.1\bin\x86\signtool.exe" failonerror="yes">
      <arg value="sign"/>
      <arg value="/f"/>
      <arg value="${basedir}\keys.p12"/>
      <arg value="/p"/>
      <arg value="${password}"/>
      <arg value="/t"/>
      <arg value="${timestampAuthorityURL}"/>
      <arg value="${basedir}\install\portable\SweetHome3D-windows-x86.exe"/>
      <arg value="${basedir}\install\portable\SweetHome3D-windows-x64.exe"/>
    </exec>

    <mkdir dir="install/portable/SweetHome3D-${version}-portable"/>
    <move file="install/portable/SweetHome3D-windows-x86.exe" todir="install/portable/SweetHome3D-${version}-portable" />
    <move file="install/portable/SweetHome3D-windows-x64.exe" todir="install/portable/SweetHome3D-${version}-portable" />
  </target>

  <!-- Builds install/portable/SweetHome3D-version-portable files required for SweetHome3D portable version
       CAUTION : May be run only under Mac OS X and requires
                 OpenJDK 15.0.2 for x86_64 installed in /Library/Java/JavaVirtualMachines/zulu-15.0.2-macosx_x86_64.jdk,
                 OpenJDK 15.0.2 for arm64  installed in /Library/Java/JavaVirtualMachines/zulu-15.0.2-macosx_aarch64.jdk,
                 lipo, codesign and a certificate imported in Keychain Access -->
  <target name="portableArchive" depends="application,furniture,textures,examples,help,jogl-java3d"
          description="Builds install/portable/SweetHome3D-version-portable files">
    <!-- Copy Mac OS X application bundle using a different configuration file -->
    <copy todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app">
      <fileset dir="install/macosx/Sweet Home 3D"/>
    </copy>
    <copy file="install/portable/SweetHome3D.cfg" todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app" overwrite="true"/>
    <!-- Change executable permission of SweetHome3D lost during copy task -->
    <chmod perm="+x" file="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/MacOS/SweetHome3D"/>
    <!-- Create directories required by OpenJDK AppBundler -->
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/Home" />
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/MacOS" />
    <!-- Copy OpenJDK files generated by jpackage to install/macosx/SweetHome3D-version/Contents/runtime/Contents/Home -->
    <copy file="${javaHome_macosx_arm64}/../MacOS/libjli.dylib"
          todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/MacOS"/>
    <copy todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/Home">
      <fileset dir="${javaHome_macosx_arm64}">
        <include name="readme.txt"/>
        <include name="DISCLAIMER"/>
        <include name="conf/**"/>
        <include name="lib/**"/>
        <exclude name="lib/libsaproc.dylib"/>
        <exclude name="lib/src.zip"/>
      </fileset>
    </copy>
    <!-- Copy legal files with their symlinks -->
    <exec executable="cp" failonerror="yes">
      <arg value="-R"/>
      <arg value="${javaHome_macosx_arm64}/legal"/>
      <arg value="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/Home"/>
    </exec>
    <!-- Remove legal files not exported by jpackage -->
    <delete dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/Home/legal/jdk.jcmd"/>
    <delete dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/Home/legal/jdk.internal.vm.compiler"/>
    <delete dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/Home/legal/jdk.internal.vm.ci"/>
    <delete dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/Home/legal/jdk.hotspot.agent"/>
    <delete dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/Home/legal/jdk.aot"/>
    <delete dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents/Home/legal/java.se"/>
    <!-- Build Universal OpenJDK with lipo -->
    <exec executable="find" dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/runtime/Contents" failonerror="yes">
      <arg value="."/>
      <arg value="-name"/>
      <arg value="*.dylib"/>
      <arg value="-exec"/>
      <arg value="lipo"/>
      <arg value="${javaHome_macosx_arm64}/../{}"/>
      <arg value="${javaHome_macosx_x86_64}/../{}"/>
      <arg value="-output"/>
      <arg value="{}"/>
      <arg value="-create"/>
      <arg value=";"/>
    </exec>

    <!-- Copy SweetHome3D JARs and its libs
         to install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app
         to ensure the Mac OS X signed version can be launched -->
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app/ext"/>
    <move file="build/SweetHome3D.jar" todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app" />
    <move file="build/Furniture.jar"   todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app" />
    <move file="build/Textures.jar"    todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app" />
    <move file="build/Examples.jar"    todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app" />
    <move file="build/Help.jar"        todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app" />
    <copy todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app" >
      <fileset dir="lib">
        <include name="*.jar"/>
        <exclude name="jmf.jar"/>
        <exclude name="j3dcore.jar"/>
        <exclude name="j3dutils.jar"/>
        <exclude name="vecmath.jar"/>
      </fileset>
    </copy>
    <!-- Copy jnlp.jar, JMF and DLLs and JARs for Java 3D
         to install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app/ext -->
    <copy file="libtest/jnlp.jar" todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app/ext"/>
    <copy todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents/app/ext">
      <fileset dir="lib">
        <include name="jmf.jar"/>
        <include name="java3d-1.6/*.jar"/>
        <include name="java3d-1.6/windows/**"/>
        <include name="java3d-1.6/linux/**"/>
        <include name="java3d-1.6/macosx/**"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
      <fileset dir="lib">
        <include name="yafaray/**"/>
      </fileset>
    </copy>
    <!-- Copy README.TXT and licenses texts to install/portable/SweetHome3D-${version}/ -->
    <copy file="install/portable/README.TXT" todir="install/portable/SweetHome3D-${version}-portable"/>
    <copy file="COPYING.TXT" todir="install/portable/SweetHome3D-${version}-portable"/>
    <copy file="LICENSE.TXT" todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-JAVA.TXT"       todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-OPENJDK.TXT"    todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-JAVA3D.TXT"     todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-JOGL.TXT"      todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-BATIK.TXT"      todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-JEKSPARSER.TXT"     todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-ITEXT.TXT"          todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-VECTORGRAPHICS.TXT" todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-SUNFLOW.TXT"   todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-YAFARAY.TXT"  todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-JMF.HTML"      todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-LAUNCH4J.TXT"  todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-BLENDSWAP.TXT"  todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-CONTRIBUTIONS.TXT" todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-KATORLEGAZ.TXT"  todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-REALLUSION.TXT"  todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-SCOPIA.TXT"      todir="install/portable/SweetHome3D-${version}-portable" />

    <!-- Copy Linux command files -->
    <copy file="install/portable/SweetHome3D-linux-x86" todir="install/portable/SweetHome3D-${version}-portable"/>
    <copy file="install/portable/SweetHome3D-linux-x64" todir="install/portable/SweetHome3D-${version}-portable"/>
    <!-- Change executable permission of command files lost during copy task -->
    <chmod perm="+x" file="install/portable/SweetHome3D-${version}-portable/SweetHome3D-linux-*"/>

    <!-- Prepare bundle Java runtime directories -->
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/runtime/windows/i586"/>
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/runtime/windows/x64"/>
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/runtime/linux/i586"/>
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/runtime/linux/x64"/>

    <!-- Prepare data directories for SH3F, SH3T, SH3L and SH3P files -->
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/data/furniture"/>
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/data/textures"/>
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/data/languages"/>
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/data/plugins"/>

    <!-- Sign Sweet Home 3D application bundle -->
    <input message="Enter Developer ID Application certificate name:" addproperty="certificateName"/>
    <exec executable="find" failonerror="yes">
      <arg value="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app"/>
      <arg value="-type"/>
      <arg value="f"/>
      <arg value="("/>
      <arg value="-name"/>
      <arg value="*.dylib"/>
      <arg value="-or"/>
      <arg value="-name"/>
      <arg value="SweetHome3D"/>
      <arg value="-or"/>
      <arg value="-name"/>
      <arg value="JavaNativeFoundation"/>
      <arg value=")"/>
      <arg value="-exec"/>
      <arg value="codesign"/>
      <arg value="-v"/>
      <arg value="-f"/>
      <arg value="-s"/>
      <arg value="${certificateName}"/>
      <arg value="--options=runtime"/>
      <arg value="--entitlements"/>
      <arg value="install/macosx/SweetHome3D.entitlements"/>
      <arg value="{}"/>
      <arg value=";"/>
    </exec>
    <exec executable="codesign" failonerror="yes">
      <arg value="-f"/>
      <arg value="-s"/>
      <arg value="${certificateName}"/>
      <arg value="--options=runtime"/>
      <arg value="--entitlements"/>
      <arg value="install/macosx/SweetHome3D.entitlements"/>
      <arg value="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app"/>
    </exec>

    <echo message="copy Windows portable launchers, JREs for Windows and Linux, SH3F, SH3T, SH3L and SH3P files
                   to install/portable/SweetHome3D-${version}-portable and prepare compressed archive"/>
  </target>

  <!-- Builds install/SweetHome3DViewer-version.zip archive that contains
       the files required for SweetHome3DViewer applet -->
  <target name="viewerInstaller" depends="viewer"
          description="Builds install/SweetHome3DViewer-version.zip archive">
    <zip destfile="install/SweetHome3DViewer-${version}.zip">
      <zipfileset dir="deploy"
                  includes="lib/**, SweetHome3DViewer.html"/>
      <zipfileset dir="install/viewer"
                  includes="README.TXT"/>
      <zipfileset dir=".">
        <include name="COPYING.TXT"/>
        <include name="LICENSE.TXT"/>
        <include name="THIRDPARTY-LICENSE-JAVA3D.TXT"/>
        <include name="THIRDPARTY-LICENSE-BATIK.TXT"/>
      </zipfileset>
    </zip>

    <echo message="install/SweetHome3DViewer-${version}.zip ready for ftp"/>
  </target>

  <!-- Builds install/SweetHome3D-version-src.zip archive that contains
       SweetHome3D source files in directory named SweetHome3D-version-src -->
  <target name="sourceArchive"
          description="Builds install/SweetHome3D-version-src.zip archive">
    <mkdir dir="install/source/SweetHome3D-${version}-src"/>
    <copy todir="install/source/SweetHome3D-${version}-src">
      <fileset dir=".">
        <include name="build.xml"/>
        <include name="*.TXT"/>
        <include name="THIRDPARTY-LICENSE-*.HTML"/>
        <include name="*-diff.zip"/>
        <include name="src/**"/>
        <include name="include/**"/>
        <include name="test/**"/>
        <include name="lib/**"/>
        <include name="libtest/**"/>
        <!-- Do not include generated files that may belong to
             deploy and install directories -->
        <include name="deploy/SweetHome3D*.*"/>
        <include name="deploy/*.php"/>
        <include name="install/linux/*"/>
        <include name="install/macosx/**"/>
        <include name="install/portable/*"/>
        <include name="install/viewer/*"/>
        <include name="install/windows/*"/>
        <!-- Eclipse project files -->
        <include name=".settings/**"/>
        <include name=".classpath"/>
        <include name=".project"/>
      </fileset>
    </copy>

    <zip destfile="install/SweetHome3D-${version}-src.zip" basedir="install/source"
         includes="SweetHome3D-${version}-src/**" />

    <!-- Clean build directory -->
    <delete dir="install/source"/>

    <echo message="install/SweetHome3D-${version}-src.zip ready for ftp"/>
  </target>

  <!-- Builds install/SweetHome3D-version-javadoc.zip archive that contains
       the generated Javadoc of Java files found in SweetHome3D-version-src -->
  <target name="javadoc"
          description="Builds install/SweetHome3D-version-javadoc.zip archive">
    <mkdir dir="install/javadoc/SweetHome3D-${version}-javadoc"/>
    <javadoc sourcepath="src" destdir="install/javadoc/SweetHome3D-${version}-javadoc"
             encoding="ISO-8859-1" version="true" author="true" use="true"
             windowtitle="Sweet Home 3D ${version} API">
      <doctitle><![CDATA[<img src='http://www.sweethome3d.com/SweetHome3DIcon.gif' width='48' height='48' alt='Sweet Home 3D' align='absmiddle'> Sweet Home 3D ${version} API]]></doctitle>
      <header><![CDATA[<a href='http://www.sweethome3d.com' target='_parent'><font size='+1'>Sweet Home 3D ${version}</font></a>]]></header>
      <footer><![CDATA[<a href='http://www.sweethome3d.com' target='_parent'><font size='+1'>Sweet Home 3D ${version}</font></a>]]></footer>
      <bottom><![CDATA[<table align='center'><tr>
                       <td><a href='http://www.eteks.com' target='_parent'><img align='absmiddle' src='http://www.sweethome3d.com/images/eteks.gif' border='0'><a></td>
                       <td>&copy; Copyrights 2006-2023 Emmanuel PUYBARET / <a href='http://www.eteks.com' target='_parent'>eTeks</a>
                           <br>Distributed under <a href='http://www.gnu.org/licenses/gpl-2.0.html' target='_parent'>GNU General Public License</a></td></tr></table>]]></bottom>
      <link href="http://docs.oracle.com/javase/1.5.1/docs/api/"/>
      <link href="http://download.java.net/media/java3d/javadoc/1.5.3/"/>
      <group title="Base classes" packages="*"/>
      <group title="Application and Applet" packages="com.eteks.sweethome3d:com.eteks.sweethome3d.applet"/>
      <classpath>
        <fileset dir="lib"/>
        <pathelement location="libtest/AppleJavaExtensions.jar"/>
        <pathelement location="libtest/jnlp.jar"/>
      </classpath>
    </javadoc>

    <zip destfile="install/SweetHome3D-${version}-javadoc.zip" basedir="install/javadoc"
         includes="SweetHome3D-${version}-javadoc/**" />

    <!-- Clean build directory -->
    <delete dir="install/javadoc"/>

    <echo message="install/SweetHome3D-${version}-javadoc.zip ready for ftp"/>
  </target>

  <!-- Launchs a JDepend graphical UI to help update dependencies in PackageDependenciesTest test -->
  <target name="jdepend" depends="build"
          description="Launchs a JDepend graphical UI">
    <!-- Create jdepend.properties file in build directory that specifies ignored Java packages -->
    <concat destfile="build/jdepend.properties">ignore.java=java.*</concat>

    <!-- Run JDepend UI -->
    <java classname="jdepend.swingui.JDepend" fork="true">
      <classpath>
        <pathelement location="libtest/jdepend-2.9.jar"/>
        <pathelement location="build"/>
      </classpath>
      <arg value="build"/>
    </java>

    <!-- Clean build directory -->
    <delete dir="build"/>
  </target>
</project>
