How do the variables in the play .sbt file work?

1,202 views
Skip to first unread message

ac...@comprehend.com

unread,
Jan 8, 2014, 7:48:31 PM1/8/14
to play-fr...@googlegroups.com
I've used sbt before, and while I was using play, I noticed something odd about its sbt file.

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache
)

You compare that to the .sbt in any other normal root-level project, and it looks more like this:

libraryDependencies ++= Seq(
  "org.postgresql" % "postgresql" % "9.1.902"
)

So my question is: where do those vars come from? Where are jdbc, anorm and cache defined? I'm curious because I'm trying to have a play submodule in my project, and it buggers out because it can't find those variables.

[info] Loading project definition from /Users/squirrel/Workspace/weyland/project
/Users/squirrel/Workspace/weyland/veblen/build.sbt:6: error: not found: value jdbc
  jdbc,
  ^
/Users/squirrel/Workspace/weyland/veblen/build.sbt:7: error: not found: value anorm
  anorm,
  ^
/Users/squirrel/Workspace/weyland/veblen/build.sbt:8: error: not found: value cache
  cache
  ^
[error] Type error in expression

at org.jetbrains.sbt.project.SbtProjectResolver.resolveProjectInfo(SbtProjectResolver.scala:30)
at org.jetbrains.sbt.project.SbtProjectResolver.resolveProjectInfo(SbtProjectResolver.scala:18)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
... 20 more

ac...@comprehend.com

unread,
Jan 8, 2014, 8:25:46 PM1/8/14
to play-fr...@googlegroups.com
Okay, actually, I think I've figured it out.

Those variables come as part of the play.Project, which you use in place of the usual Project in your build.scala. The details can be gleamed here: http://www.playframework.com/documentation/2.2.x/SBTSubProjects

What you need to do is import play.Project._, and then use play.Project in place of Project. In order to be able to import play.Project, you need to add the play plugin to sbt, by adding these lines to your toplevel project/plugins.sbt

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

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")
Reply all
Reply to author
Forward
0 new messages