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

     Sweet Home 3D, Copyright (c) 2007-2017 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
     - 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
     - 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">
  <!-- The current version of Sweet Home 3D -->
  <property name="version" value="5.4"/>

  <target name="build"
          description="Builds build/SweetHome3D.jar with all its classes">
    <!-- 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="1.1" source="1.2"
           debug="false" debuglevel="lines,vars,source"/>
    <!-- Compile other classes -->
    <javac srcdir="src" destdir="build/classes"
           encoding="ISO-8859-1" target="1.5" source="1.5"
           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/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="**/package.html"/>
        <exclude name="com/eteks/sweethome3d/io/*Catalog*.properties"/>
        <exclude name="com/eteks/sweethome3d/io/resources/**"/>
        <exclude name="**/help/**"/>
      </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/**"/>
    </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="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/*.jnilib"/>
      </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/*.jnilib"/>
      </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/freehep-vectorgraphics-svg-2.1.1b.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.1b.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,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/Help.jar"/>
    </jar>

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

    <input message="Enter Passphrase for keystore:" addproperty="password"/>
    <!-- Sign jar files in deploy/lib dir -->
    <signjar keystore="keys.p12" alias="sweethome3d" storepass="${password}" 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"/>
    <!-- Sign jar files in deploy/lib dir -->
    <signjar keystore="keys.p12" alias="SweetHome3D" storepass="${password}" 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="1.1" source="1.2"
           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="1.5"
           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/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"/>
    <!-- Sign jar files in deploy/lib dir -->
    <signjar keystore="keys.p12" alias="SweetHome3D" storepass="${password}" 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,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="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/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="linux/**/*.so"/>
        <include name="java3d-1.6/linux/**/*.so"/>
        <include name="macosx/*.jnilib"/>
        <include name="java3d-1.6/macosx/*.jnilib"/>
      </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-BATIK.TXT"/>
        <include name="THIRDPARTY-LICENSE-ITEXT.TXT"/>
        <include name="THIRDPARTY-LICENSE-VECTORGRAPHICS.TXT"/>
        <include name="THIRDPARTY-LICENSE-SUNFLOW.TXT"/>
        <include name="THIRDPARTY-LICENSE-JMF.HTML"/>
        <include name="THIRDPARTY-LICENSE-TANGO.TXT"/>
        <include name="THIRDPARTY-LICENSE-CONTRIBUTIONS.TXT"/>
      </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,
                 64 bit JRE and launch4j installed in their default location -->
  <target name="windowsLauncher" depends="application,furniture,textures,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/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="j3dcore.jar"/>
        <exclude name="j3dutils.jar"/>
        <exclude name="vecmath.jar"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </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>
    <!-- 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-JAVA3D.TXT"    todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-BATIK.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-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 file="THIRDPARTY-LICENSE-TANGO.TXT"     todir="install/windows/build" />
    <copy file="THIRDPARTY-LICENSE-CONTRIBUTIONS.TXT" todir="install/windows/build" />

    <!-- Copy 32 bit JRE to install/windows/build/jre/x86... excluding files mentioned
         in JRE README.TXT file (JRE bin/javaw.exe command excepted) -->
    <copy todir="install/windows/build/jre8/x86">
      <fileset dir="C:\Program Files (x86)\Java\jre1.8.0_51">
        <include name="*"/>
        <include name="bin/**"/>
        <include name="lib/**"/>

        <exclude name="lib/ext/sunjce_provider.jar"/>
        <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/JavaAccessBridge-32.dll"/>
        <exclude name="bin/JAWTAccessBridge-32.dll"/>
        <exclude name="bin/WindowsAccessBridge-32.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 JRE to install/windows/build/jre/x64... excluding files mentioned
         in JRE README.TXT file (JRE bin/javaw.exe command excepted) -->
    <copy todir="install/windows/build/jre8/x64">
      <fileset dir="C:\Program Files\Java\jre1.8.0_51">
        <include name="*"/>
        <include name="bin/**"/>
        <include name="lib/**"/>

        <exclude name="lib/ext/sunjce_provider.jar"/>
        <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/JavaAccessBridge-64.dll"/>
        <exclude name="bin/JAWTAccessBridge-64.dll"/>
        <exclude name="bin/WindowsAccessBridge-64.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>

    <!-- 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-x86.xml"/>
    </exec>
    <exec executable="C:\Program Files (x86)\Launch4j\launch4jc.exe" failonerror="yes">
      <arg value="${basedir}\install\windows\installerLaunch4j-x64.xml"/>
    </exec>

    <!-- Pack largest jars -->
    <exec executable="C:\Program Files\Java\jre1.8.0_51\bin\pack200.exe" failonerror="yes">
      <arg value="${basedir}\install\windows\build\lib\SweetHome3D.pack.gz"/>
      <arg value="${basedir}\install\windows\build\lib\SweetHome3D.jar"/>
    </exec>
    <delete file="${basedir}\install\windows\build\lib\SweetHome3D.jar"/>

    <exec executable="C:\Program Files\Java\jre1.8.0_51\bin\pack200.exe" failonerror="yes">
      <arg value="-J-Xmx512m"/>
      <arg value="${basedir}\install\windows\build\jre8\x86\lib\rt.pack.gz"/>
      <arg value="${basedir}\install\windows\build\jre8\x86\lib\rt.jar"/>
    </exec>
    <delete file="${basedir}\install\windows\build\jre8\x86\lib\rt.jar"/>

    <exec executable="C:\Program Files\Java\jre1.8.0_51\bin\pack200.exe" failonerror="yes">
      <arg value="-J-Xmx512m"/>
      <arg value="${basedir}\install\windows\build\jre8\x64\lib\rt.pack.gz"/>
      <arg value="${basedir}\install\windows\build\jre8\x64\lib\rt.jar"/>
    </exec>
    <delete file="${basedir}\install\windows\build\jre8\x64\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, 64 bit JRE,
                 launch4j and Inno Setup 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 -->
    <exec executable="C:\Program Files (x86)\Inno Setup 5\ISCC.exe" failonerror="yes">
      <arg value="${basedir}\install\windows\installerInnoSetup.iss"/>
    </exec>

    <!-- 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, 64 bit JRE,
                 launch4j, Inno Setup 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"/>
    <!-- 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="${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 -->
    <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} $p"/>
      <arg value="${basedir}\install\windows\signedInstallerInnoSetup.iss"/>
    </exec>

    <!-- 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/SweetHome3D-version directory. -->
  <target name="macosxBundle" depends="application,furniture,textures,help"
          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/Resources/Java -->
    <mkdir dir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java/ext"/>
    <move file="build/SweetHome3D.jar" todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" />
    <move file="build/Furniture.jar"   todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" />
    <move file="build/Textures.jar"    todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" />
    <move file="build/Help.jar"        todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java" />
    <copy todir="install/macosx/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 DLLs and JARs for Java 3D
         to install/macosx/SweetHome3D-version/Sweet Home 3D.app/Contents/Resources/Java/ext -->
    <copy file="libtest/jnlp.jar" todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java/ext"/>
    <copy todir="install/macosx/SweetHome3D-${version}/Sweet Home 3D.app/Contents/Resources/Java/ext" >
      <fileset dir="lib">
        <include name="jmf.jar"/>
        <include name="j3dcore.jar"/>
        <include name="j3dutils.jar"/>
        <include name="vecmath.jar"/>
      </fileset>
      <fileset dir="lib/macosx">
        <include name="*.jar"/>
        <include name="*.jnilib"/>
      </fileset>
    </copy>
    <!-- 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-JAVA3D.TXT"     todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-BATIK.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-JMF.HTML"       todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-TANGO.TXT"      todir="install/macosx/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-CONTRIBUTIONS.TXT"   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 -->
  <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="-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 hdutil, codesign
                 and a certificate imported in Keychain Access -->
  <target name="macosxSignedInstaller" depends="macosxBundle"
          description="Builds install/SweetHome3D-version-macosx.dmg archive">
    <input message="Enter certificate name:" addproperty="certificateName"/>
    <!-- Sign Sweet Home 3D application bundle -->
    <exec executable="codesign" failonerror="yes">
      <arg value="-s"/>
      <arg value="${certificateName}"/>
      <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="-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="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_121 -->
  <target name="linux32Installer" depends="application,furniture,textures,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/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 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 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-BATIK.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-JMF.HTML"      todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-TANGO.TXT"     todir="install/linux/x86/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-CONTRIBUTIONS.TXT"  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/jre... excluding files mentioned
         in JRE README.TXT file (JRE bin/java command excepted) -->
    <copy todir="install/linux/x86/SweetHome3D-${version}/jre8">
      <fileset dir="jre1.8.0_121">
        <include name="**"/>
        <exclude name="lib/ext/sunjce_provider.jar"/>
        <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}/jre8/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}/jre8/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_121 -->
  <target name="linux64Installer" depends="application,furniture,textures,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"/>

    <!-- 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/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 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 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-BATIK.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-JMF.HTML"      todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-TANGO.TXT"     todir="install/linux/x64/SweetHome3D-${version}" />
    <copy file="THIRDPARTY-LICENSE-CONTRIBUTIONS.TXT"  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/jre... excluding files mentioned
         in JRE README.TXT file (JRE bin/java command excepted) -->
    <copy todir="install/linux/x64/SweetHome3D-${version}/jre8">
      <fileset dir="jre1.8.0_121/">
        <include name="**"/>
        <exclude name="lib/ext/sunjce_provider.jar"/>
        <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}/jre8/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}/jre8/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"/>
    <!-- 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="${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 -->
  <target name="portableArchive" depends="application,furniture,textures,help,jogl-java3d"
          description="Builds install/portable/SweetHome3D-version-portable files">
    <!-- Copy SweetHome3D JARs and its libs
         to install/portable/SweetHome3D-${version}/lib -->
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/lib/ext"/>
    <move file="build/SweetHome3D.jar" todir="install/portable/SweetHome3D-${version}-portable/lib" />
    <move file="build/Furniture.jar"   todir="install/portable/SweetHome3D-${version}-portable/lib" />
    <move file="build/Textures.jar"    todir="install/portable/SweetHome3D-${version}-portable/lib" />
    <move file="build/Help.jar"        todir="install/portable/SweetHome3D-${version}-portable/lib" />
    <copy todir="install/portable/SweetHome3D-${version}-portable/lib" >
      <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/lib/ext -->
    <copy file="libtest/jnlp.jar" todir="install/portable/SweetHome3D-${version}-portable/lib/ext"/>
    <copy todir="install/portable/SweetHome3D-${version}-portable/lib/ext">
      <fileset dir="lib">
        <include name="jmf.jar"/>
        <include name="j3dcore.jar"/>
        <include name="j3dutils.jar"/>
        <include name="vecmath.jar"/>
        <include name="macosx/*"/>
        <include name="java3d-1.6/*.jar"/>
        <include name="java3d-1.6/windows/**"/>
        <include name="java3d-1.6/linux/**"/>
        <exclude name="java3d-1.6/jogl-all.jar"/>
      </fileset>
      <fileset dir="build">
        <include name="java3d-1.6/jogl-java3d.jar"/>
      </fileset>
    </copy>
    <!-- Copy README.TXT and licenses texts to install/macosx/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-JAVA3D.TXT"     todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-BATIK.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-JMF.HTML"      todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-LAUNCH4J.TXT"  todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-TANGO.TXT"     todir="install/portable/SweetHome3D-${version}-portable" />
    <copy file="THIRDPARTY-LICENSE-CONTRIBUTIONS.TXT"   todir="install/portable/SweetHome3D-${version}-portable" />
    <!-- Copy Mac OS X application bundle using a different Info.plist file -->
    <copy todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app">
      <fileset dir="install/macosx/Sweet Home 3D"/>
    </copy>
    <copy file="install/portable/Info.plist" todir="install/portable/SweetHome3D-${version}-portable/SweetHome3D-macosx.app/Contents" 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"/>

    <!-- 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 jre directories -->
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/jre/windows/i586"/>
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/jre/windows/x64"/>
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/jre/linux/i586"/>
    <mkdir dir="install/portable/SweetHome3D-${version}-portable/jre/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"/>

    <echo message="copy Windows portable launchers, jres, 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="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-2017 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>
