I am trying to use scala -akka from sbt.
My sbt file looks as follows:
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:
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 comments bellow. 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 ?
You didn't have all right dependencies for your project.
You have add this one "com.typesafe.akka" %% "akka-actor" % "2.0.5"
. This one is the main dependency with the core modules for akka. Also it's better to add the following ones for your 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 should import akka.actor._
Updated
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"
)
Don't forget to reload
and update
your project in sbt
Your akka-actor dependency absolutely CAN NOT be a different version than your other dependencies. And any dependencies you add absolutely CAN NOT be reliant on different versions of akka either or you'll have a very messed up dependency tree.
And you may as well use current versions if you're starting out. Coltrane 2.2-M3 is current at time of writing.
You can add some more akka libs as needed... But this is a basic 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"
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With