This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Installing Scala Ant Tasks

1 reply
Bastian, Mark
Joined: 2009-01-16,
User offline. Last seen 42 years 45 weeks ago.
tolsen77
Joined: 2008-10-08,
User offline. Last seen 1 year 38 weeks ago.
Re: Installing Scala Ant Tasks
Here's an example of a full ANT build script (I edited out my stuff so might need some adjustments):

<?xml version="1.0" encoding="UTF-8"?>

<project name="Example script" default="build" basedir=".">
<description> Build script </description>

<!-- Main targets -->
<target name="build" depends="package">
</target>


<!-- Compiler settings -->
<property name="jvm-target" value="jvm-1.5"/>

<!-- Paths -->
<property name="scala.lib.dir" location="${SCALA_HOME}/lib"/>
<property name="src.dir" location="${basedir}/src" />
<property name="lib.dir" location="${basedir}/lib"/>
<property name="build.dir" location="${basedir}/build"/>
<property name="cls.build.dir" location="${build.dir}/classes"/>
<property name="lib.build.dir" location="${build.dir}/lib"/>
<property name="java.home" location="${JAVA_HOME}"/>

<path id="project.classpath">
    <pathelement location="${scala.lib.dir}/scala-library.jar"/>
</path>

<!-- Scala compiler task -->
<taskdef resource="scala/tools/ant/antlib.xml">
    <classpath>
        <pathelement location="${scala.lib.dir}/scala-compiler.jar"/>
        <pathelement location="${scala.lib.dir}/scala-library.jar"/>
    </classpath>
</taskdef>

<!-- Targets -->
<target name="clean">
    <delete dir="${build.dir}"/>
</target>

<target name="compile" depends="clean">
    <mkdir dir="${cls.build.dir}"/>
    <scalac srcdir="${src.dir}" destdir="${cls.build.dir}" target="${jvm-target}" classpathref="project.classpath" force="yes" deprecation="yes">
        <include name="**/*.scala"/>
    </scalac>
</target>

<target name="package" depends="compile">
    <mkdir dir="${lib.build.dir}"/>
    <jar destfile="${lib.build.dir}/example.jar">
        <fileset dir="${cls.build.dir}"/>
    </jar>
</target>

</project>

On Fri, Jan 16, 2009 at 4:27 PM, Bastian, Mark <mbastia [at] sandia [dot] gov> wrote:
Hi Folks,   I am trying to figure out how to install the scala ant tasks. Several examples show a scalac task, but I don't see any documentation on what jars are required on the Ant path for this. Is placing scala-library.jar and scala-compiler.jar in ANT_HOME\lib sufficient? Also, can anyone tell me the correct xml namespace declaration to put in the build.xml project settings (e.g. for ivy, I'd out something like xmlns:ivy="antlib:fr.jayasoft.ivy.ant")?   Thanks, Mark  

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland