3

(Disclaimer: I'm a complete Play/SBT newbie.) I've been trying to create a new project across two sub-modules using play for a web front-end (the "app" module) and plain scala for the core module ("core"). However, I've been running into problems where trying to run sbt:

[info] Loading project definition from /home/rm/PlayApp/project Play ebean module has been replaced with an external Play ebean plugin. See https://playframework.com/documentation/2.4.x/Migration24 for details.

I've looked at the migration guide, and it doesn't seem to help much. It doesn't seem to me that ebeans is required to use Play!, but sbt doesn't seem to want to run without it. Furthermore, even when I add ebeans as a sbt plugin, it still has problems.

project/Build.scala

import org.scalajs.sbtplugin.ScalaJSPlugin
import play.sbt.PlayScala
import sbt.{Build => SbtBuild, _}
import Keys._


object BuildSettings {
  val buildSettings = Defaults.coreDefaultSettings ++ Seq(
    scalaVersion := "2.11.7",
    version := "1.0.0",
    resolvers += Resolver.sonatypeRepo("releases"),
    resolvers += Resolver.url("scalajs-repo", new java.net.URL("http://mvnrepository.com/artifact/org.scala-js")),
    scalacOptions ++= Seq()
  )
}

object Dependencies {
  val playjson = "com.typesafe.play" %% "play-json" % "2.4.3"
}

object Build extends SbtBuild {

  import BuildSettings._
  import Dependencies._

  lazy val root = Project(id = "Application",
    base = file("."),
    settings = buildSettings ++ Seq(
      run <<= run in Compile in core
    )
  ).aggregate(core)


  lazy val core = Project("core",
    file("core"),
    settings = buildSettings
  )

  lazy val app = Project("app",
    file("app"),
    settings = buildSettings ++ Seq(
      libraryDependencies ++= Seq(
        playjson
      )
    )
  ).enablePlugins(PlayScala, ScalaJSPlugin)

}

project/plugins.sbt

logLevel := Level.Warn

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

addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "0.6.5")
memleek
  • 31
  • 2
  • What problem are you getting? You are right that play doesn't require ebean. Neither does SBT. – Bhashit Parikh Oct 12 '15 at 06:14
  • Whenever I try and run sbt, it fails with the message: `[info] Loading project definition from /home/rm/PlayApp/project Play ebean module has been replaced with an external Play ebean plugin. See https://playframework.com/documentation/2.4.x/Migration24 for details.` – memleek Oct 12 '15 at 06:23
  • Whelp, my mistake. Turns out a nested build.sbt listed ebeans as a dependency. Problem solved! – memleek Oct 12 '15 at 06:27

1 Answers1

1

You just need to add Ebean as a plugin and enable it as the Play offical documentation says:

Ebean dependency

Ebean has been pulled out into an external project, to allow it to have a lifecycle independent of Play’s own lifecycle. The Ebean bytecode enhancement functionality has also been extracted out of the Play sbt plugin into its own plugin.

To migrate an existing Play project that uses Ebean to use the new external Ebean plugin, remove javaEbean from your libraryDependencies in build.sbt, and add the following to project/plugins.sbt:

  • addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")

After that, enable Ebean plugin for your project:

  • lazy val myProject = (project in file(".")).enablePlugins(PlayJava, PlayEbean)

And finally, configure Ebean mapped classes as a list instead of a comma separated string (which is still supported but was deprecated):

  • ebean.default = ["models.*"]

  • ebean.orders = ["models.Order","models.OrderItem"]

Additionally, Ebean has been upgraded to 4.5.x, which pulls in a few of the features that Play previously added itself, including the Model class. Consequently, the Play Model class has been deprecated, in favour of using com.avaje.ebean.Model.

Community
  • 1
  • 1
G. I. Joe
  • 1,585
  • 17
  • 21