Search code examples
scalasbtplay-json

How to declare play json dependency?


My build.sbt file (sbt version is 0.13.8):

lazy val commonSettings = Seq(
  version := "1.0.0",
  scalaVersion := "2.11.6"
)

resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"

lazy val root = (project in file(".")).
  settings(commonSettings: _*).
  settings(
    name := "myapp",
    libraryDependencies ++= Seq(
      "com.typesafe.play" % "play-json" % "2.3.4",
      "org.scalatest" % "scalatest_2.11" % "2.2.4" % "test",
      "junit" % "junit" % "4.12" % "test"
    )
  )

scalacOptions ++= Seq("-unchecked", "-feature", "-deprecation")

I get this error when trying to compile my project:

[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.play#play-json_2.11;2.3.4: not found
[error] Total time: 0 s, completed Apr 17, 2015 5:59:28 PM

How can I get this play-json library for my scala 2.11.6?


Solution

  • You need to tell sbt which scala version should use.

    You can either be explicit:

    "com.typesafe.play" % "play-json_2.11" % "2.3.4",
    

    Or use %% (sbt doc) as follows to tell sbt to use scalaVersion :

    "com.typesafe.play" %% "play-json" % "2.3.4",