<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="all" name="prix">
    <property name="dist" value="dev"/>

    <!--environment is broken for Win XP -->
    <!--property environment="env"/-->
    <property name="env.USERDOMAIN" value="cunix"/>
    <property location="/tmp" name="env.TMP"/>

    <property file="../properties/${env.USERDOMAIN}_${user.name}.properties"/>
    <property location="${env.TMP}/prix" name="build"/>
    <!-- property location="${user.home}/${www}/prix" name="dist.dir"/ -->
    <property location="${www}/prix" name="dist.dir"/>
    <property location="${build}/install" name="install.dir"/>
    <property location="${install.dir}/code" name="code.dir"/>
    <taskdef classname="org.jini.rio.tools.ant.ClassDepTask" classpath="${src}\lib\ant-rio-ext.jar" name="classdep"/>

    <target depends="" name="dirs">
        <mkdir dir="${dist.dir}"/>
        <mkdir dir="${dist.dir}/code"/>
        <mkdir dir="${dist.dir}/jnlp"/>
        <mkdir dir="${dist.dir}/html"/>
        <mkdir dir="${dist.dir}/security"/>
        <mkdir dir="${code.dir}"/>
        <copy todir="${code.dir}">
            <fileset dir="${dist.dir}/../core/code-dl">
                <include name="ninja-dl.jar"/>
            </fileset>
            <fileset dir="${dist.dir}/../core/code">
                <include name="ninja.jar"/>
            </fileset>
            <fileset dir="${src}/lib">
                <include name="rio-dl.jar"/>
                <include name="teahouse.jar"/>
                <!-- jini files -->
                <include name="jini-core.jar"/>
                <include name="jini-ext.jar"/>
                <include name="sun-util.jar"/>
                <!-- rio files -->
                <include name="jsb-boot.jar"/>
                <include name="loader.jar"/>
                <include name="rio-core.jar"/>
                <include name="cybernode.jar"/>
                <include name="serviceui.jar"/>
            </fileset>
        </copy>
        <copy todir="${dist.dir}/code">
            <fileset dir="${dist.dir}/../core/code-dl">
                <include name="ninja-dl.jar"/>
                <include name="ninja.war"/>
            </fileset>
            <fileset dir="${src}/lib">
                <include name="cybernode-ui.jar"/>
                <include name="cybernode-dl.jar"/>
                <include name="rio-dl.jar"/>
            </fileset>
        </copy>
    </target>

    <target depends="clean,launch-jar" name="all">
        <!-- WRITEME -->
    </target>

    <target name="clean">
        <delete dir="${build}" failonerror="true" verbose="false"/>
    </target>
    <target depends="dirs" name="compile">
        <property name="class.dir" value="${build}"/>
        <path id="class.path">
            <pathelement path="${src}/lib/jini-core.jar"/>
            <pathelement path="${src}/lib/jini-ext.jar"/>
            <pathelement path="${src}/lib/serviceui.jar"/>
            <pathelement path="${src}/lib/sun-util.jar"/>
            <pathelement path="${src}/lib/rio-core.jar"/>
            <pathelement path="${dist.dir}/../core/code/ninja.jar"/>
            <pathelement path="${src}/lib/servlet.jar"/>
            <pathelement path="${src}/lib/javaws.jar"/>
            <pathelement path="${src}/lib/cybernode.jar"/>
            <pathelement path="${src}/lib/teahouse.jar"/>
        </path>
        <mkdir dir="${class.dir}"/>
        
        <javac classpath="" destdir="${class.dir}" failonerror="true" includes="**/*.java" source="1.3" srcdir="${src}/com/millipad/util" target="1.1"/>
        <javac classpathref="class.path" destdir="${class.dir}" failonerror="true" includes="**/*.java" source="1.3" srcdir="${src}/net/jini/print" target="1.1"/>
        <javac classpathref="class.path" debug="false" depend="false" destdir="${class.dir}" failonerror="true" includes="**/*.java" source="1.3" srcdir="${src}/edu/columbia/print/ninja/prix" target="1.1" verbose="false"/>
        <rmic base="${class.dir}" debug="true" verify="true">
            <classpath refid="class.path"/>
            <classpath path="${class.dir}"/>
        </rmic>
        <copy todir="${class.dir}/edu/columbia/print/ninja/prix">
            <fileset dir="${src}/edu/columbia/print/ninja/prix" id="changeme" includes="**/*.properties,**/*.ser,**/*.gif"/>
        </copy>
        <mkdir dir="${class.dir}/install"/>
    </target>
    <target depends="compile" name="main-jar">
        <property name="class.dir" value="${build}"/>
        <classdep basedir="${class.dir}" compress="true" files="true" jarfile="${code.dir}/prix.jar" manifest="MANIFEST.MF">
            <classpath>
                    <pathelement path="${class.dir}"/>
                    <pathelement path="${src}/lib/jini-core.jar"/>
                    <pathelement path="${src}/lib/jini-ext.jar"/>
                    <pathelement path="${src}/lib/serviceui.jar"/>
                    <pathelement path="${src}/lib/sun-util.jar"/>
                    <pathelement path="${src}/lib/rio-core.jar"/>
                    <pathelement path="${src}/lib/cybernode.jar"/>
                    <pathelement path="${dist.dir}/../core/code/ninja.jar"/>
            </classpath>
            <out name="java"/>
            <out name="javax"/>
            <out name="sun"/>
            <out name="com.millipad.teahouse"/>
            <skip name="edu.columbia.print.ninja.prix.display.WebServer"/>
            <element name="edu.columbia.print.ninja.prix.Prix"/>
            <element name="edu.columbia.print.ninja.prix.Prix_Stub"/>
            <element name="edu.columbia.print.ninja.prix.display.Gui"/>
            <element name="edu.columbia.print.ninja.prix.display.Gui_Stub"/>
            <element name="edu.columbia.print.ninja.prix.requester.SpoolIntercept"/>
            <element name="edu.columbia.print.ninja.prix.requester.LprRequester"/>
            <element name="edu.columbia.print.ninja.prix.requester.WinRequester"/>
            <element name="edu.columbia.print.ninja.prix.service.lpr.LprPrinter"/>
            <element name="edu.columbia.print.ninja.prix.authenticate.PcdAuth"/>
            <include name="edu/columbia/print/ninja/prix/**/*.properties"/>
            <include name="edu/columbia/print/ninja/prix/**/*.ser"/>
            <include name="edu/columbia/print/ninja/prix/**/*.gif"/>
            
        </classdep>
        <classdep basedir="${class.dir}" compress="true" debug="false" edges="false" files="true" jarfile="${dist.dir}/code/prix-dl.jar" manifest="MANIFEST-DL.MF">
            <classpath>
                    <pathelement path="${class.dir}"/>
                    <pathelement path="${src}/lib/jini-core.jar"/>
                    <pathelement path="${src}/lib/jini-ext.jar"/>
                    <pathelement path="${src}/lib/serviceui.jar"/>
                    <pathelement path="${src}/lib/sun-util.jar"/>
                    <pathelement path="${src}/lib/rio-core.jar"/>
                    <pathelement path="${dist.dir}/../core/code/ninja.jar"/>
            </classpath>
            <out name="java"/>
            <out name="javax"/>
            <out name="sun"/>
            <out name="com.millipad.teahouse"/>
            <element name="edu.columbia.print.ninja.prix.Prix_Stub"/>
            <element name="edu.columbia.print.ninja.prix.authenticate.PcdAuth"/>
            <element name="com.millipad.util.RemoteBlockingStackImpl_Stub"/>
            <element name="edu.columbia.print.ninja.prix.display.Gui"/>
            <element name="edu.columbia.print.ninja.prix.display.Gui_Stub"/>
            <include name="edu/columbia/print/ninja/prix/**/*.properties"/>
            <include name="edu/columbia/print/ninja/prix/display/*.gif"/>
        </classdep>
        <classdep basedir="${class.dir}" compress="true" files="true" jarfile="${code.dir}/webserver.jar">
            <classpath>
                    <pathelement path="${class.dir}"/>
                    <pathelement path="${src}/lib/jini-core.jar"/>
                    <pathelement path="${src}/lib/jini-ext.jar"/>
                    <pathelement path="${src}/lib/serviceui.jar"/>
                    <pathelement path="${src}/lib/sun-util.jar"/>
                    <pathelement path="${src}/lib/rio-core.jar"/>
                    <pathelement path="${src}/lib/cybernode.jar"/>
                    <pathelement path="${dist.dir}/../core/code/ninja.jar"/>
            </classpath>
            <out name="java"/>
            <out name="javax"/>
            <out name="sun"/>
            <element name="edu.columbia.print.ninja.prix.display.WebServer"/>
        </classdep>
        
    </target>
    
    <target depends="compile" name="main-war">
        <property name="class.dir" value="${build}"/>

        <copy todir="${src}/edu/columbia/print/ninja/prix/admin/WEB-INF/lib/">
            <fileset dir="${src}/edu/columbia/print/ninja/core/admin/WEB-INF/lib/">
                <include name="ninja.jar"/>
            </fileset>
        </copy>
        <classdep basedir="${class.dir}" compress="true" edges="false" files="true" jarfile="${src}/edu/columbia/print/ninja/prix/admin/WEB-INF/lib/prix.jar" outer="true">
            <classpath>
                    <pathelement path="${class.dir}"/>
                    <pathelement path="${src}/lib/jini-core.jar"/>
                    <pathelement path="${src}/lib/jini-ext.jar"/>
                    <pathelement path="${src}/lib/serviceui.jar"/>
                    <pathelement path="${src}/lib/sun-util.jar"/>
                    <pathelement path="${src}/lib/rio-core.jar"/>
            </classpath>
            <out name="java"/>
            <out name="javax"/>
            <out name="sun"/>
            <element name="net.jini.print.lookup.AttributeEntry"/>
            <element name="edu.columbia.print.ninja.prix.Station"/>
            <include name="edu/columbia/print/ninja/prix/*.properties"/>
        </classdep>
        
        <war basedir="${src}/edu/columbia/print/ninja/prix/admin" compress="true" warfile="${dist.dir}/code/prix.war" webxml="${src}/edu/columbia/print/ninja/prix/admin/WEB-INF/web.xml"/>
    </target>

    <target depends="main-jar,main-war" name="install-jar">
        <zip basedir="${install.dir}" compress="true" includes="**/*" zipfile="${class.dir}\install.zip"/>
        <classdep basedir="${class.dir}" compress="true" edges="false" files="true" jarfile="${dist.dir}/code/prix-install.jar" outer="true">
            <classpath>
                    <pathelement path="${class.dir}"/>
                    <pathelement path="${src}/lib/jini-core.jar"/>
                    <pathelement path="${src}/lib/jini-ext.jar"/>
                    <pathelement path="${src}/lib/serviceui.jar"/>
                    <pathelement path="${src}/lib/sun-util.jar"/>
                    <pathelement path="${src}/lib/rio-core.jar"/>
                    <pathelement path="${src}/lib/javaws.jar"/>
            </classpath>
            <out name="java"/>
            <out name="javax"/>
            <out name="sun"/>
            <element name="edu.columbia.print.ninja.prix.Installer"/>
            <include name="install.zip"/>
        </classdep>
        <exec executable="jarsigner" vmlauncher="true">
            <arg value="-storepass"/>
            <arg value="password"/>
            <arg value="${dist.dir}/code/prix-install.jar"/>
            <arg value="atg"/>
        </exec>
    </target>

    <target depends="install-jar" name="launch-jar">
        <classdep basedir="${class.dir}" compress="true" edges="false" files="true" jarfile="${dist.dir}/code/prix.jar" outer="true">
            <classpath>
                    <pathelement path="${class.dir}"/>
                    <pathelement path="${src}/lib/jini-core.jar"/>
                    <pathelement path="${src}/lib/jini-ext.jar"/>
                    <pathelement path="${src}/lib/serviceui.jar"/>
                    <pathelement path="${src}/lib/sun-util.jar"/>
                    <pathelement path="${src}/lib/rio-core.jar"/>
                    <pathelement path="${src}/lib/javaws.jar"/>
            </classpath>
            <out name="java"/>
            <out name="javax"/>
            <out name="sun"/>
            <element name="edu.columbia.print.ninja.prix.Launcher"/>
        </classdep>
        <exec executable="jarsigner" vmlauncher="true">
            <arg value="-storepass"/>
            <arg value="password"/>
            <arg value="${dist.dir}/code/prix.jar"/>
            <arg value="atg"/>
        </exec>
    </target>

    <target depends="main-jar,main-war,install-jar" name="jars">
    </target>
    
</project>
