
<project name="IGV" default="all" basedir=".">

    <!-- Properties-->
    <property name="jar.name"      value="igv.jar" />

    <!-- Source and lib directories -->
    <property name="src.dir"       value="${basedir}/src/" />
    <property name="lib.dir"       value="${basedir}/lib/" />

    <!-- Platform specific input files -->
    <property name="native.dir"        value="${basedir}/native/" />
    <property name="win.dir"           value="${native.dir}/win/" />
    <property name="mac.intel.dir"     value="${native.dir}/mac-intel/" />
    <property name="mac.powerpc.dir"   value="${native.dir}/mac-powerpc/" />
    <property name="linux64.dir"       value="${native.dir}/linux-64/" />
    <property name="linux.dir"       value="${native.dir}/linux/" />

    <!-- Temp directory.  Sources are compiled here prior to archiving -->
    <property name="tmp.dir"       value="${basedir}/tmp/" />
    <property name="resource.dir"  value="${tmp.dir}resources/" />

    <!-- Distribution directory.  Binary distribution is placed here -->
    <property name="jar.path"      value="${tmp.dir}${jar.name}" />

    <!-- build specific properties.  -->
    <property name="build-number"  value="0" />
    <property name="version"       value="1.3.1" />
    <property name="data-server-url"    value="http://www.broad.mit.edu/igv/resources/dataServerRegistry.txt" />


    <!-- Clean all generated artifacts -->
    <target name="clean">
        <delete dir="${tmp.dir}" />
    </target>
    

    <target name="init" depends="clean">

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

        <!-- Copy resource files to the tmp directory -->
        <copy todir="${tmp.dir}" overwrite="true" >
            <fileset dir="${src.dir}">
                <exclude name="**/*.form"/>
                <exclude name="**/*.java"/>
                <exclude name="**/*.svn"/>
                <exclude name="**/manifest.mf"/>
            </fileset>
        </copy>


        <!-- Create class path for manifest -->
        <path id="@jars">
            <pathelement path="${lib.dir}AbsoluteLayout.jar" />
            <pathelement path="${lib.dir}ATV-3.1.jar" />
            <pathelement path="${lib.dir}colt.jar" />
            <pathelement path="${lib.dir}commons-math-1.1.jar" />
            <pathelement path="${lib.dir}concurrent.jar" />
            <pathelement path="${lib.dir}jargs.jar" />
            <pathelement path="${lib.dir}jhdf5.jar" />
            <pathelement path="${lib.dir}jhdf.jar" />
            <pathelement path="${lib.dir}jibble.jar" />
            <pathelement path="${lib.dir}jide-action.jar" />
            <pathelement path="${lib.dir}jide-common.jar" />
            <pathelement path="${lib.dir}jide-components.jar" />
            <pathelement path="${lib.dir}jide-dialogs.jar" />
            <pathelement path="${lib.dir}jide-dock.jar" />
            <pathelement path="${lib.dir}jide-grids.jar" />
            <pathelement path="${lib.dir}jlfgr-1_0.jar" />
            <pathelement path="${lib.dir}ledatastream.jar" />
            <pathelement path="${lib.dir}log4j-1.2.15.jar" />
            <pathelement path="${lib.dir}maf.jar" />
            <pathelement path="${lib.dir}sam-1.0.jar" />
            <pathelement path="${lib.dir}swing-layout-1.0.jar" />
        </path>

        <pathconvert property="class-path" pathsep=" " dirsep="/" refid="@jars">
            <map from="${lib.dir}" to="lib/"/>
        </pathconvert>

        <tstamp>
            <format property="timestamp" pattern="MM/dd/yyyy hh:mm aa" />
        </tstamp>
        <echo message="Resource ${resource.dir}"/>
        <echo message="Version ${version}"/>
        <replace file="${resource.dir}about.properties" token="@VERSION" value="${version}"/>
        <replace file="${resource.dir}about.properties" token="@BUILD" value="${build-number}"/>
        <replace file="${resource.dir}about.properties" token="@TIMESTAMP" value="${timestamp}"/>
        <replace file="${resource.dir}about.properties" token="@DEFAULT_MASTER_RESOURCE_URL" value="${data-server-url}"/>

    </target>

    <target name="build" depends="compile">
        <jar destfile="${basedir}/${jar.name}"  basedir="${tmp.dir}">

            <manifest>
            <attribute name="Class-Path" value="${class-path}" />
            <attribute name="Built-By" value="${user.name}" />
            <attribute name="Main-Class" value="org.broad.igv.ui.IGVMainFrame"/>
            </manifest>
        </jar>
    </target>

    <target name="compile" depends="init">
        <javac srcdir="${src.dir}"  debug="on" destdir="${tmp.dir}">
            <classpath refid="@jars" />
        </javac>
    </target>

    <target name="all" depends="build, clean"/>
    

</project>
