<?xml version="1.0" encoding="UTF-8"?>
<project name="FFDec" basedir="." default="all" xmlns:jacoco="antlib:org.jacoco.ant">
    <description>Builds project FFDec</description>    
                             
    <loadproperties srcfile="build.properties" />
    <property name="jar.filename" value="${prefix.filename}"/>
    <property name="exe.filename" value="${prefix.filename}"/>
    <property name="exe64.filename" value="${prefix.filename}64"/>                  
        
    <path id="ant.lib.classpath">
        <fileset dir="${ant.lib.dir}" includes="**/*.jar"/>
    </path>    
    
    
    <taskdef name="mkbom" classname="com.jpexs.jbomutils.ant.MkBomTask" classpathref="ant.lib.classpath" />
    <taskdef name="xar" classname="com.jpexs.xar.ant.XarTask" classpathref="ant.lib.classpath" />
    <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpathref="ant.lib.classpath" />
    <taskdef name="cpio" classname="org.apache.ant.compress.taskdefs.Cpio" classpathref="ant.lib.classpath" />       
    <taskdef name="deb" classname="com.googlecode.ant_deb_task.Deb" classpathref="ant.lib.classpath" />
    <taskdef name="desktopentry" classname="com.googlecode.ant_deb_task.DesktopEntry" classpathref="ant.lib.classpath" />
    <taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="ant.lib.classpath"  />
    <taskdef name="nsis" classname="com.danielreese.nsisant.Task" classpathref="ant.lib.classpath" />
    
    
    <property name="dist.lib.dir" value="${dist.dir}/${dist.lib.dirname}"/>    
    <patternset id="compiler.resources">
        <include name="**/?*.properties"/>  
        <include name="**/?*.colorschemes"/>                
        <include name="**/?*.bin"/>
        <include name="**/?*.xml"/>
        <include name="**/?*.txt"/>
        <include name="**/?*.gif"/>
        <include name="**/?*.png"/>
        <include name="**/?*.jpeg"/>
        <include name="**/?*.jpg"/>
        <include name="**/?*.html"/>
        <include name="**/?*.dtd"/>
        <include name="**/?*.tld"/>
        <include name="**/?*.mid"/>
        <include name="**/?*.wav"/>
        <include name="**/?*.js"/>
        <include name="**/?*.swf"/>
        <include name="**/?*.css"/>
    </patternset>
    
    
    
    <target name="-loadversion" depends="-loadversion-prop,-loadversion-private">
        
    </target>
    <target name="-loadversion-private" unless="new.version">
        <property name="version.major" value="0" />
        <property name="version.minor" value="0" />
        <property name="version.release" value="0" />
        <property name="version.major" value="0" />
        <property name="version.build" value="0" />
        <!-- <property name="version.revision" value="" /> -->
        <property name="version.debug" value="true" />
        
        <property name="version" value="${version.major}.${version.minor}.${version.release}" />
        <property name="version.number" value="${version.major}.${version.minor}.${version.release}.${version.build}" />  
        <property name="private" value="true" />        
    </target>
    <target name="-loadversion-prop" if="new.version">
        <loadproperties srcfile="${version_info}" prefix="version"/> 
        <property name="version" value="${version.major}.${version.minor}.${version.release}" />
        <property name="version.number" value="${version.major}.${version.minor}.${version.release}.${version.build}" />  
        <script language="beanshell" classpathref="ant.lib.classpath">
            if("true".equals("" + project.getProperty("version.debug"))) {
                project.setProperty("nightly","true");
            }
        </script>
        <echo level="info" message="Loaded Version:${version.major}.${version.minor}.${version.release}.${version.build}"/>
    </target>
    
 

    <target name="compile" depends="build_lib,-copy-lib">
        <!--<delete dir="${compile.dir}"/>-->        
        <mkdir dir="${compile.dir}"/>
        <javac srcdir="${src.dir}" destdir="${compile.dir}" includes="**/*.java" target="${target.java}" source="${target.java}" debug="true"
               debuglevel="lines,vars,source" includeantruntime="false" encoding="utf-8">
            <compilerarg line="-Xlint:unchecked -Xlint:deprecation"/> <!-- For Java 8: -Xdiags:verbose -->
            <classpath>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
            </classpath>
        </javac>
        <copy todir="${compile.dir}">
            <fileset dir="${src.dir}">
                <patternset refid="compiler.resources"/>
                <type type="file"/>
            </fileset>
        </copy>
    </target>
    
    <target name="compile_lib">
        <ant antfile="${core.lib.script}" target="compile" inheritAll="false" usenativebasedir="true" />
    </target>
    
    <target name="compile-tests">
        <delete dir="${compile.test.dir}"/>
        <mkdir dir="${compile.test.dir}"/>
        <javac srcdir="${test.dir}" destdir="${compile.test.dir}" includes="**/*.java" target="${target.java}" source="${target.java}" debug="true" includeantruntime="false" encoding="utf-8">                        
            <classpath>
                <pathelement path="${compile.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
        </javac>
    </target>

    <target name="-test-halt-always">
        <property name="test.halt.failure" value="true" />
    </target>

    <target name="-test-halt-newver" if="new.version">
        <property name="test.halt.failure" value="true" />
    </target>
    <target name="-test-halt-nonewver" unless="new.version">
        <property name="test.halt.failure" value="false" />
    </target>

    <target name="testhalt" depends="-test-halt-always,test">
        
    </target>
    <target name="test" depends="-test-halt-newver,-test-halt-nonewver,test_lib,compile,compile-tests">
        <delete dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}/raw/"/>
        
         
        
        <mkdir dir="${coverage.dir}" />
        <jacoco:coverage destfile="${coverage.dir}/jacoco.exec">
            <testng 
                outputDir="${test.result.dir}"
                haltOnFailure="${test.halt.failure}" verbose="2" workingDir="${basedir}">
        
                <classpath>
                    <pathelement path="${compile.test.dir}"/>
                    <pathelement path="${compile.dir}"/>
                    <fileset dir="${lib.dir}" includes="**/*.jar"/>
                    <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
                </classpath>
                <jvmarg value="-noverify" />
                <classfileset dir="${compile.test.dir}" includes="**/*.class" />                                    
            </testng>
        </jacoco:coverage>
                  
        <!-- Coverage report -->
        <mkdir dir="${coverage.result.dir}"/>
        <jacoco:report>
            <executiondata>
                <file file="${coverage.dir}/jacoco.exec" />
            </executiondata>
            <structure name="${project.name}">
                <classfiles>
                    <fileset dir="${compile.dir}" />
                </classfiles>
                <sourcefiles encoding="UTF-8">
                    <fileset dir="${src.dir}" />
                </sourcefiles>
            </structure>
            <html destdir="${coverage.result.dir}" />
        </jacoco:report>
    </target>
    
    <condition property="is_windows">
        <os family="windows"/>
    </condition>
    
    
    
    
    
    <target name="installer" depends="-loadversion,-load-tools,dist">       
        <property name="exe.file" value="${releases.dir}/${prefix.filename}_${version}${version.suffix}_setup.exe"/>       
        <nsis script="installer.nsi" path="${nsis.path}" verbosity="2">
            <define name="APP_NAME" value="${product.name}"/>
            <define name="APP_VER" value="${version}${version.suffix}"/>
            <define name="APP_VER_MAJOR" value="${version.major}"/>
            <define name="APP_VER_MINOR" value="${version.minor}"/>
            <define name="APP_PUBLISHER" value="${vendor}"/>
            <define name="APP_URL" value="${product.url}"/>
            <define name="APP_SETUPFILE" value="${exe.file}" />
            <define name="JRE_VERSION" value="${target.java}" />
        </nsis>
        <echo level="info" message="Setup created in ${exe.file}"/>
    </target>
    
    <target name="library" depends="-loadversion,release_lib,-copy-lib">
        <mkdir dir="${releases.dir}"/>
        <copy file="${lib.file}" todir="${releases.dir}" />
    </target>
    
    <target name="archive" depends="-loadversion,dist">
        <mkdir dir="${releases.dir}"/>
        <property  name="zip.file" value="${releases.dir}/${prefix.filename}_${version}${version.suffix}.zip" />
        <zip destfile="${zip.file}" basedir="${dist.dir}" excludes="${app.script}">
            <zipfileset dir="${dist.dir}" includes="${app.script}" fullpath="${app.script}" filemode="755"/>
        </zip>
    </target>
    
    
    
    <target name="deb" depends="-loadversion,dist">
        <mkdir dir="${releases.dir}"/>
        <tempfile property="app.deb.desktop.temp" deleteonexit="true" prefix="desktop"/>
        <desktopentry
            toFile="${app.deb.desktop.temp}"
            name="${product.name}"
            comment="${app.description.short}"
            exec="/usr/bin/${app.package}"
            icon="/usr/share/java/${app.package}/icon.png"
            categories="Development;Network;Utility;WebDevelopment;Java"
        />
        <deb 
            package="${app.package}"
            todir="${releases.dir}"
            debFilenameProperty="deb.file.orig"
            section="editors"
            depends="${app.package.depends}">
            <version upstream="${version}" />
            <maintainer name="${vendor}" email="${app.vendor.mail}"/>
            <description synopsis="${app.description.short}">${app.description}</description>
            <tarfileset dir="${dist.dir}" prefix="usr/share/java/${app.package}">
                <include name="**"/>
            </tarfileset>
            <tarfileset file="${dist.dir}/${app.script}" fullpath="usr/bin/${app.package}" filemode="755" />
            <tarfileset file="${app.deb.desktop.temp}" fullpath="usr/share/applications/${app.deb.desktop.file}.desktop"/>
        </deb>
        <property name="deb.file" value="${releases.dir}/${prefix.filename}_${version}${version.suffix}.deb" />        
        <move file="${deb.file.orig}" tofile="${deb.file}" />
        <delete file="${app.deb.desktop.temp}" />
    </target>         
    
    <target name="osx-app-installer" depends="osx-app-bundle">
        <mkdir dir="${app.installer.dir}/flat/base.pkg"/>
        <mkdir dir="${app.installer.dir}/flat/Resources/en.lproj"/>
        <mkdir dir="${app.installer.dir}/root/Applications"/>
        <copy todir="${app.installer.dir}/root/Applications/">
            <fileset dir="${app.bundle.dir}">
                <include  name="${app.osx.dir}.app/**" />
            </fileset>
        </copy>
        
        <tempfile deleteonexit="true" property="app.cpio.temp" prefix="cpio"/>
        
        <cpio destfile="${app.cpio.temp}" format="odc">
            <tarfileset dir="${app.installer.dir}/root" uid="0" gid="80" includes="Applications/${app.osx.dir}.app/Contents/MacOS/${app.osx.dir}"  filemode="777" />            
            <tarfileset dir="${app.installer.dir}/root" uid="0" gid="80">
                <exclude name="Applications/${app.osx.dir}.app/Contents/Resources/${app.script}" />
                <exclude name="Applications/${app.osx.dir}.app/Contents/MacOS/${app.osx.dir}" />
            </tarfileset>
            <tarfileset dir="${app.installer.dir}/root" uid="0" gid="80" includes="Applications/${app.osx.dir}.app/Contents/Resources/${app.script}" filemode="777" />        
        </cpio>
        <gzip src="${app.cpio.temp}" destfile="${app.installer.dir}/flat/base.pkg/Payload" />
        <delete file="${app.cpio.temp}" />
        <resourcecount property="app.installer.files.number">
            <fileset dir="${app.installer.dir}/root" />
        </resourcecount>
        <length property="app.installer.files.size.bytes">
            <fileset dir="${app.installer.dir}/root" />
        </length>
        
        <script language="beanshell" classpathref="ant.lib.classpath">
        <![CDATA[
            long length_bytes = Long.parseLong(project.getProperty("app.installer.files.size.bytes"));
            long length_kbytes = Math.round((length_bytes / 1024) * Math.pow(10,2))
                              / Math.pow(10,2);            
            project.setNewProperty("app.installer.files.size.kilobytes", "" + length_kbytes);
        ]]>
        </script>
        
        <echo file="${app.installer.dir}/flat/base.pkg/PackageInfo"><![CDATA[<pkg-info format-version="2" identifier="${mac.bundle}.base.pkg" version="${version}${version.suffix}" install-location="/" auth="root">
  <payload installKBytes="${app.installer.files.size.kilobytes}" numberOfFiles="${app.installer.files.number}"/>
<bundle-version>
    <bundle id="${mac.bundle}" CFBundleIdentifier="${mac.bundle}" path="./Applications/${app.osx.dir}.app" CFBundleVersion="${version}${version.suffix}"/>
</bundle-version>
</pkg-info>]]></echo>


        <mkbom destfile="${basedir}/${app.installer.dir}/flat/base.pkg/Bom">
            <tarfileset dir="${app.installer.dir}/root" uid="0" gid="80" includes="Applications/${app.osx.dir}.app/Contents/MacOS/${app.osx.dir}" filemode="755" />            
            <tarfileset dir="${app.installer.dir}/root" uid="0" gid="80">
                <exclude name="Applications/${app.osx.dir}.app/Contents/Resources/${app.script}" />
                <exclude name="Applications/${app.osx.dir}.app/Contents/MacOS/${app.osx.dir}" />
            </tarfileset>
            <tarfileset dir="${app.installer.dir}/root" uid="0" gid="80" includes="Applications/${app.osx.dir}.app/Contents/Resources/${app.script}" filemode="755" />  
        </mkbom>
        
        <echo file="${app.installer.dir}/flat/Distribution"><![CDATA[<?xml version="1.0" encoding="utf-8"?>
<installer-script minSpecVersion="1.000000" authoringTool="com.apple.PackageMaker" authoringToolVersion="3.0.3" authoringToolBuild="174">
    <title>${product.name} ${version}${version.suffix}</title>
    <options customize="never" allow-external-scripts="no"/>
    <domains enable_anywhere="true"/>
    <installation-check script="pm_install_check();"/>
    <script>function pm_install_check() {
  if(!(system.compareVersions(system.version.ProductVersion,'10.5') >= 0)) {
    my.result.title = 'Failure';
    my.result.message = 'You need at least Mac OS X 10.5 to install ${product.name}';
    my.result.type = 'Fatal';
    return false;
  }
  return true;
}
</script>
    <choices-outline>
        <line choice="choice1"/>
    </choices-outline>
    <choice id="choice1" title="base">
        <pkg-ref id="${mac.bundle}.base.pkg"/>
    </choice>
    <pkg-ref id="${mac.bundle}.base.pkg" installKBytes="${app.installer.files.size.kilobytes}" version="${version}${version.suffix}" auth="Root">#base.pkg</pkg-ref>
</installer-script>]]></echo>                       
       <property name="pkg.file" value="${releases.dir}/${prefix.filename}_${version}${version.suffix}.pkg"/> 
              
       <xar destfile="${basedir}/${pkg.file}" compression="none">
           <tarfileset dir="${app.installer.dir}/flat" group="staff" gid="20" username="builder" uid="501" />
       </xar>                 
    </target>
    
    <target name="deb-versioned" depends="-new-version-set,deb">
        
    </target>
    
    
    <target name="osx-app-bundle" depends="-loadversion,dist">
        <property name="app.script.temp" value="${app.bundle.dir}/${app.osx.dir}.app/Contents/MacOS/${app.osx.dir}"/>
        <echo file="${app.script.temp}">#!/usr/bin/env bash&#10;$(dirname "$${BASH_SOURCE[0]}")/../Resources/${app.script} "$$&#64;"</echo>
        <property name="app.info.temp" value="${app.bundle.dir}/${app.osx.dir}.app/Contents/Info.plist"/>
        <echo file="${app.info.temp}"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDisplayName</key>
	<string>${product.name}</string>
	<key>CFBundleExecutable</key>
	<string>FFDec</string>
	<key>CFBundleIconFile</key>
	<string>Icon.icns</string>
	<key>CFBundleIdentifier</key>
	<string>${mac.bundle}</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>FFDec</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>${version}${version.suffix}</string>
	<key>CFBundleVersion</key>
	<string>${version}${version.suffix}</string>
	<key>LSApplicationCategoryType</key>
	<string>${mac.category.type}</string>
</dict>
</plist>]]></echo>        
        <copy todir="${app.bundle.dir}/${app.osx.dir}.app/Contents/Resources/">
            <fileset dir="${dist.dir}" />
        </copy>                  
        <fixcrlf srcdir="${app.bundle.dir}/${app.osx.dir}.app/Contents/Resources/" eol="lf" includes="**/*.txt" preservelastmodified="true" />
        <fixcrlf srcdir="${app.bundle.dir}/${app.osx.dir}.app/Contents/Resources/" eol="lf" includes="**/*.md" preservelastmodified="true" />    
    </target>
    
    <target name="osx-app-archive" depends="osx-app-bundle">        
        <mkdir dir="${releases.dir}"/>        
        <property  name="osx.zip.file" value="${releases.dir}/${prefix.filename}_${version}${version.suffix}_macosx.zip" />        
        <zip destfile="${osx.zip.file}">
            <zipfileset dir="${app.bundle.dir}" includes="${app.osx.dir}.app/Contents/MacOS/${app.osx.dir}"  filemode="777" />
            <zipfileset dir="${app.bundle.dir}">
                <exclude name="${app.osx.dir}.app/Contents/Resources/${app.script}" />
                <exclude name="${app.osx.dir}.app/Contents/MacOS/${app.osx.dir}" />
            </zipfileset>
            
            <zipfileset dir="${app.bundle.dir}" includes="${app.osx.dir}.app/Contents/Resources/${app.script}" filemode="777" />           
        </zip>           
    </target>
    
    <target name="-set-gui-type">
        <property name="exe.type" value="gui" />
    </target>
    <target name="-set-console-type">
        <property name="exe.type" value="console" />
    </target>
    <target name="-exe-config" depends="-loadversion"> 
        <echoxml file="${exe.config}">
            <launch4jConfig>
                <dontWrapJar>true</dontWrapJar>
                <headerType>${exe.type}</headerType>
                <jar>${jar.filename}.jar</jar>
                <outfile>${basedir}/${dist.dir}/${exe.filename}.exe</outfile>
                <errTitle></errTitle>
                <cmdLine></cmdLine>
                <chdir></chdir>
                <priority>normal</priority>
                <downloadUrl>http://java.com/download</downloadUrl>
                <supportUrl></supportUrl>
                <customProcName>false</customProcName>
                <stayAlive>false</stayAlive>
                <restartOnCrash>false</restartOnCrash>
                <manifest></manifest>
                <icon>${basedir}/${exe.icon}</icon>
                <jre>
                    <path></path>
                    <minVersion>${min.java.version}</minVersion>
                    <maxVersion></maxVersion>
                    <jdkPreference>preferJre</jdkPreference>
                    <runtimeBits>64/32</runtimeBits>
                    <maxHeapPercent>${max.heap.size.percent}</maxHeapPercent>
                    <opt>-Djava.net.preferIPv4Stack=true</opt>
                    <opt>-Djna.nosys=true</opt>
                    <opt>-Dsun.java2d.uiScale=1.0</opt>
                </jre>
                <splash>
                    <file>graphics/splash2.bmp</file>
                    <waitForWindow>true</waitForWindow>
                    <timeout>60</timeout>
                    <timeoutErr>true</timeoutErr>
                </splash>
                <versionInfo>
                    <fileVersion>${version.number}</fileVersion>
                    <txtFileVersion>${version}${version.suffix}</txtFileVersion>
                    <fileDescription>${product.name}</fileDescription>
                    <copyright>${vendor}</copyright>
                    <productVersion>${version.number}</productVersion>
                    <txtProductVersion>${version}${version.suffix}</txtProductVersion>
                    <productName>${product.name}</productName>
                    <companyName></companyName>
                    <internalName>${internal.name}</internalName>
                    <originalFilename>${exe.filename}.exe</originalFilename>
                </versionInfo>
            </launch4jConfig>
        </echoxml>
    </target>    
    <target name="-exe-linux" unless="is_windows" depends="-load-tools,-exe-config">
        <java jar="${launch4j.path}/launch4j.jar" fork="true">
            <arg line="${exe.config}" />
        </java>
    </target>
    <target name="-exe-windows" if="is_windows" depends="-load-tools,-exe-config">
        <java jar="${launch4j.path}/launch4j.jar" fork="true">
            <arg line="${exe.config}" />
        </java>
    </target>   
    <target name="exe" depends="-set-gui-type,-exe-linux,-exe-windows">
        
    </target>
    
    
    <target name="-check-tools">
        <available file="tools.properties" property="tools.config.exists"/>
    </target>
    
    <target name="-load-tools-ok" if="tools.config.exists">
        <loadproperties srcfile="tools.properties" />
    </target>
    
    <target name="-load-tools-fail" unless="tools.config.exists">
        <fail>
            tools.properties NOT found.
            Please create file named "tools.properties" and add two lines:
            nsis.path = Path to Nullsoft Install System
            launch4j.path = Path to launch4j
            
            WARNING: You must use double backslash in paths on Windows System or forward slash
        </fail>
    </target>
    
    <target name="-load-tools" depends="-check-tools,-load-tools-ok,-load-tools-fail">
        
    </target>
    <target name="exe-console" depends="-set-console-type,-exe-linux,-exe-windows">

    </target>

    <target name="release" depends="library,archive,deb,osx-app-archive,installer,osx-app-installer,locales">

    </target>
         
    <target name="all" depends="clean,build,test,release">    
        
    </target>                         
        
    <target name="dist" depends="build,exe">
        <copy todir="${dist.dir}">
            <fileset dir="${resources.dir}" includes="**/*.*"/>
        </copy>
        <copy todir="${dist.dir}" file="${changelog.file}"/>
        <fixcrlf srcdir="${dist.dir}" includes="**/*.md" eol="crlf" preservelastmodified="true" />        
        <fixcrlf srcdir="${dist.dir}" includes="**/*.txt" eol="crlf" preservelastmodified="true" />
        <fixcrlf srcdir="${dist.dir}" includes="**/*.sh" eol="lf" preservelastmodified="true" />
        <fixcrlf srcdir="${dist.dir}" includes="**/*.bat" eol="crlf" preservelastmodified="true" />
    </target>
    
    <target name="locales" depends="-loadversion">
        <delete dir="${locales.target.dir}"/>
        <mkdir dir="${locales.target.dir}/${project.name}"/>
        <copy todir="${locales.target.dir}/${project.name}">
            <fileset dir="${locales.dir}" includes="**/*.*"/>
        </copy>
        <mkdir dir="${locales.target.dir}/jsyntaxpane/bundle/"/>
        <copy todir="${locales.target.dir}/jsyntaxpane/bundle/">
            <fileset dir="libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/jsyntaxpane" includes="**/*.*"/>
        </copy>
        <mkdir dir="${locales.target.dir}/jsyntaxpane/defaultsyntaxkit"/>
        <copy todir="${locales.target.dir}/jsyntaxpane/defaultsyntaxkit">
            <fileset dir="libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/META-INF/services/jsyntaxpane/defaultsyntaxkit" includes="**/*.*"/>
        </copy>
        <mkdir dir="${locales.target.dir}/jsyntaxpane/syntaxkits/flasmsyntaxkit"/>
        <copy todir="${locales.target.dir}/jsyntaxpane/syntaxkits/flasmsyntaxkit">
            <fileset dir="libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/flasmsyntaxkit" includes="**/config*.properties"/>
        </copy>
        <mkdir dir="${locales.target.dir}/jsyntaxpane/syntaxkits/flasm3syntaxkit"/>
        <copy todir="${locales.target.dir}/jsyntaxpane/syntaxkits/flasm3syntaxkit">
            <fileset dir="libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/flasm3syntaxkit" includes="**/config*.properties"/>
        </copy>
        <mkdir dir="${locales.target.dir}/jsyntaxpane/syntaxkits/flasm3methodinfosyntaxkit"/>
        <copy todir="${locales.target.dir}/jsyntaxpane/syntaxkits/flasm3methodinfosyntaxkit">
            <fileset dir="libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/META-INF/services/jsyntaxpane/syntaxkits/flasm3methodinfosyntaxkit" includes="**/config*.properties"/>
        </copy>
        <mkdir dir="${locales.target.dir}/lib"/>
        <copy todir="${locales.target.dir}/lib">
            <fileset dir="${locales.lib.dir}" includes="**/*.*"/>
        </copy>
        <mkdir dir="${locales.target.dir}/nsis"/>
        <copy todir="${locales.target.dir}/nsis">
            <fileset dir="nsis_locales" includes="**/*.*"/>
        </copy>                                
        <echo file="${locales.target.dir}/readme.txt">${project.name} ${version}${version.suffix} localization pack
            -------------------------------------------------------------------            
            Please follow instructions on https://github.com/jindrapetrik/jpexs-decompiler
        </echo>
        <property name="lang.file" value="${releases.dir}/${prefix.filename}_${version}${version.suffix}_lang.zip" />
        <zip destfile="${lang.file}" basedir="${locales.target.dir}"/>
    </target>
    
    <target name="-nightly-suffix" if="nightly">        
        <property name="version.suffix" value="_nightly${version.build}"/>         
    </target>
    
    <target name="-no-suffix" unless="version.suffix">
        <property name="version.suffix" value=""/>         
    </target>
    
    <target name="-private-suffix" if="private">                
        <property name="version.suffix" value="_private_${git.short.tag}"/>         
    </target>
    
    <target name="-suffix" depends="-nightly-suffix,-private-suffix,-no-suffix">
       
    </target>
    <target name="-timestamp" depends="-loadversion,git-tag">
        <tstamp>
            <format property="BUILTAT" pattern="MM/dd/yyyy hh:mm aa" timezone="CET" locale="en"/>
            <format property="VERDATE" pattern="yyyyddMM_hhmm" timezone="CET" locale="en"/>
        </tstamp>        
        <echo level="info" message="Version: ${version}"/>
    </target>
    
    <target name="release_lib" depends="git-tag,-loadversion,-save-version-info,-suffix">
        <copy file="${version_info}" tofile="${core.lib.version_info}" />        
        <ant antfile="${core.lib.script}" target="release" inheritAll="false" usenativebasedir="true"/>
        <property  name="lib.file" value="${lib.releases.dir}/${lib.prefix.filename}_${version}${version.suffix}.zip" />
    </target>
    
    <target name="build_lib" depends="-loadversion,-save-version-info">
        <copy file="${version_info}" tofile="${core.lib.version_info}" />
        <ant antfile="${core.lib.script}" target="build" inheritAll="false" usenativebasedir="true"/>
    </target>
    
    <target name="-copy-lib">
        <copy file="${core.lib.path}" todir="${lib.dir}" />    
    </target>
    
    <target name="clean_lib">
        <ant antfile="${core.lib.script}" target="clean" inheritAll="false" usenativebasedir="true" />
        <delete file="${lib.dir}/${core.lib.name}" />
    </target>
    
    
    <target name="-test_lib-newver" if="new.version">
        <ant antfile="${core.lib.script}" target="testhalt" inheritAll="false" usenativebasedir="true" />    
    </target>
    
    <target name="-test_lib-nonewver" unless="new.version">
        <ant antfile="${core.lib.script}" target="test" inheritAll="false" usenativebasedir="true" />    
    </target>
    
    
    <target name="test_lib" depends="-test_lib-newver,-test_lib-nonewver">
    </target>
    
    <target name="-git-check-exists" >
        <property environment="env" />
        <available file="git" filepath="${env.PATH}" property="git.present" />
        <available file="git.exe" filepath="${env.Path}" property="git.present"/>
        <available file="git.exe" filepath="${env.PATH}" property="git.present" />
    </target>
    
    <target name="-git-required" depends="-git-check-exists" unless="private">             
        <fail unless="git.present" message="Git not found. Please install git with commandline support."/>
    </target>
            
    <target name="-do-git-tag" if="git.present">
        <exec executable="git" outputproperty="git.tag" failonerror="true">
            <arg value="rev-parse"/>
            <arg value="HEAD"/>
        </exec>  
        <exec executable="git" outputproperty="git.short.tag" failonerror="true">
            <arg value="rev-parse"/>
            <arg value="--short"/>
            <arg value="HEAD"/>
        </exec>        
        <echo level="info" message="Git tag:${git.tag}"/>
        <echo level="info" message="Git shorttag:${git.short.tag}"/>
    </target>
    
    <target name="-no-git-tag" if="private" unless="git.present">        
        <property name="git.tag" value="unknown" />
        <property name="git.short.tag" value="unk" />
        <echo level="warning" message="Warning: Git executable not found. No revision hash will be included in release." />
    </target>
    
    <target name="git-tag" depends="-git-required,-no-git-tag,-do-git-tag">        
        
    </target>
    
    <target name="build" depends="-loadversion,build_lib,-copy-lib,-timestamp,-suffix,compile">        
        <mkdir dir="${dist.dir}"/>
        <!-- <delete dir="${dist.lib.dir}"/> -->
        <mkdir dir="${dist.lib.dir}"/>
        <copy todir="${dist.lib.dir}">
            <fileset dir="${lib.dir}" includes="**/*.jar"/>
            <fileset dir="${lib.dir}" includes="**/*.exe"/>
            <fileset dir="${lib.dir}" includes="**/*.txt"/>            
        </copy>
        
        
                                                     
        <propertyfile file="${compile.dir}/${properties.name}"
                      comment="This file is automatically generated - DO NOT EDIT">        
            <entry key="buildtime" value="${BUILTAT}"/>
            <entry key="build" value="${git.tag}"/>
            <entry key="builder" value="${builder}"/>             
            <entry key="version" value="${version}"/>          
            <entry key="nightly" value="${nightly}"/>
            
            <entry key="version.major" value="${version.major}"/>
            <entry key="version.minor" value="${version.minor}"/>
            <entry key="version.release" value="${version.release}"/>
            <entry key="version.build" value="${version.build}"/>
            <entry key="version.debug" value="${version.debug}"/>
        </propertyfile>
        
        <pathconvert pathsep=" " property="manifestClassPath">
            <fileset dir="${dist.dir}" includes="${dist.lib.dirname}/**/*.*"/>
            <chainedmapper>
                <flattenmapper/>
                <globmapper from="*" to="${dist.lib.dirname}/*"/>
            </chainedmapper>
        </pathconvert>

        <jar destfile="${dist.dir}/${jar.filename}.jar" basedir="${compile.dir}">
            <manifest>
                <attribute name="Main-Class" value="${main.class}"/>
                <attribute name="Class-Path" value="${manifestClassPath}"/>
            </manifest>
        </jar>
    </target>

    <target name="run" depends="build">
        <java jar="${dist.dir}/${jar.filename}.jar" fork="true">
            <jvmarg value="-Xmx${max.heap.size.run}m" />
            <jvmarg value="-Djava.net.preferIPv4Stack=true" />
            <jvmarg value="-Dsun.java2d.uiScale=1.0" />
            <arg line="${run.params}" />
        </java>
    </target>


    <target name="javadoc">
        <mkdir dir="${javadoc.dir}"/>
        <javadoc sourcepath="${src.dir}" destdir="${javadoc.dir}" windowtitle="${project.name}"
                 useexternalfile="yes">
            <fileset dir="${src.dir}" includes="**/*.java"/>
            <classpath>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
            </classpath>
        </javadoc>
    </target>
    <target name="clean" depends="clean_lib">        
        <delete dir="${compile.dir}"/>        
        <delete dir="${compile.test.dir}"/>
        <delete dir="${coverage.dir}"/>
        <delete dir="${coverage.result.dir}"/>        
        <delete dir="${test.result.dir}"/>
        <delete dir="${locales.target.dir}"/>
        <delete dir="${javadoc.dir}"/>
        <delete dir="${dist.dir}"/>  
        <delete dir="${app.installer.dir}"/>  
        <delete dir="${app.bundle.dir}"/>  
    </target>
    
    <!-- Debug one test method (Netbeans IDE) -->
    <target name="debug-test-method" depends="compile-tests">
        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
        <fail unless="test.method">Must select some method in the IDE or set test.method</fail>
        <delete dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}"/>
        <mkdir dir="${test.result.dir}/raw/"/>
     
        <nbjpdastart addressproperty="jpda.address" name="ffdec" transport="dt_socket">
            <classpath>
                <pathelement path="${compile.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
        </nbjpdastart>
        
        <testng 
            outputDir="${test.result.dir}"
            haltOnFailure="false" verbose="2" workingDir="${basedir}" methods="${test.class}.${test.method}">
        
            <classpath>
                <pathelement path="${compile.test.dir}"/>
                <pathelement path="${compile.dir}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
                <fileset dir="${test.lib.dir}" includes="**/*.jar"/>
            </classpath>
            <jvmarg value="-noverify" />
            <jvmarg value="-Xdebug"/>
            <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
            <classfileset dir="${compile.test.dir}" includes="**/*.class" />                                    
        </testng>     
    </target>
    
    
    <target name="git-pull" depends="-git-required">
        <exec executable="git" failonerror="true">
            <arg value="pull"/>            
        </exec> 
    </target>
    
    <target name="git-push">
        <!-- NOTHING -->       
    </target>
    
    <target name="-loadoldversion">
        <loadproperties srcfile="${version_info}" prefix="oldversion" />
    </target>
        
    <target name="-save-version-info-file">        
        <propertyfile file="${version_info}"
                      comment="DO NOT MODIFY - it is updated automatically with the build script">                               
            <entry key="major" value="${version.major}"/>
            <entry key="minor" value="${version.minor}"/>
            <entry key="release" value="${version.release}"/>
            <entry key="build" value="${version.build}"/>
            <entry key="debug" value="${version.debug}"/>
        </propertyfile>        
    </target>     
    
    <target name="-save-version-info" depends="-save-version-info-file">
        
    </target>
    
    <target name="-new-version-set">
        <property name="new.version" value="1" />
    </target>
    
    <target name="new-version" depends="-new-version-set,all">
        
    </target>          
    
    <target name="new-version-library" depends="-new-version-set,library">
        
    </target>
    
    <target name="new-version-archive" depends="-new-version-set,archive">
        
    </target>
    
    <target name="new-version-deb" depends="-new-version-set,deb">
        
    </target>
    
    <target name="new-version-osx-app-archive" depends="-new-version-set,osx-app-archive">
        
    </target>
    
    <target name="new-version-installer" depends="-new-version-set,installer">
        
    </target>
    
    <target name="new-version-osx-app-installer" depends="-new-version-set,osx-app-installer">
        
    </target>
    
    <target name="new-version-locales" depends="-new-version-set,locales">
        
    </target>
    
    <target name="windows-home" >
        
    </target>
                  
    
    <property environment="env" />
    
    <condition property="windows_appdata_isset">
        <and>
            <os family="windows"/>                
            <isset property="env.APPDATA" />
        </and>
    </condition>
    <condition property="windows_home_isset">
        <and>
            <isset property="user.home" />
            <os family="windows"/>                            
        </and>
    </condition>
    
    <condition property="osx_home_isset">
        <and>
            <isset property="user.home" />
            <os family="mac"/>                    
        </and>        
    </condition>
    
    
    <condition property="os_specific_home_isset">
        <or>
            <isset property="osx_home_isset" />
            <isset property="windows_appdata_isset" />                            
            <isset property="windows_home_isset" />  
        </or>        
    </condition>
    
    <target name="-get-env">
        <property environment="env"/>
    </target>
    
    <target name="-get-home-from-user-windows-appdata" if="windows_appdata_isset">
        <property name="app.homedir" value="${env.APPDATA}\${vendor}\${project.name}" />
        <echo message="Detected homedir in Windows APPDATA: ${app.homedir}" level="info"/>
    </target>
    
    <target name="-get-home-from-user-windows-home" if="windows_home_isset" unless="windows_appdata_isset">
        <property name="app.homedir" value="${user.home}\Application Data\${vendor}\${project.name}" />
        <echo message="Detected homedir in Windows home Application Data: ${app.homedir}" level="info"/>
    </target>
    <target name="-get-home-from-user-osx-home" if="osx_home_isset">
        <property name="app.homedir" value="${user.home}/Library/Application Support/${project.name}" />
        <echo message="Detected homedir in OSX: ${app.homedir}" level="info"/>
    </target>   
       
    <target name="-get-home-from-user" if="user.home" unless="os_specific_home_isset">
        <property name="app.homedir" value="${user.home}/.${project.name}" />
        <echo message="Detected homedir in user home: ${app.homedir}" level="info"/>
    </target>   
    
    <target name="-get-home-no" unless="user.home">
        <property name="app.homedir" value="." />
        <echo message="Detected homedir in current dir: ${app.homedir}" level="info"/>
    </target>   
                                                                                                                                                                                                                                                                                                    
    <target name="-get-home" depends="-get-home-from-user-windows-appdata,-get-home-from-user-windows-home,-get-home-from-user-osx-home,-get-home-from-user,-get-home-no">        
        
    </target>
    
    <target name="-get-playerglobal-home" depends="-get-home">
        <property name="playerglobal.homedir" value="${app.homedir}/flashlib"/>
        <mkdir dir="${playerglobal.homedir}"/>
        <echo message="PlayerGlobal homedir: ${playerglobal.homedir}" level="info"/>
    </target>
    
    <target name="download-playerglobal" depends="-get-playerglobal-home">
        <tempfile property="adobe.temp.file" prefix="adobepages" suffix=".html" deleteonexit="true" />
        <get src="${adobe.playerglobal.pages.url}" dest="${adobe.temp.file}" />       
        <replaceregexp flags="s" file="${adobe.temp.file}" match=".*&lt;a href=&quot;([^&quot;]+)&quot;&gt;&lt;img[^&gt;]*/&gt;Download the playerglobal\.swc to target the latest version APIs&lt;/a&gt;.*" replace="\1" />
        <loadfile srcfile="${adobe.temp.file}" property="playerglobal.url" />
        <replaceregexp file="${adobe.temp.file}" match=".*/([^/]+\.swc)$" replace="\1" />        
        <loadfile srcfile="${adobe.temp.file}" property="playerglobal.filename" />
        <get src="${playerglobal.url}" dest="${playerglobal.homedir}/${playerglobal.filename}" />
        <delete file="${adobe.temp.file}"/>
    </target>
    <target name="fix-src-endoflines">
        <fixcrlf srcdir="${src.dir}" includes="**/*.java" />
        <fixcrlf srcdir="${src.dir}" includes="**/*.properties" />
        <fixcrlf srcdir="${src.dir}" includes="**/*.txt" />        
        <fixcrlf srcdir="${src.dir}" includes="**/*.md" />
        <fixcrlf srcdir="${src.dir}" includes="**/*.xml" />                
        <fixcrlf srcdir="${src.dir}" includes="**/*.flex" />                        
        <fixcrlf srcdir="${src.dir}" includes="**/*.bat" eol="crlf" />
        <fixcrlf srcdir="${src.dir}" includes="**/*.sh" eol="lf" />
        <ant antfile="${core.lib.script}" target="fix-src-endoflines" inheritAll="false" usenativebasedir="true" />        
    </target>
    <target name="deps" depends="download-playerglobal">
        
    </target>        
</project>
