Newer
Older
zweic / build.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id$ -->

<project name="zweic" default="build" basedir=".">

    <property environment="env"/>
    <property name="scala.home" value="${env.SCALA_HOME}"/>
    <property file="./build.properties"/>

    <condition property="os.win"><os family="windows"/></condition>

    <target name="init.win" if="os.win">
        <property name="scala.home.win" value="${scala.home}"/>
        <property name="scala.prefix" value="${scala.home.win}"/>
    </target>

    <target name="init.unix" unless="os.win">
        <property name="scala.home.unix" value="${scala.home}"/>
        <property name="scala.prefix" value="${scala.home.unix}/share/scala"/>
    </target>

    <target name="init" depends="init.win, init.unix">
        <echo level="verbose">scala.prefix=${scala.prefix}</echo>
        <path id="scala.cpath">
            <pathelement location="${scala.prefix}/lib/fjbg.jar"/>
            <pathelement location="${scala.prefix}/lib/msil.jar"/>
            <pathelement location="${scala.prefix}/lib/scala.jar"/>
        </path>
        <path id="scalac.cpath">
            <path refid="scala.cpath"/>
            <pathelement location="${scala.prefix}/src"/>
            <pathelement location="${scala.prefix}/lib/tools.jar"/>
        </path>
        <fail message="Directory ${scala.prefix} does not contain a valid Scala distribution">
            <condition><not>
                <available classname="scala.tools.scalac.ant.Scalac"
                           classpathref="scalac.cpath"/>
            </not></condition>
        </fail>
        <taskdef name="scalac"
                 classname="scala.tools.scalac.ant.Scalac"
                 classpathref="scalac.cpath"/>
    </target>

    <target name="build" depends="init">
        <mkdir dir="${output.dir}"/>
        <javac srcdir="${sources.dir}" destdir="${output.dir}">
            <classpath>
               <pathelement location="${output.dir}"/>
            </classpath>
            <include name="**/*.java"/>
        </javac>
        <scalac srcdir="${sources.dir}" destdir="${output.dir}"
                excludes="${exclude.files}">
            <classpath>
                <pathelement location="${output.dir}"/>
            </classpath>
            <include name="**/*.scala"/>
            <exclude name="**/*-partial.scala"/>
        </scalac>
    </target>

    <target name="init.zweic" depends="init">
        <macrodef name="zweic">
            <attribute name="classname"/>
            <attribute name="srcdir"/>
            <attribute name="file"/>
            <sequential>
                <echo/>
                <echo>Running zweic on file @{file}</echo>
                <java classname="@{classname}" fork="true">
                    <classpath>
                        <path refid="scala.cpath"/>
                        <pathelement location="${output.dir}"/>
                    </classpath>
                    <arg line="@{srcdir}/@{file}"/>
                </java>
            </sequential>
        </macrodef>
    </target>

    <target name="run" depends="build, init.zweic">
        <zweic classname="${compiler.main}" srcdir="${examples.dir}" file="${test.file}"/>
    </target>

    <target name="init.submit">
        <echo level="verbose">group=${group}</echo>
        <condition property="isset.group">
    	    <length string="${group.number}" length="2"/>
        </condition>
        <fail unless="isset.group">Erreur: votre numero de groupe manque ou est incorrect; veuillez le definir dans votre fichier build.properties</fail>
    </target>

    <target name="submit" depends="init.submit">
	<zip destfile="${group}.zip">
	    <zipfileset dir="${sources.dir}" prefix="${group}/sources"
	                includes="**/*.scala"/>
	    <zipfileset dir="." prefix="${group}"
	                includes="Makefile,build.*"/>
	</zip>
        <mail mailhost="${mailhost}" mailport="${mailport}"
              subject="[COMPILATION] ${group}">
            <from address="${from.address}"/>
            <to address="${to.address}"/>
            <message>You'll find attached the solution of group ${group}.
            </message>
            <fileset dir=".">
                <include name="${group}.zip"/>
            </fileset>
        </mail>
        <delete file="${group}.zip"/>
    </target>

    <target name="clean">
        <delete quiet="true">
            <fileset dir="${output.dir}" includes="**/*.class"/>
            <fileset dir="." includes=".latest-*"/>
        </delete>
    </target>

    <target name="distclean" depends="clean">
        <delete>
            <fileset dir="." includes="**/*~"/>
            <fileset dir="." includes="**/core*"/>
        </delete>
    </target>

</project>