Setting up Scala within a Java Maven project
In order to be able to start writing a Scala unit test and compile Scala code into our Java project, we need to add a few dependencies and the scala-maven-plugin to the pom.xml
file. The dependencies are as follows:
Dependency for the core scala-library:
<dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>2.10.0</version> </dependency>
Dependency for scalatest (a framework for testing in Scala that supports JUnit and other styles; we will cover it in detail in Chapter 4, Testing Tools):
<dependency> <groupId>org.scalatest</groupId> <artifactId>scalatest_2.10</artifactId> <version>2.0/version> <scope>test</scope> </dependency>
Dependency for JUnit to use Java
Assert
statements in our test case:<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId...