
266
CHAPTER 9
■ SCALING YOUR TEAM
stack.push(1)
stack.push(2)
stack.pop() should equal (2)
stack.pop() should equal (1)
}
ScalaTest and Specs both offer integration with Ant and Maven, so you can integrate
your tests into your existing Java build environment. With both tools, you can describe
tests for your business logic in simple, readable, powerful ways and run those tests using
your existing build and test infrastructure. In this way, Scala integrates very well into your
organization.
Build Tools
Scala works with most popular Java-related build tools including Maven, Ant, and Buildr.
This means that integrating Scala into an existing Java-oriented workflow is simple and
painless. In this section, I’m going to do a quick survey of the tools available for building,
testing, and packaging Scala apps, and that includes apps that contain Scala, Java, JRuby,
and so on. Basically, these tools convert source code to bytecode and stuff that bytecode
into JAR and WAR files. The order I’ve chosen is most verbose to least verbose.
Maven
My personal favorite build and dependency-management tool of all time is Maven (I
duck as people throw things at me.
6
) Maven is far more than a build tool: it’s a complete
dependency-management system and will even ensure that you don’t mix items in a
project where there are license conflicts (e.g., GPL 2 and Apache 2.0).
Maven arranges things as dependencies and goals. Maven will figure out what depen-
dencies are necessary to resolve in order to achieve a goal. Maven may need to download
a JAR file in order to resolve a dependency. Maven will go to different repositories, including
well-known repositories of open source code, in order to download dependencies. Maven
also determines what code to run in order to resolve a dependency in order to reach a goal.
For example, if the goal is
jetty:run (run the web application inside a Jetty container), Maven
will download the JARs that your code depends on, compile your source code, package
your code into a WAR directory layout, download the Jetty runtime, and then invoke Jetty.
With Maven, you only worry about your own code and defining its dependencies, and
Maven takes care of the rest.
6. Paul Snively: As well you should! :-)
19897ch09.fm Page 266 Thursday, April 23, 2009 4:33 PM