import play.Project in Play 2.3 not working

2019-09-05 06:42发布

In an older Play app (v 2.2.x) I have the following in my Build.scala

import play.Project._

In v.2.3 this is not compiling

Is there any reason for this based on the version?

2条回答
走好不送
2楼-- · 2019-09-05 07:00

See the migration guide

https://www.playframework.com/documentation/2.3.x/Migration23 - scroll down to Build Changes

Near: "If you were previously using play.Project, for example a Scala project [...] then you can continue to use a similar approach via native sbt"

查看更多
家丑人穷心不美
3楼-- · 2019-09-05 07:04

Need to take care while migrating - in Build.scala

In Play 2.2

import sbt._
import Keys._
import PlayProject._

Migrate to Play 2.3, add the followings

import play.Play.autoImport._
import PlayKeys._

Remove import PlayProject._

Add also

If Java Project

val main = Project(appName, file(".")).enablePlugins(play.PlayJava).settings( version := appVersion, libraryDependencies ++= appDependencies )

If Scala Project

val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings( version := appVersion, libraryDependencies ++= appDependencies )

Instead of

val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings()

Don't need to add the scalaVersion := "2.11.1" in Build.scala or build.sbt file as suggested in the Play 2.3 Migration Guide. In Play 2.2 the Build.scala or build.sbt file structure is different.

查看更多
登录 后发表回答