1

Say I want to include a dependency on the play-json library in my sbt file. How and where can I find that information?

I tried searching central repo, play git repository -- couldn't find anything.

Jacek Laskowski
  • 64,943
  • 20
  • 207
  • 364
Andriy Drozdyuk
  • 50,346
  • 44
  • 149
  • 256
  • How do you know the library exists at all? I'm asking as the source should give you further clues on how to use it and where to find the latest version. – Jacek Laskowski Mar 28 '14 at 17:41
  • That's exactly my point. I can't find it on maven central: http://search.maven.org/#search%7Cga%7C1%7Cplay-json But I did see it mentioned in the answer to this question: http://stackoverflow.com/questions/19436069/adding-play-json-library-to-sbt – Andriy Drozdyuk Mar 28 '14 at 20:19
  • I updated my answer. The dependency is in http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-json_2.10/. – Jacek Laskowski Mar 29 '14 at 15:24

1 Answers1

2

First of all, when you want to include a dependency, you've somehow been told about it - about the required version and where to find it. Ask the person this question and you're done. The official source should always be the home page of a dependency.

I'd use http://search.maven.org/ or http://mvnrepository.com/ and pick whatever version is the most current. In your case, however, esp. after the comment where you pointed at Adding Play JSON Library to sbt the answer was right there - in the answers - see https://stackoverflow.com/a/20475410/1305344:

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"

The trick is to set up resolvers properly and using the above resolver gives http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-json_2.10.

When you've got resolvers and any version in your build configuration, you may want to use sbt-updates that's (quoting the plugin's headline) "SBT plugin that can check maven repositories for dependency updates". Quite handy to have it installed as a global plugin, i.e. .sbt/0.13/plugins/sbt-updates.sbt with the following:

resolvers += Classpaths.sbtPluginSnapshots

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.6-SNAPSHOT")

When you execute dependencyUpdates you're told what needs version update.

> dependencyUpdates
[info] Found 1 dependency update for superapp
[info]   org.jacoco:org.jacoco.agent:jacoco : 0.6.4.201312101107 -> 0.6.5.201403032054 -> 0.7.0.201403182114
[success] Total time: 1 s, completed 2014-03-28 18:30:12

As you can see, I need to upgrade jacoco.

If the project you depend on releases to some known repositories, running sbt-updates regularly will ultimately tell you about the update. I'd strongly recommend reading RELEASE_NOTES for an update before upgrading since it may be introducing some breaking changes you'd rather know about before going to production.

Community
  • 1
  • 1
Jacek Laskowski
  • 64,943
  • 20
  • 207
  • 364
  • Right, but finding the latest version of a lib through SO answer is questionable... what happens when the newer version comes out? Looking on mvnrepository I am not able to find it. The other answer points to a random blog post... There should be an easy way to get this info from some official source? – Andriy Drozdyuk Apr 09 '14 at 22:29
  • You're right, @drozzy. The official source is the home page of a project you need to depend on. If the dependency releases to some known repositories, running sbt-updates regularly will ultimately tell you about the update. – Jacek Laskowski Apr 10 '14 at 09:56
  • I've updated the answer to include the comment above. – Jacek Laskowski Apr 10 '14 at 10:00