Child pages
  • Configuring Ant to Build Scala with WebObjects
Skip to end of metadata
Go to start of metadata

Step1. Setup Properties for Scalac Task

You may edit (or add to) the init.properties Ant target in order to set up the appropriate properties for the scalac Ant task.

<property name="scala-library.jar" value="${scala.home}/lib/scala-library.jar" />

<path id="build.classpath">
        <pathelement location="${scala-library.jar}" />
        <pathelement location="${wo.local.frameworks}/ERExtensions.framework/Resources/Java/ERExtensions.jar" />
	<pathelement location="${wo.local.frameworks}/ERJars.framework/Resources/Java/log4j-1.2.14.jar" />
	<pathelement location="${wo.system.frameworks}/JavaWebObjects.framework/Resources/Java/javawebobjects.jar" />
        <pathelement location="${wo.system.frameworks}/JavaEOAccess.framework/Resources/Java/javaeoaccess.jar" />
	<pathelement location="${wo.system.frameworks}/JavaEOControl.framework/Resources/Java/javaeocontrol.jar" />
	<pathelement location="${wo.system.frameworks}/JavaFoundation.framework/Resources/Java/javafoundation.jar" />	
	<pathelement location="${wo.local.frameworks}/ERAttachment.framework/Resources/Java/ERAttachment.jar" />
	<!--pathelement location="Other custom framework path, etc" /-->

        <pathelement location="bin" />
	<fileset dir="Libraries">
		<include name="*.jar" />
	</fileset>
	<fileset dir="${wo.extensions}">
		<include name="*.jar" />
	</fileset>
</path>

<taskdef resource="scala/tools/ant/antlib.xml">
	 <classpath>
		<pathelement location="${scala.home}/lib/scala-compiler.jar" />
		<pathelement location="${scala-library.jar}" />
	</classpath>
</taskdef>
Notes:
  1. The first block of pathelements define the classpaths required by the scala compiler.
  2. The taskdef sets up the Ant scalac task

Step2. Edit the compile Target

Add the scalac task to the compile target. Make sure that it's placed after the mkdir task:

<scalac srcdir="Sources" destdir="bin" classpathref="build.classpath">
    <include name="**/*.scala" />
</scalac>

Step3. Add an <otherclasspath> entry for scala-library.jar

In the build.woapp target, add the following entry to add Scala to the built classpath for your WebObjects app.

<otherclasspath root="${scala.home}">
	<include name="lib/scala-library.jar" />
</otherclasspath>

Step4. Add scala.home to build.properties

Finally, you must set the scala.home property in the build.properties file.
This is the location of the Scala installation on your system. e.g: /usr/share/scala