<?xml version="1.0" encoding="UTF-8"?>
<!-- Builds the ImageLab3D cookbook for TWiki. -->
<project name="build-montemedia" default="all" basedir=".">
    <target name="init">
        <property name="author" value="Werner Randelshofer"/>
        <property name="version" value="0.6.8"/>
        <property name="buildnb" value=""/>
        <property name="name" value="MonteMedia"/>
        <property name="date" value="2012-04-26"/>
        <property name="versionLong" value="${version} ${date}"/>
        <property name="lib" value="lib"/>
        <property name="dist" value="dist"/>
        <property name="classes" value="build/classes"/>
        <property name="project.jhotdraw.src" value="../../../../JHotDraw/current/trunk/jhotdraw7/src/main/java"/>
        <property name="project.jai-core.src" value="../../../../JAI/current/JAI-Core/src/share/classes"/>
        <property name="project.jai-imageio-core.src" value="../../../../JAI/current/JAI-ImageIO-Core/src/share/classes"/>
        <property name="src.main" value="src/main"/>
        <property name="src.main.jmf" value="src/main.jmf"/>
        <property name="src.main.jmf.gpl" value="src/main.jmf.gpl"/>
        <property name="src.fmj" value="src/fmj"/>
        <property name="src.fmj.ejmf" value="src/fmj.ejmf"/>
        <property name="src.fmj.rtp" value="src/fmj.rtp"/>
        <property name="src.fmj.utils" value="src/fmj.utils"/>
        <property name="src.jai.core" value="src/jai.core"/>
        <property name="src.jffmpeg" value="src/jffmpeg"/>
        <property name="src.jmf" value="src/jmf"/>
    </target>
    
    <target name="copy sources from JAI-Core" depends="init">
        <copy todir="${src.jai.core}">
            <fileset dir="${project.jai-core.src}">
                <exclude name="**/.*"/>
            </fileset>
        </copy>
    </target>
    <target depends="init" description="Try running it." name="run JMF Registry">
        <java classname="JMFRegistry"
         classpath="${classes}:${lib}/jmf.jar"
         failonerror="true" fork="true"
         >
            <jvmarg value="-Xmx1024M"/>
            <jvmarg value="-Dapple.laf.useScreenMenuBar=true"/>
            <jvmarg value="-Dcom.apple.macos.useScreenMenuBar=true"/>
            <jvmarg value="-Djava.library.path=${lib}"/>
        </java>
    </target>
    <target depends="init" description="Javadoc" name="javadoc">
        <delete dir="${dist}/javadoc"/>
        <mkdir dir="${dist}/javadoc"/>
        <javadoc destdir="${dist}/javadoc" doctitle="${name} ${version}"
        footer="Copyright ${date} ${author}"
        header="Copyright ${date} ${author}"
        windowtitle="Monte Media ${version}"
        encoding="UTF-8"
        >
            <packageset dir="${src.main}">
                <include name="org/monte/**"/>
            </packageset>
            <packageset dir="${src.main.jmf}">
                <include name="org/monte/**"/>
            </packageset>
            <!--
            <sourcepath>
                <pathelement location="${src.main}"/>
                <pathelement location="${src.fmj}"/>
                <pathelement location="${src.fmj.ejmf}"/>
                <pathelement location="${src.fmj.rtp}"/>
                <pathelement location="${src.fmj.utils}"/>
            </sourcepath>
            -->
            <classpath>
                <fileset dir="${lib}">
                    <include name="**/*.jar"/>
                </fileset>
                <fileset dir="/System/Library/Java/Extensions">
                    <include name="QTJava.zip"/>
                </fileset>
            </classpath>
        </javadoc>
    </target>
   <target depends="init"
    description="Bundle the software." name="bundle Src">
       <mkdir dir="${dist}"/>
        <zip destfile="${dist}/${name}-${version}src.zip">
            <fileset dir="..">
                <include name="Media/**"/>
                <exclude name="Media/build/**"/>
                <exclude name="Media/dist/**"/>
                <exclude name="**/.*"/>
            </fileset>
        </zip>
    </target>
   <target depends="init,clean,jar,jar CC,javadoc"
    description="Bundle the software." name="bundle Src CC">
       <mkdir dir="${dist}"/>
        <zip destfile="${dist}/${name}-${version}src-cc.zip">
            <fileset dir="..">
                <include name="Media/**"/>
                <exclude name="Media/dist/**"/>
                <exclude name="Media/build/**"/>
                <exclude name="Media/lib/**"/>
                <exclude name="Media/src/fmj/**"/>
                <exclude name="Media/src/fmj.ejmf/**"/>
                <exclude name="Media/src/fmj.rtp/**"/>
                <exclude name="Media/src/fmj.utils/**"/>
                <exclude name="Media/src/jai.core/**"/>
                <exclude name="Media/src/jffmpeg/**"/>
                <exclude name="Media/src/jmf/**"/>
                <exclude name="Media/src/main.jmf/**"/>
                <exclude name="Media/src/main.jmf.gpl/**"/>
                <exclude name="**/.*"/>
            </fileset>
            <fileset dir="..">
                <include name="Media/dist/monte*.jar"/>
                <include name="Media/dist/javadoc/**"/>
            </fileset>
        </zip>
    </target>
    <target name="clean" depends="init">
        <delete dir="${classes}" />
        <delete dir="${dist}/TSCCDemo ${version}" />
    </target>
    <target name="compile" depends="init,clean">
        <mkdir dir="${classes}"/>
        <javac
                destdir="${classes}"
                srcdir="${src.main}:${src.main.jmf}:${src.main.jmf.gpl}:${src.fmj}:${src.fmj.ejmf}:${src.fmj.rtp}:${src.fmj.utils}:${src.jffmpeg}"
                debug="true"
                source="1.5"
                target="1.5"
                optimize="true"
                encoding="UTF-8"
                includeantruntime="false"
         >
            <classpath>
                <fileset dir="${lib}">
                    <include name="jmf.jar"/>
                    <include name="jdom.jar"/>
                </fileset>
            </classpath>
            
            <exclude name="**/package-info.java"/>
        </javac>
        <copy todir="${classes}">
            <fileset dir="${src.main}" >
                <exclude name="**/*.java"/>
                <exclude name="**/.*"/>
            </fileset>
            <fileset dir="${src.main.jmf}" >
                <exclude name="**/*.java"/>
                <exclude name="**/.*"/>
            </fileset>
            <fileset dir="${src.main.jmf.gpl}" >
                <exclude name="**/*.java"/>
                <exclude name="**/.*"/>
            </fileset>
        </copy>
    </target>
    <target name="jar" depends="init,compile">
        <mkdir dir="${dist}"/>
        <jar destfile="${dist}/monte-gpl.jar" basedir="${classes}" compress="true">
            <manifest>
                <attribute name="Built-By" value="${author}"/>
                <attribute name="Main-Class" value="MovieMaker"/>
                <attribute name="Class-Path" value="jmf.jar,jdom.jar,jai_codec.jar,jai_core.jar"/>
                <attribute name="Implementation-Version" value="${versionLong}"/>
            </manifest>
            <include name="org/monte/**"/>
            <include name="*.class"/>
        </jar>
    </target>
    <target name="jar CC" depends="init,compile">
        <mkdir dir="${dist}"/>
        <jar destfile="${dist}/monte-cc.jar" basedir="${classes}" compress="true">
            <manifest>
                <attribute name="Built-By" value="${author}"/>
                <attribute name="Main-Class" value="MovieMaker"/>
                <attribute name="Class-Path" value="jmf.jar,jdom.jar,jai_codec.jar,jai_core.jar"/>
                <attribute name="Implementation-Version" value="${versionLong}"/>
            </manifest>
            <include name="org/monte/**"/>
            <include name="*.class"/>
            <exclude name="org/monte/media/jmf/demux/vob/**"/>
        </jar>
    </target>
</project>
