47

How can I add the Play JSON library (play.api.libs.json) to my sbt project?

When I added the following to my plugins.sbt file:

addSbtPlugin("play" % "sbt-plugin" % "2.1.0")

I faced this error:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: play#sbt-plugin;2.1.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

I did not find a resolver for this library, otherwise I would've added it and ran sbt update. Note that my resolvers includes http://repo.typesafe.com/typesafe/releases/.

Jacek Laskowski
  • 64,943
  • 20
  • 207
  • 364
Kevin Meredith
  • 38,251
  • 58
  • 190
  • 340

5 Answers5

78

Play 2.2 is out and can be added separately from rest of Play Framework. in build.sbt:

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

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.2.1"
Karolis
  • 1,498
  • 1
  • 14
  • 21
39

Play 2.3 JSON with SBT >= 0.13.5

put into build.sbt:

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.4"

Play 2.1

build.sbt:

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

scalaVersion := "2.10.2"

libraryDependencies += "play" % "play_2.10" % "2.1.0"

Play JSON is in Play 2.1 not an independent artifact.

Schleichardt
  • 7,385
  • 1
  • 22
  • 36
  • At the time of writing this was true, not it is an independent lib. – Schleichardt Apr 15 '14 at 21:26
  • 1
    Doesn't work for me. Using sbt 13.11. It cannot find com.typesafe.play#play-json_2.10;2.3.4. Probably due to me scala version being 2.10.5. I had to add the typesafe repo – BradLaney Feb 29 '16 at 19:02
  • on Maven Central is this version: http://search.maven.org/#artifactdetails%7Ccom.typesafe.play%7Cplay-json_2.10%7C2.3.10%7Cjar – Schleichardt Feb 29 '16 at 21:54
  • 1
    had to add the `resolvers += ...` line even for Play 2.3 and SBT > 0.13.5, and reload. Then worked. – yair Mar 03 '16 at 15:48
13

This worked for me (scala 2.11)

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

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.3.0"

Raul
  • 1,759
  • 1
  • 16
  • 30
1

You can use the following to get the Play JSON library:

addSbtPlugin("play" % "play-json" % "2.2-SNAPSHOT")

You may also have to include the following resolver:

"Mandubian repository snapshots" at "https://github.com/mandubian/mandubian-mvn/raw/master/snapshots/"

Here's where I originally got the info: http://mandubian.com/2013/02/21/play-json-stand-alone/

Andrew Jones
  • 1,338
  • 9
  • 25
  • Hmm I got a missing dependency error from adding the 1 liner. Any way to avoid the git link? – Kevin Meredith Oct 17 '13 at 21:38
  • 3
    Now available truly standalone as "com.typesafe.play" %% "play-json" % "2.2.0". See comment by Mandubian in that blog post link "since play 2.2, you don't need my repo anymore" – reggoodwin Nov 09 '13 at 10:08
1

One could check the Getting Started section of the GitHub repository and add the following to the build.sbt file:

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.0-M1"
030
  • 8,013
  • 8
  • 63
  • 100