Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does sbt report "not found: value PlayScala" with Build.scala while build.sbt works?

I am creating a multi-module sbt project, with following structure:

<root>
----build.sbt
----project
    ----Build.scala
    ----plugins.sbt
----common
----LoggingModule  

LoggingModule is a Play Framework project, while common is a simple Scala project.

In plugins.sbt:

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

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

While I have this in build.sbt, all works fine and it recognises PlayScala:

name := "Multi-Build"

lazy val root = project.in(file(".")).aggregate(common, LoggingModule).dependsOn(common, LoggingModule)

lazy val common = project in file("common")

lazy val LoggingModule = (project in file("LoggingModule")).enablePlugins(PlayScala)  

However as soon I put this in project/Build.scala instead of `build.sbt' as follows:

object RootBuild extends Build {  

  lazy val root = project.in(file("."))
    .aggregate(common, LoggingModule)
    .dependsOn(common, LoggingModule)

  lazy val common = project in file("common")
  lazy val LoggingModule = (project in file("LoggingModule")).enablePlugins(PlayScala)

  ...//other settings
}

it generates error as:

not found: value PlayScala
lazy val LoggingModule = (project in file("LoggingModule")).enablePlugins(PlayScala)
                                                                          ^

How to solve the issue?

like image 787
Vikas Raturi Avatar asked Oct 01 '14 04:10

Vikas Raturi


1 Answers

It's just a missing import.

In .sbt files, some things are automatically imported by default: contents of objects extending Plugin, and (>= 0.13.5) autoImport fields in AutoPlugins. This is the case of PlayScala.

In a Build.scala file, normal Scala import rules apply. So you have to import things a bit more explicitly. In this case, you need to import play.PlayScala (or use .enabledPlugins(play.PlayScala) directly).

like image 72
sjrd Avatar answered Nov 09 '22 13:11

sjrd