What do you need to build sbt with Akka?

I am trying to use scala -akka from sbt.

My sbt file looks like this:

name := "hello" version := "1.0" scalaVersion := "2.9.1" resolvers += "akka" at "http://repo.akka.io/snapshots" libraryDependencies ++= Seq( "com.codahale" % "simplespec_2.9.0-1" % "0.4.1", "com.typesafe.akka" % "akka-stm" % "2.0-SNAPSHOT" ) 

my code is:

 import akka._ object HelloWorld { def main(args: Array[String]) { println("Hello, world!") } } 

When I do sbt compile , I get

 ]# **sbt compile** [info] Set current project to default-91c48b (in build file:/var/storage1/home/test_user/dev_scala/hello/) [info] Compiling 1 Scala source to /var/storage1/home/test_user/dev_scala/hello/target/scala-2.9.2/classes... [error] /var/storage1/home/test_user/dev_scala/hello/src/main/scala/hw.scala:3: not found: object akka [error] import akka._ [error] ^ [error] one error found [error] (compile:compile) Compilation failed [error] Total time: 3 s, completed May 22, 2013 8:59:08 PM 

Please advice.

EDIT2: based on the comments below. here is the new sbt file

 name := "hello" version := "1.0" scalaVersion := "2.9.1" resolvers += "akka" at "http://repo.akka.io/snapshots" libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.1.4", "com.codahale" % "simplespec_2.9.0-1" % "0.4.1", "com.typesafe.akka" % "akka-stm" % "2.0-SNAPSHOT" , "com.typesafe.akka" %% "akka-actor" % "2.2-M3", "com.typesafe.akka" %% "akka-slf4j" % "2.2-M3", "com.typesafe.akka" %% "akka-remote" % "2.2-M3", "com.typesafe.akka" %% "akka-testkit" % "2.2-M3"% "test" ) 

any ideas?

+8
scala akka sbt
source share
2 answers

You did not have any suitable dependencies for your project.

You added this "com.typesafe.akka" %% "akka-actor" % "2.0.5" . This is the main dependency on the core modules for akka. It is also better to add the following for the akka project:

 "com.typesafe.akka" %% "akka-actor" % "2.0.5", "com.typesafe.akka" %% "akka-slf4j" % "2.0.5", "com.typesafe.akka" %% "akka-remote" % "2.0.5", "com.typesafe.akka" %% "akka-agent" % "2.0.5", "com.typesafe.akka" %% "akka-testkit" % "2.0.5"% "test" 

And to use actors you have to import akka.actor._

Update

Ok this build file works for me

 name := "hello" version := "1.0" scalaVersion := "2.10.1" libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.2-M3", "com.typesafe.akka" %% "akka-slf4j" % "2.2-M3", "com.typesafe.akka" %% "akka-remote" % "2.2-M3", "com.typesafe.akka" %% "akka-agent" % "2.2-M3", "com.typesafe.akka" %% "akka-testkit" % "2.2-M3" % "test" ) 

Do not forget to reload and update your project in sbt

+11
source share

Your addiction to akka-actor CANNOT be a different version than your other addictions. And any dependencies that you add absolutely CANNOT rely on different versions of akka, or you will have a very confusing dependency tree.

And you can use current versions if you start. Coltrane 2.2-M3 is current during recording.

You can add some more akka libs as needed ... But this is the main starting point based on a real project that we run in prod:

 name := "app" organization := "com.yourorg" version := "0.0.1-SNAPSHOT" scalaVersion := "2.10.1" scalacOptions ++= Seq("-unchecked", "-deprecation") resolvers ++= Seq( "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" ) libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.2-M3", "com.typesafe.akka" %% "akka-slf4j" % "2.2-M3", "com.typesafe.akka" %% "akka-testkit" % "2.2-M3" ) 
+1
source share

All Articles