Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Next, we’ll build the Scala module. This can easily be done by using the scalac compiler and packaging the code into a bundle, just like we did when building the Java version of the calculator. First, we must ensure that the Scala library is on our build classpath. Then, we’ll define an Ant task for the compilation step. Listing 15.6 illustrates the snippets of the build file that perform these tasks for us. Once the code is compiled, it can be packaged into a bundle using the same mechanisms as the Java code.
Listing 15.6. Scala Calculator Build Script
<path id="scala.class.path">
<pathelement path="${scala.library.jar}"/>
<pathelement path="${scala.compiler.jar}"/>
</path>
<taskdef resource="scala/tools/ant/antlib.xml"
classpathref="scala.class.path"/>
<target name="compile" depends="init">
<scalac srcdir="${scala.src}" destdir="${scala.build}">
<classpath refid="project.class.path"/>
</scalac>
</target>