1
votes

Using sbt 13.8, the newest scala plugin for IntelliJ, and a new SBT project with Scala 2.11.7, I try to add a single library - akka 2.4.2. following this, i simply add

libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.4.2"

But I am getting an unresolved dependency error:

Error:Error while importing SBT project:

[info] Resolving org.scala-sbt#tasks;0.13.8 ...

[info] Resolving org.scala-sbt#tracking;0.13.8 ...

[info] Resolving org.scala-sbt#cache;0.13.8 ...

[info] Resolving org.scala-sbt#testing;0.13.8 ...

[info] Resolving org.scala-sbt#test-agent;0.13.8 ...

[info] Resolving org.scala-sbt#test-interface;1.0 ...

[info] Resolving org.scala-sbt#main-settings;0.13.8 ...

[info] Resolving org.scala-sbt#apply-macro;0.13.8 ...

[info] Resolving org.scala-sbt#command;0.13.8 ...

[info] Resolving org.scala-sbt#logic;0.13.8 ...

[info] Resolving org.scala-sbt#precompiled-2_8_2;0.13.8 ...

[info] Resolving org.scala-sbt#precompiled-2_9_2;0.13.8 ...

[info] Resolving org.scala-sbt#precompiled-2_9_3;0.13.8 ...

[trace] Stack trace suppressed: run 'last common/*:update' for the full output.

[trace] Stack trace suppressed: run 'last common/*:ssExtractDependencies' for the full output.

[trace] Stack trace suppressed: run 'last app1/*:ssExtractDependencies' for the full output.

[error] (common/*:update) sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka actor_2.10;2.4.2: not found

[error] (common/*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-actor_2.10;2.4.2: not found

[error] (app1/*:ssExtractDependencies) sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-actor_2.10;2.4.2: not found

why is sbt trying to find akka-actor_2.10 if I set project to 2.11.7?

UPDATE:

explicitly stating version,

libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.4.2"

works but then you get an SBT project import warning:

[warn] Scala version was updated by one of library dependencies:

[warn] Binary version (2.11) for dependency org.scala-lang#scala-library;2.11.7 [warn] in com.myorg#common$sources_2.10;1.0 differs from Scala binary version in project (2.10).

[warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version: [warn] * org.scala-lang:scala-library:(2.11.7, 2.10.4)...

EDIT:

build.sbt

import Dependencies._


name := "coolApps"

version := "1.0"

scalaVersion := "2.11.7"

lazy val common = (project in file("common")).
settings(Commons.settings: _*).
settings(
libraryDependencies ++= commonDependencies
 // dependencyOverrides += "org.scala-lang" % "scala-library" % scalaVersion.value
)

lazy val app1 = (project in file("app1")).
 settings(Commons.settings: _*).
 settings(
libraryDependencies ++= app1Dependencies
 ).
dependsOn(common)

Dependencies.scala

object Dependencies {


val akka = "com.typesafe.akka" %% "akka-actor" % "2.4.2"


val commonDependencies: Seq[ModuleID] = Seq(
 akka
 )

val app1Dependencies: Seq[ModuleID] = Seq()
}

Commons.scala

import sbt._
import Keys._


object Commons {
  val coolAppVersion = "1.0"

  val settings: Seq[Def.Setting[_]] = Seq(
   organization := "com.company",
   version := coolAppVersion,
   scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8"),
   resolvers ++= Seq(
    "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/"
  )
 )
}
1
What's your build.sbt?maciekjanusz
ill make an edit and add build.sbtAzeli

1 Answers

3
votes

In your build.sbt, you need to set the key

scalaVersion := "2.11.7"

If you don't set this, it'll use the scala used by SBT itself which is a 2.10.x version.