<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="ScriptBuilder_Repo" default="default" basedir=".">
    <description>Builds, tests, and runs the project ScriptBuilder_Repo.</description>
    <import file="nbproject/build-impl.xml"/>

<!--        STORE SUBVERSION BUILD STRING      -->
<target name="-post-init" description="Sets the buildversion for the current build">
    <exec outputproperty="svna.version" executable="svnversion">
        <arg value="-c" />
        
        <redirector>
            <outputfilterchain>
                <tokenfilter>
                    <replaceregex pattern="^[0-9]*:?" replace="" flags="g"/>
                    <replaceregex pattern="M" replace="" flags="g"/>
                </tokenfilter>
            </outputfilterchain>
        </redirector>
    </exec>
    <propertyfile file="${src.dir}/scriptbuilder/gui/application.properties">
        <entry key="Application.revision" value="${svna.version}" type="int" operation="="/>
    </propertyfile>
    <echo>Setting SVN version: ${svna.version}</echo>
</target>
<target name="-post-jar" description="Sets the buildversion for the current build">
    <propertyfile file="${src.dir}/scriptbuilder/gui/application.properties">
        <entry key="Application.buildnumber" value="1" type="int" operation="+"/>
    </propertyfile>
</target>
<target name="package-jars" depends="jar">

        <!-- Change the value of this property to be the name of your JAR,
             minus the .jar extension. It should not have spaces.
             <property name="deploy.jar.name" value="MyJarName"/>
        -->
        <property name="deploy.jar.name" value="ScriptBuilder"/>


        <!-- don't edit below this line -->

        <property name="deploy.dir" value="deploy"/>
        <property name="deploy.jar" value="${deploy.dir}/${deploy.jar.name}.jar"/>

        <echo message="Packaging ${application.title} into a single JAR at ${deploy.jar}"/>

        <delete dir="${deploy.dir}"/>
        <mkdir dir="${deploy.dir}"/>

        <jar destfile="${deploy.dir}/temp_final.jar" filesetmanifest="skip">
            <zipgroupfileset dir="dist" includes="*.jar"/>
            <zipgroupfileset dir="dist/lib" includes="*.jar"/>

            <manifest>
                <attribute name="Main-Class" value="${main.class}"/>
            </manifest>
        </jar>

        <zip destfile="${deploy.jar}">
            <zipfileset src="${deploy.dir}/temp_final.jar"
            excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
        </zip>

        <delete file="${deploy.dir}/temp_final.jar"/>

    </target>
  <!-- =================================================================== -->
  <!-- Make zip file for distribution that contains Jar and Incidents      -->
  <!-- =================================================================== -->
  <target name="zip" depends="package-jars" description="Make zip file">
        <property name="deploy.dir" value="deploy"/>
    <zip destfile="${deploy.dir}/ScriptBuilder.zip">
    <zipfileset     
         dir="${deploy.dir}"
         includes="**.jar"
         filemode="755"
    />
    </zip>
    <zip destfile="${deploy.dir}/ScriptBuilder.zip"
         basedir="."
	 includes="Incidents/**"
         update="true"
    />
    <zip destfile="${deploy.dir}/ScriptBuilder.zip"
         basedir="src/scriptbuilder/gui/"
	 includes="application.properties"
         update="true"
    />
  </target>
</project>
