But since I always starts my explorations with the solid foundation of maven the first problem I encountered was how to integrate scala in my build process in a project that already mixes GAE and Sculptor. I.e. I start off from a project that has been created with our maven appengine archetype. So this is a log of my steps for making this happen.
1) In your pom, add a property for the version of Scala:
<scala.version>2.7.7</scala.version>
2) In your pom, add repository for scala:
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
3) In your pom , add pluginRepository:
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
4) In your pom, add dependency:
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
5) In your pom, add entry in maven-dependency-plugin in the build section:
<artifactItem>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
<outputDirectory>war/WEB-INF/lib</outputDirectory>
</artifactItem>
6) In your pom, add dependency to specs-library (if you want it):
<dependency>
<groupId>org.specs</groupId>
<artifactId>specs</artifactId>
<version>1.4.3</version>
<scope>test</scope>
</dependency>
7) In your pom, add the scala-plugin to the build section:
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-target:jvm-1.5</arg>
</args>
</configuration>
</plugin>
8) In your project file structure, add a simple scala file: src/main/scala/org/foo/App.scala
package org.foo
/**
* Hello world!
*
*/
object App extends Application {
println( "Hello World!" )
}
9) In your project file structure, add a simple scala test: src/test/scala/org/foo/AppTest.scala
10) In the root of your project file structure, run mvn install to see that everything builds ok
package org.foo
import org.junit._
import Assert._
@Test
class AppTest {
@Test
def testOK() = assertTrue(true)
}
No comments:
Post a Comment