Chaitanya
Chaitanya

Reputation: 3638

Error while compiling scala play application

I have a scala play application which I am trying to compile using the sbt shell

My build.sbt file is as follows

name := """template-service"""

version := "2.6.x"

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

scalaVersion := "2.12.4"

crossScalaVersions := Seq("2.11.12", "2.12.4")

libraryDependencies += guice
libraryDependencies += "com.typesafe.play" %% "play-slick" % "3.0.3"
libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "3.0.3"

libraryDependencies += "com.h2database" % "h2" % "1.4.196"

libraryDependencies += specs2 % Test

resolvers += Resolver.url("bintray-sbt-plugins", url("https://dl.bintray.com/sbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)

addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")

However, while compiling I keep on getting the error

Projects/template-service/build.sbt:5: error: not found: value PlayScala
lazy val root = (project in file(".")).enablePlugins(PlayScala)
                                                     ^
[error] sbt.compiler.EvalException: Type error in expression
[error] sbt.compiler.EvalException: Type error in expression
[error] Use 'last' for the full log.

I tried restarting the sbt shell and repeated the above procedure and got the error consistently. Could anyone please let me know what I am missing in the build.sbt file? Is it some kind of a configuration setting that needs to be added ?

Any pointers will be highly helpful. Thanks in advance !!!

Upvotes: 1

Views: 1069

Answers (1)

dvir
dvir

Reputation: 2566

You should bring the play plugin in project/plugins.sbt: In your project directory, inside the project dir, create a file called plugins.sbt and add to it this content:

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

which adds the play sbt plugin (specifically play 2.7.0 - use another version if you need).

Then type reload in your sbt shell to restart the shell.

Upvotes: 3

Related Questions