<project name="JenaCheck" default="jar" basedir=".">

    <path id="project.class.path">
        <pathelement location="${classpath}"/>
        <fileset dir="." includes="lib/*.jar" />
    </path>

    <target name="get-jars">
        <get src="http://ks1.org/nz/JARS/pellet-1.5RC1-all.jar" dest="lib/pellet-1.5RC1-all.jar" usetimestamp="true"/>
        <get src="http://ks1.org/nz/JARS/axis2-1.2-all.jar" dest="lib/axis2-1.2-all.jar" usetimestamp="true"/>
        <get src="http://ks1.org/nz/JARS/acerola3d-all.jar" dest="lib/acerola3d-all.jar" usetimestamp="true"/>
        <get src="http://ks1.org/nz/JARS/sen-1.2.2.1-all.jar" dest="lib/sen-1.2.2.1-all.jar" usetimestamp="true"/>
    </target>

    <target name="compile">
        <mkdir dir="build"/>
        <javac srcdir="src" destdir="build" encoding="utf-8" debug="on">
            <classpath refid="project.class.path"/>
            <compilerarg value="-Xlint:unchecked" />
        </javac>
        <copy todir="build/jp">
            <fileset dir="src/jp" includes="**/*.a3"/>
        </copy>
    </target>

    <target name="jar" depends="compile">
        <jar destfile="release/JenaCheck.jar" basedir="build"
             manifest="release/manifest"/>
        <jar destfile="release/JenaCheck.jar" basedir="release"
             update="true" includes="META-INF/services.xml" />
    </target>

    <target name="jar-all" depends="jar">
        <mkdir dir="tmp" />
        <unzip src="release/JenaCheck.jar" dest="tmp" />
        <unzip src="lib/pellet-1.5RC1-all.jar" dest="tmp" />
        <unzip src="lib/axis2-1.2-all.jar" dest="tmp" />
        <unzip src="lib/acerola3d-all.jar" dest="tmp" />
        <unzip src="lib/sen-1.2.2.1-all.jar" dest="tmp" />
        <delete file="tmp/META-INF/MANIFEST.MF" />
        <delete file="tmp/META-INF/INDEX.LIST" />
        <delete><fileset dir="tmp/META-INF/" includes="**/*.DSA" /></delete>
        <delete><fileset dir="tmp/META-INF/" includes="**/*.SF" /></delete>
        <move todir="tmp/tmp/"> <!-- Why? -->
            <fileset dir="tmp/EDU/" />
        </move>
        <delete dir="tmp/EDU/" />
        <move todir="tmp/edu/">
            <fileset dir="tmp/tmp/" />
        </move>
        <jar destfile="release/JenaCheck-all.jar" basedir="tmp"
             manifest="release/manifest"/>
        <jar destfile="release/JenaCheck-all.jar" basedir="release"
             update="true" includes="META-INF/services.xml" />
        <delete dir="tmp" />
    </target>

    <target name="clean">
        <delete dir="build" />
        <delete file="release/JenaCheck.jar"/>
        <delete file="release/JenaCheck-all.jar"/>
        <delete>
            <fileset dir="." includes="**/gaha"/>
        </delete>
        <delete>
            <fileset dir="." includes="**/*~" defaultexcludes="no"/>
        </delete>
    </target>

    <target name="exec" depends="compile">
        <java classname="jp.ac.do_johodai.j314.sw.jc.JenaCheck" fork="true">
            <classpath>
                <pathelement location="build"/>
                <pathelement location="lib/axis2-1.2-all.jar"/>
                <pathelement location="lib/pellet-1.5RC1-all.jar"/>
                <pathelement location="lib/acerola3d-all.jar"/>
                <pathelement location="lib/sen-1.2.2.1-all.jar"/>
            </classpath>
        </java>
    </target>

    <target name="exec2" depends="jar-all">
        <java classname="jp.ac.do_johodai.j314.sw.jc.JenaCheck" fork="true">
        <classpath>
            <pathelement location="release/JenaCheck-all.jar"/>
        </classpath>
        </java>
    </target>

    <target name="javadoc" depends="compile">
        <javadoc packagenames="jp.ac.do_johodai.j314.sw.jc,
                               jp.ac.do_johodai.j314.sw.je,
                               jp.ac.do_johodai.j314.sw.ws"
                 sourcepath="src"
                 destdir="docs/javadoc"
                 encoding="utf-8"
                 classpath="lib/pellet-1.5RC1-all.jar,
                            lib/axis2-1.2-all.jar,
                            lib/acerola3d-all.jar"
                 charset="utf-8">
        </javadoc>
    </target>

    <target name="src-package" depends="clean">
        <echo>
*******************************************************
      If you want to spesify version of package:
      ant -Dversion=3.14 src-package
*******************************************************
        </echo>
        <tar tarfile="../JenaCheck-${version}.tar" basedir=".."
             includes="JenaCheck/**"
             excludes="JenaCheck/**/*.jar"/>
        <gzip zipfile="../JenaCheck-${version}.tar.gz" src="../JenaCheck-${version}.tar"/>
        <delete file="../JenaCheck-${version}.tar"/>
    </target>
</project>
