3

I need to add dependency on akka-testkit to my Play! application. I would like to avoid hardcoding the version of Akka and stick to the one used by Play instead (to ensure compatibility).

"com.typesafe.akka" %% "akka-testkit" % akkaVersion % Test 

Is it possible to obtain the version in my build.sbt? The only place where I see it listed is in Play's project/Dependencies.scala.

Artur Nowak
  • 5,254
  • 3
  • 22
  • 32
  • You can simplify make the build save the dependency version in some resource file (or generated source) included at runtime. – cchantep Jan 30 '16 at 19:14

2 Answers2

1

You can do 'show full-classpath' on sbt command line to see what akka its picking up.

Or even better you can use sbt dependency graph to get a more detailed view

Ajay Padala
  • 2,371
  • 16
  • 13
  • The problem is not how to determine the version manually, but how to do it automatically during the build. So, e.g. it would be updated to the proper version when upgrading Play! – Artur Nowak Jan 31 '16 at 20:29
0

I recently faced the same issue and solved it by defining akka-toolkit dependency as following (build.sbt):

"com.typesafe.akka" %% "akka-testkit" % play.core.PlayVersion.akkaVersion % "test"

I also have Play added via sbt plugin (project/plugins.sbt):

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.20")

For readability, you can extract play.core.PlayVersion.akkaVersion to a variable and/or use imports to not be forced to type the full path