Search code examples
jarplayframeworkdependency-managementactivator

How to change play framework dependency version


I want to change one of my library to the latest version. where to find the version of the dependency in play.


Solution

  • In general, you can see a list of Play's direct dependencies by checking the project/Dependencies.scala file in the source code for that version of Play. For version 2.4.3, that file is here: https://github.com/playframework/playframework/blob/2.4.3/framework/project/Dependencies.scala

    In the specific case of Jackson, the group ID and module structure changed between Jackson 1.x and 2.x. Play 2.4.3 is using Jackson 2.5.4. If your project depends on Jackson 1.8.5, this dependency isn't coming from Play, but from some other source.

    You can use the sbt-dependency-graph plugin to view the full tree of transitive dependencies and see where it is introduced.

    To update to a newer version, you can add a direct dependency to your build.sbt with the desired version:

    libraryDependencies += "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.13"
    

    This will override the version requested by other libraries; by default, sbt will use the greatest version requested.

    However, there are a few things to keep in mind:

    1. Jackson is composed of several sub-modules. If you are using several of these in the same project, including transitively, it's a good idea to use the same version of all of them. This might require adding additional dependencies to your project to keep them all in sync.
    2. When upgrading dependencies in your application that are also used by other libraries it depends on, you'll need to consider backward compatibility. Jackson is not always fully backward compatible between minor versions, so if you update to a newer version of Jackson than what your libraries were designed to use, you might encounter problems at runtime.
    3. Using both Jackson 1.x and 2.x in the same project is possible, since they have different group IDs and Java package names, but it may be confusing and error prone. If you can, it would be better to standardise on the Jackson version that is used by the Play Framework version you choose.