ivy.xml contains information about the dependencies needed to build the project. To compile scala source, I'll need to add two dependencies - scala-library and scala-compiler.
<info organisation="com.maethorechannen" module="snow-core"/>
<dependency org="org.scala-lang" name="scala-library" rev="2.7.7"/>
<dependency org="org.scala-lang" name="scala-compiler" rev="2.7.7"/>
<!-- other dependecies -->
If you've used Maven then this will look vaguely familiar yet more compact - groupId becomes org, artifactId becomes name and version becomes rev. As by default Ivy uses Maven's repositories, you can use the same values as you would in Maven.
My build.xml will need to do 3 things:
- download ivy
- setup scala
Strictly speaking, the first item is not technically required if I manually install Ivy into Ant. For the moment, it seems easier if I just set it up so that Ivy gets automagically installed if need be. Fortunatly, the ivy-go example build.xml file shows us how to do this.
The Scala side of things is also fairly straightforward. The scala-lang.org page on Scala Ant Tasks gave me a fairly good idea of what needed to be done, however I had to make a few changes:
- make the init target depend on the install-ivy target
- modify init so that it executes ivy:retrieve (which downloads the dependencies) and modify the way init generates the build classpath so that it includes jars from the lib directory
- modify the taskdef that imports the scala tasks (also in the init target) so that it finds scala-compiler and scala-library in the lib directory and not in scala.home
- modify the build target, so that it compiles all scala source files in the src/main/scala directory and subdirectories
As the build.xml file is a bit big for a blog post, you can find it here