I have an build.sbt file that looks like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
name := "TobiasPlayground" version := "1.0" scalaVersion := "2.11.7" scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8") libraryDependencies ++= { val akkaV = "2.3.9" val sprayV = "1.3.3" Seq( "io.spray" %% "spray-client" % sprayV, "io.spray" %% "spray-can" % sprayV, "io.spray" %% "spray-routing" % sprayV, "io.spray" %% "spray-testkit" % sprayV % "test", "com.typesafe.akka" %% "akka-actor" % akkaV, "com.typesafe.akka" %% "akka-testkit" % akkaV % "test", "org.specs2" %% "specs2-core" % "2.3.11" % "test", "org.slf4j" %% "slf4j-api" % "1.7.10" ) } |
But for some reason I can’t get slf4j downloaded from the Maven repository (http://mvnrepository.com)
If I search the Maven Repository, I can clearly see that the version I intend to use is there.
Running “sbt compile” from the command line will result in the following output, and here it is time to pay attention to the details, look at what it is trying to do !!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
Tobiass-MBP:TobiasPlayground tobias$ sbt compile [info] Loading project definition from /Users/tobias/qvantel/TobiasPlayground/project Waiting for lock on /Users/tobias/.ivy2/.sbt.ivy.lock to be available... [info] Set current project to TobiasPlayground (in build file:/Users/tobias/qvantel/TobiasPlayground/) [info] Updating {file:/Users/tobias/qvantel/TobiasPlayground/}tobiasplayground... Waiting for lock on /Users/tobias/.ivy2/.sbt.ivy.lock to be available... [info] Resolving org.slf4j#slf4j-api_2.11;1.7.10 ... [warn] module not found: org.slf4j#slf4j-api_2.11;1.7.10 [warn] ==== local: tried [warn] /Users/tobias/.ivy2/local/org.slf4j/slf4j-api_2.11/1.7.10/ivys/ivy.xml [warn] ==== jcenter: tried [warn] https://jcenter.bintray.com/org/slf4j/slf4j-api_2.11/1.7.10/slf4j-api_2.11-1.7.10.pom [warn] ==== public: tried [warn] https://repo1.maven.org/maven2/org/slf4j/slf4j-api_2.11/1.7.10/slf4j-api_2.11-1.7.10.pom [info] Resolving jline#jline;2.12.1 ... [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: org.slf4j#slf4j-api_2.11;1.7.10: not found [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] [warn] Note: Unresolved dependencies path: [warn] org.slf4j:slf4j-api_2.11:1.7.10 (/Users/tobias/qvantel/TobiasPlayground/build.sbt#L9-27) [warn] +- default:tobiasplayground_2.11:1.0 |
As you can see above the package (jar) it tries to download is not slf4j-api it is slf4j-api_2.11;1.7.10
The build.sbt file uses the double and single % (percent) character and this is what makes the difference. Â The %% makes SBT append the project specified scala version to the package name, resulting in a name “slf4j-api_2.11”.
BUT that name does not exist in the Maven Repository, however, the “slf4j-api” does
So by simply choosing one instead of two %, the problem will go away 🙂
Thus, the built.sbt should look like this instead
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
name := "TobiasPlayground" version := "1.0" scalaVersion := "2.11.7" scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8") libraryDependencies ++= { val akkaV = "2.3.9" val sprayV = "1.3.3" Seq( "io.spray" %% "spray-client" % sprayV, "io.spray" %% "spray-can" % sprayV, "io.spray" %% "spray-routing" % sprayV, "io.spray" %% "spray-testkit" % sprayV % "test", "com.typesafe.akka" %% "akka-actor" % akkaV, "com.typesafe.akka" %% "akka-testkit" % akkaV % "test", "org.specs2" %% "specs2-core" % "2.3.11" % "test", "org.slf4j" % "slf4j-api" % "1.7.10" ) } |
For reference go to https://www.playframework.com/documentation/2.1.1/SBTDependencies to read more about how SBT handles decencies and the % and %%.
I read this article to finally get this right http://stackoverflow.com/questions/17461453/build-scala-and-symbols-meaning