What they don't cover there is what is needed to bundle up that compiled Scala code and put it somewhere that Railo can get at.
Here's the Ant task I use to create and deploy a JAR:
<jar destfile="${www}/WEB-INF/railo/lib/Publisher.jar" basedir="${build.dir}"/>
<copy file="${scala.home}/lib/scala-library.jar" todir="${www}/WEB-INF/railo/lib"/>
</target>
Read on for more details of the build-scala and docs-scala tasks...
The build-scala task compiles the .scala files to .class files (and is very similar to that shown on the Scala website):
<mkdir dir="${build.dir}"/>
<scalac srcdir="${sources.dir}" destdir="${build.dir}" classpathref="build.classpath">
<include name="**/*.scala"/>
</scalac>
</target>
The docs-scala task generates JavaDoc-style API documentation from the source code. It's a good idea to do this automatically every time you build the system so the documentation is always up to date. I don't commit the generated docs to git so that no one accidentally gets hold of an old version.
<mkdir dir="${docs.dir}" />
<scaladoc
srcdir="${sources.dir}"
destdir="${docs.dir}"
deprecation="yes" unchecked="yes" addparams="-access:private"
windowtitle="Publisher Documentation"
doctitle="<div>Publisher</div>"
classpathref="build.classpath">
<include name="**/*.scala" />
</scaladoc>
</target>
And finally the init-scala task sets up the Scala environment for the build / docs tasks:
<property name="scala-library.jar" value="${scala.home}/lib/scala-library.jar"/>
<path id="build.classpath">
<pathelement location="${scala-library.jar}"/>
<pathelement location="${www}/WEB-INF/lib/mysql-connector-java-bin.jar"/>
<pathelement location="${build.dir}"/>
</path>
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<pathelement location="${scala.home}/lib/scala-compiler.jar" />
<pathelement location="${scala-library.jar}" />
</classpath>
</taskdef>
</target>
Note that we're relying on the MySQL JDBC driver (the Publisher reads large numbers of records from the database and converts them to a specific XML representation that is needed by a search engine).
The last part of the Ant build file is the high-level properties that specify where Scala is installed and the source, build and docs directories:
<property name="sources.dir" value="${basedir}/../publisher/src"/>
<property name="build.dir" value="${basedir}/../publisher/build"/>
<property name="docs.dir" value="${basedir}/../publisher/docs"/>
My repo is structured so the build.xml file is in a build folder at the top level, Scala is installed in a scala folder also at the top level (yes, a minimal Scala installation is under git as part of our build process) and the Publisher code is in the publisher folder at the top level (with the source code under a src folder).
There are no comments for this entry.


