start the long migration
![](http://steamregister.com/wp-content/uploads/2016/02/021216-bird-migration-1-630x375.jpg)scala-2.12-play-2.6
parent
599fb907da
commit
71668b8b5c
24
build.sbt
24
build.sbt
|
@ -1,20 +1,16 @@
|
|||
import com.typesafe.sbt.packager.Keys.scriptClasspath
|
||||
import com.typesafe.sbt.SbtScalariform.autoImport.scalariformFormat
|
||||
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
|
||||
import com.typesafe.sbt.web.SbtWeb.autoImport._
|
||||
import play.Play.autoImport._
|
||||
import play.sbt.PlayImport._
|
||||
import play.twirl.sbt.Import._
|
||||
import play.sbt.PlayImport._
|
||||
import PlayKeys._
|
||||
import scalariform.formatter.preferences._
|
||||
|
||||
import BuildSettings._
|
||||
import Dependencies._
|
||||
|
||||
lazy val root = Project("lila", file("."))
|
||||
.enablePlugins(_root_.play.sbt.PlayScala)
|
||||
.dependsOn(api)
|
||||
.aggregate(api)
|
||||
lazy val root = Project("lila", file(".")).dependsOn(api).aggregate(api)
|
||||
.enablePlugins(PlayScala, PlayNettyServer, JavaAppPackaging)
|
||||
.disablePlugins(PlayAkkaHttpServer)
|
||||
.disablePlugins(PlayFilters)
|
||||
|
||||
scalaVersion := globalScalaVersion
|
||||
resolvers ++= Dependencies.Resolvers.commons
|
||||
|
@ -34,9 +30,8 @@ scriptClasspath := Seq("*")
|
|||
libraryDependencies ++= Seq(
|
||||
scalaz, chess, scalalib, hasher, typesafeConfig, findbugs,
|
||||
reactivemongo.driver, reactivemongo.iteratees, akka.actor, akka.slf4j,
|
||||
maxmind, prismic, netty, guava,
|
||||
kamon.core, kamon.influxdb,
|
||||
java8compat, semver, scrimage, scalaConfigs, scaffeine
|
||||
maxmind, prismic, guava,
|
||||
kamon.core, kamon.influxdb, semver, scrimage, scalaConfigs, scaffeine
|
||||
)
|
||||
TwirlKeys.templateImports ++= Seq(
|
||||
"lila.game.{ Game, Player, Pov }",
|
||||
|
@ -51,6 +46,9 @@ TwirlKeys.templateImports ++= Seq(
|
|||
)
|
||||
resourceDirectory in Assets := (sourceDirectory in Compile).value / "assets"
|
||||
|
||||
import com.typesafe.sbt.SbtScalariform.autoImport.scalariformFormat
|
||||
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
|
||||
import scalariform.formatter.preferences._
|
||||
Seq(
|
||||
ScalariformKeys.preferences := ScalariformKeys.preferences.value
|
||||
.setPreference(DanglingCloseParenthesis, Force)
|
||||
|
@ -129,7 +127,7 @@ lazy val evaluation = module("evaluation", Seq(
|
|||
// )
|
||||
|
||||
lazy val common = module("common", Seq()).settings(
|
||||
libraryDependencies ++= provided(play.api, play.test, reactivemongo.driver, kamon.core)
|
||||
libraryDependencies ++= provided(play.api, play.test, play.jodaForms, reactivemongo.driver, kamon.core)
|
||||
)
|
||||
|
||||
lazy val rating = module("rating", Seq(common, db)).settings(
|
||||
|
|
|
@ -2,7 +2,7 @@ package lila.common
|
|||
|
||||
import play.api.i18n.Lang
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.ws.WS
|
||||
import old.play.api.libs.ws.WS
|
||||
import play.api.Play.current
|
||||
|
||||
// http://detectlanguage.com
|
||||
|
|
|
@ -50,6 +50,8 @@ object Form {
|
|||
}
|
||||
|
||||
object UTCDate {
|
||||
import play.api.data.JodaForms._
|
||||
import play.api.data.format.JodaFormats._
|
||||
val dateTimePattern = "yyyy-MM-dd HH:mm"
|
||||
val utcDate = jodaDate(dateTimePattern, DateTimeZone.UTC)
|
||||
implicit val dateTimeFormat = jodaDateTimeFormat(dateTimePattern)
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
package old.play
|
||||
|
||||
import java.util.concurrent.atomic.{ AtomicReference }
|
||||
// import java.util.concurrent.{Executors, ThreadFactory}
|
||||
|
||||
import akka.actor.{ ActorSystem, Scheduler }
|
||||
import akka.stream.Materializer
|
||||
import play.api._
|
||||
import play.api.ApplicationLoader.Context
|
||||
import play.api.inject.guice.GuiceApplicationBuilder
|
||||
import play.api.inject.Injector
|
||||
import play.api.libs.ws.WSClient
|
||||
import play.api.Mode
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
/*
|
||||
* Band aid for progressive migration to 2.6
|
||||
* https://gist.github.com/mathieuancelin/b50342227d0e686397cde6de33d5e356
|
||||
*/
|
||||
object Env {
|
||||
|
||||
// I know it's really bad ...
|
||||
private[play] val _ref: AtomicReference[Application] = new AtomicReference[Application]()
|
||||
|
||||
lazy val application: Application = Option(_ref.get()).get
|
||||
lazy val actorSystem: ActorSystem = application.actorSystem
|
||||
lazy val materializer: Materializer = application.materializer
|
||||
lazy val configuration: Configuration = application.configuration
|
||||
lazy val mode: Mode = application.mode
|
||||
lazy val scheduler: Scheduler = actorSystem.scheduler
|
||||
lazy val injector: Injector = application.injector
|
||||
lazy val playExecutionContext: ExecutionContext = injector.instanceOf(classOf[ExecutionContext])
|
||||
lazy val environment: Environment = injector.instanceOf(classOf[Environment])
|
||||
lazy val WS: WSClient = injector.instanceOf(classOf[WSClient])
|
||||
// lazy val cache: CacheApi = injector.instanceOf(classOf[CacheApi])
|
||||
// lazy val procNbr = Runtime.getRuntime.availableProcessors()
|
||||
|
||||
// private def factory(of: String) = new ThreadFactory {
|
||||
// val counter = new AtomicInteger(0)
|
||||
// override def newThread(r: Runnable): Thread = new Thread(r, s"$of-${counter.incrementAndGet()}")
|
||||
// }
|
||||
|
||||
// lazy val httpRequestExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(procNbr * 2, factory("http-requests")))
|
||||
// lazy val httpCallsExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(procNbr * 10, factory("http-calls")))
|
||||
// lazy val dataStoreExecContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(procNbr * 5, factory("data-store")))
|
||||
|
||||
}
|
||||
|
||||
trait GoodOldPlay {
|
||||
|
||||
object Implicits {
|
||||
implicit def defaultActorSystem: ActorSystem = Env.actorSystem
|
||||
implicit def defaultMaterializer: Materializer = Env.materializer
|
||||
implicit def defaultScheduler: Scheduler = Env.scheduler
|
||||
implicit def defaultContext: ExecutionContext = Env.playExecutionContext
|
||||
}
|
||||
|
||||
def WS = Env.WS
|
||||
def Configuration = Env.configuration
|
||||
def Application = Env.configuration
|
||||
def Injector = Env.configuration
|
||||
def Mode = Env.configuration
|
||||
|
||||
def currentApplication = Env.application
|
||||
def defaultContext = Env.playExecutionContext
|
||||
def defaultScheduler = Env.scheduler
|
||||
def defaultMaterializer = Env.scheduler
|
||||
def defaultActorSystem = Env.configuration
|
||||
// def httpRequestsContext = Env.httpRequestExecContext
|
||||
// def httpCallsContext = Env.httpCallsExecContext
|
||||
// def dataStoreContext = Env.dataStoreExecContext
|
||||
}
|
||||
|
||||
object api {
|
||||
object Play {
|
||||
def application = Env.application
|
||||
def maybeApplication = Option(Env.application)
|
||||
def injector = Env.injector
|
||||
def classloader = Env.application.classloader
|
||||
def configuration = Env.configuration
|
||||
def current = Env.application
|
||||
def isDev = Env.mode == Mode.Dev
|
||||
def isProd = Env.mode == Mode.Prod
|
||||
def isTest = Env.mode == Mode.Test
|
||||
def mode = Env.mode
|
||||
// def getFile(relativePath: String) = Env.application.getFile(relativePath)
|
||||
// def getExistingFile(relativePath: String) = Env.application.getExistingFile(relativePath)
|
||||
// def resource(name: String) = Env.application.resource(name)
|
||||
// def resourceAsStream(name: String) = Env.application.resourceAsStream(name)
|
||||
}
|
||||
object libs {
|
||||
object ws {
|
||||
def WS = Env.WS
|
||||
}
|
||||
object concurrent {
|
||||
object Akka {
|
||||
object Implicits {
|
||||
implicit def defaultActorSystem: ActorSystem = Env.actorSystem
|
||||
implicit def defaultMaterializer: Materializer = Env.materializer
|
||||
implicit def defaultScheduler: Scheduler = Env.scheduler
|
||||
}
|
||||
def defaultScheduler: Scheduler = Env.scheduler
|
||||
def defaultActorSystem: ActorSystem = Env.actorSystem
|
||||
def defaultMaterializer: Materializer = Env.materializer
|
||||
}
|
||||
object Execution {
|
||||
object Implicits {
|
||||
implicit def defaultContext: ExecutionContext = Env.playExecutionContext
|
||||
}
|
||||
def defaultContext: ExecutionContext = Env.playExecutionContext
|
||||
// def httpRequestsContext = Env.httpRequestExecContext
|
||||
// def httpCallsContext = Env.httpCallsExecContext
|
||||
// def dataStoreContext = Env.dataStoreExecContext
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,16 +26,16 @@ object PlayApp {
|
|||
def withApp[A](op: Application => A): A =
|
||||
Play.maybeApplication map op err "Play application is not started!"
|
||||
|
||||
def system = withApp { implicit app =>
|
||||
play.api.libs.concurrent.Akka.system
|
||||
}
|
||||
// def system = withApp { implicit app =>
|
||||
// old.play.api.libs.concurrent.Akka.system
|
||||
// }
|
||||
|
||||
lazy val langs = loadConfig.getStringList("play.i18n.langs").map(Lang.apply)(scala.collection.breakOut)
|
||||
|
||||
private def enableScheduler = !(loadConfig getBoolean "app.scheduler.disabled")
|
||||
|
||||
lazy val scheduler = new Scheduler(
|
||||
system.scheduler,
|
||||
old.play.Env.actorSystem.scheduler,
|
||||
enabled = enableScheduler && isServer,
|
||||
debug = loadConfig getBoolean "app.scheduler.debug"
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ object BuildSettings {
|
|||
|
||||
import Dependencies._
|
||||
|
||||
val globalScalaVersion = "2.11.11"
|
||||
val globalScalaVersion = "2.12.3"
|
||||
|
||||
def buildSettings = Defaults.coreDefaultSettings ++ Seq(
|
||||
organization := "org.lichess",
|
||||
|
@ -21,7 +21,7 @@ object BuildSettings {
|
|||
publishArtifact in (Compile, packageSrc) := false
|
||||
)
|
||||
|
||||
def defaultDeps = Seq(scalaz, chess, scalalib, jodaTime, ws, java8compat, specs2)
|
||||
def defaultDeps = Seq(scalaz, chess, scalalib, jodaTime, ws, specs2)
|
||||
|
||||
def compile(deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile")
|
||||
def provided(deps: ModuleID*): Seq[ModuleID] = deps map (_ % "provided")
|
||||
|
@ -46,7 +46,7 @@ object BuildSettings {
|
|||
// "-Ywarn-unused-import",
|
||||
// "-Ywarn-unused",
|
||||
// "-Xlint:missing-interpolator",
|
||||
"-Ybackend:GenBCode", "-Ydelambdafy:method", "-target:jvm-1.8"
|
||||
"-Ydelambdafy:method"
|
||||
)
|
||||
|
||||
val srcMain = Seq(
|
||||
|
|
|
@ -30,14 +30,12 @@ object Dependencies {
|
|||
val jodaTime = "joda-time" % "joda-time" % "2.9.9"
|
||||
|
||||
val chess = "org.lichess" %% "scalachess" % "6.6"
|
||||
val maxmind = "com.sanoma.cda" %% "maxmind-geoip2-scala" % "1.2.3-THIB"
|
||||
val prismic = "io.prismic" %% "scala-kit" % "1.2.11-THIB"
|
||||
val java8compat = "org.scala-lang.modules" %% "scala-java8-compat" % "0.8.0"
|
||||
val maxmind = "com.sanoma.cda" %% "maxmind-geoip2-scala" % "1.3.0-THIB"
|
||||
val prismic = "io.prismic" %% "scala-kit" % "1.2.12-THIB"
|
||||
val semver = "com.gilt" %% "gfc-semver" % "0.0.5"
|
||||
val scrimage = "com.sksamuel.scrimage" %% "scrimage-core" % "2.1.8"
|
||||
val scalaConfigs = "com.github.kxbmap" %% "configs" % "0.4.4"
|
||||
val scaffeine = "com.github.blemale" %% "scaffeine" % "2.2.0" % "compile"
|
||||
val netty = "io.netty" % "netty" % "3.10.6.Final"
|
||||
val guava = "com.google.guava" % "guava" % "21.0"
|
||||
val specs2 = "org.specs2" %% "specs2-core" % "3.9.2" % "test"
|
||||
|
||||
|
@ -52,17 +50,18 @@ object Dependencies {
|
|||
}
|
||||
|
||||
object play {
|
||||
val version = "2.4.6"
|
||||
val version = "2.6.3"
|
||||
val api = "com.typesafe.play" %% "play" % version
|
||||
val jodaForms = "com.typesafe.play" %% "play-joda-forms" % version
|
||||
val test = "com.typesafe.play" %% "play-test" % version
|
||||
}
|
||||
object akka {
|
||||
val version = "2.4.16"
|
||||
val version = "2.5.4"
|
||||
val actor = "com.typesafe.akka" %% "akka-actor" % version
|
||||
val slf4j = "com.typesafe.akka" %% "akka-slf4j" % version
|
||||
}
|
||||
object kamon {
|
||||
val version = "0.6.4.2-LILA"
|
||||
val version = "0.6.7"
|
||||
val core = "io.kamon" %% "kamon-core" % version
|
||||
val influxdb = "io.kamon" %% "kamon-influxdb" % version
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
|
||||
|
||||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6")
|
||||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.3")
|
||||
|
||||
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.0")
|
||||
|
|
Loading…
Reference in New Issue