Skip to content

Commit

Permalink
Migration to Scala 2.13
Browse files Browse the repository at this point in the history
Fixes #82
  • Loading branch information
minettiandrea committed Jan 21, 2022
1 parent ff0a91f commit a6189db
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 28 deletions.
13 changes: 7 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ publish / skip := true
lazy val codegen = (project in file("codegen")).settings(
name := "box-codegen",
licenses += ("Apache-2.0", url("http://www.opensource.org/licenses/apache2.0.php")),
scalaVersion := Settings.versions.scala212,
scalaVersion := Settings.versions.scala213,
libraryDependencies ++= Settings.codegenDependecies.value,
resolvers += Resolver.jcenterRepo,
Compile / resourceDirectory := baseDirectory.value / "../resources",
Expand All @@ -52,7 +52,7 @@ lazy val codegen = (project in file("codegen")).settings(
lazy val serverServices = (project in file("server-services")).settings(
name := "box-server-services",
licenses += ("Apache-2.0", url("http://www.opensource.org/licenses/apache2.0.php")),
scalaVersion := Settings.versions.scala212,
scalaVersion := Settings.versions.scala213,
libraryDependencies += "com.iheart" %% "ficus" % Settings.versions.ficus,
resolvers += Resolver.jcenterRepo,
).settings(publishSettings).dependsOn(sharedJVM)
Expand All @@ -61,11 +61,12 @@ lazy val server: Project = project
.settings(
name := "box-server",
licenses += ("Apache-2.0", url("http://www.opensource.org/licenses/apache2.0.php")),
scalaVersion := Settings.versions.scala212,
scalaBinaryVersion := "2.12",
scalaVersion := Settings.versions.scala213,
scalaBinaryVersion := "2.13",
scalacOptions ++= Settings.scalacOptionsServer,
libraryDependencies ++= Settings.jvmDependencies.value,
resolvers += "OSGeo Releases" at "https://repo.osgeo.org/repository/release",
resolvers += "Eclipse" at "https://repo.eclipse.org/content/groups/snapshots",
slick := slickCodeGenTask.value , // register manual sbt command
deleteSlick := deleteSlickTask.value,
Compile / packageBin / mainClass := Some("ch.wsl.box.rest.Boot"),
Expand Down Expand Up @@ -114,7 +115,7 @@ lazy val server: Project = project
lazy val serverCacheRedis = (project in file("server-cache-redis")).settings(
name := "box-server-cache-redis",
licenses += ("Apache-2.0", url("http://www.opensource.org/licenses/apache2.0.php")),
scalaVersion := Settings.versions.scala212,
scalaVersion := Settings.versions.scala213,
libraryDependencies ++= Settings.serverCacheRedisDependecies.value,
resolvers += Resolver.jcenterRepo,
).settings(publishSettings).dependsOn(serverServices)
Expand Down Expand Up @@ -228,7 +229,7 @@ lazy val shared = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure

lazy val sharedJVM: Project = shared.jvm.settings(
name := "box-shared-jvm",
scalaVersion := Settings.versions.scala212,
scalaVersion := Settings.versions.scala213,
)

lazy val sharedJS: Project = shared.js.settings(
Expand Down
11 changes: 5 additions & 6 deletions project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ object Settings {
object versions {

//General
val scala212 = "2.12.12"
val scala213 = "2.13.3"
val scala213 = "2.13.8"
val ficus = "1.4.7"

val macWire = "2.3.7"
Expand Down Expand Up @@ -117,8 +116,8 @@ object Settings {

/** Dependencies only used by the JVM project */
val jvmDependencies = Def.setting(sharedJVMCodegenDependencies.value ++ Seq(
"org.scala-lang" % "scala-reflect" % versions.scala212,
"org.scala-lang" % "scala-compiler" % versions.scala212,
"org.scala-lang" % "scala-reflect" % versions.scala213,
"org.scala-lang" % "scala-compiler" % versions.scala213,
"com.typesafe.akka" %% "akka-http-core" % versions.akkaHttp,
"com.typesafe.akka" %% "akka-http-caching" % versions.akkaHttp,
"de.heikoseeberger" %% "akka-http-circe" % versions.akkaHttpJson,
Expand All @@ -140,14 +139,14 @@ object Settings {
"com.dimafeng" %% "testcontainers-scala-postgresql" % versions.testcontainersScalaVersion % "test",
"com.outr" %% "scribe" % versions.scribe,
"com.outr" %% "scribe-slf4j" % versions.scribe,
"ch.wavein" %% "scala-thumbnailer" % "0.7.1",
"ch.wavein" %% "scala-thumbnailer" % "0.7.2",
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
"org.mitre.dsmiley.httpproxy" % "smiley-http-proxy-servlet" % "1.10",
"com.openhtmltopdf" % "openhtmltopdf-pdfbox" % "1.0.9",
"org.jsoup" % "jsoup" % "1.12.1",
"com.github.spullara.mustache.java" % "compiler" % "0.9.6",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.10.3",
"org.locationtech.geotrellis" %% "geotrellis-raster" % "3.6.0",
"org.locationtech.geotrellis" %% "geotrellis-raster" % "3.6.0-SNAPSHOT",
"com.norbitltd" %% "spoiwo" % "1.7.0",
"io.github.cquiroz" %% "scala-java-time" % "2.0.0",
"org.flywaydb" % "flyway-core" % "7.9.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ch.wsl.box.rest.html.mustache

import java.util
import java.util.Map.Entry
import scala.collection.JavaConversions._

import scala.util.Try

Expand All @@ -26,7 +25,7 @@ class ArrayMap(val obj: Seq[Any]) extends java.util.AbstractMap[Any, Any] with j
override def hasNext: Boolean = index < length

override def next(): Any = {
val nextObj = obj.get(index)
val nextObj = obj(index)
index += 1
nextObj
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package ch.wsl.box.rest.html.mustache

import java.io.Writer
import java.lang.reflect.{Field, Method}

import com.github.mustachejava.Iteration
import com.github.mustachejava.reflect.ReflectionObjectHandler

import scala.collection.JavaConversions.mapAsJavaMap
import scala.jdk.CollectionConverters._
import scala.reflect.ClassTag
import scala.runtime.BoxedUnit

Expand All @@ -19,7 +18,7 @@ class ScalaObjectHandler extends ReflectionObjectHandler {

override def coerce(value: AnyRef) = {
value match {
case m: collection.Map[_, _] => mapAsJavaMap(m)
case m: collection.Map[_, _] => m.asJava
case u: BoxedUnit => null
case s: Seq[Any] => new ArrayMap(s)
case Some(some: AnyRef) => coerce(some)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import scribe.Logging

import scala.concurrent.{ExecutionContext, Future}

case class BoxFormMetadataFactory(implicit mat:Materializer, ec:ExecutionContext, services:Services) extends Logging with MetadataFactory {
class BoxFormMetadataFactory(implicit mat:Materializer, ec:ExecutionContext, services:Services) extends Logging with MetadataFactory {



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ch.wsl.box.services.Services
import scala.concurrent.{ExecutionContext, Future}
import scala.util.Try

case class ExportMetadataFactory(implicit up:UserProfile, mat:Materializer, ec:ExecutionContext,services:Services) extends Logging with DataMetadataFactory {
class ExportMetadataFactory(implicit up:UserProfile, mat:Materializer, ec:ExecutionContext,services:Services) extends Logging with DataMetadataFactory {

import io.circe.generic.auto._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ch.wsl.box.services.Services
import scala.concurrent.{ExecutionContext, Future}
import scala.util.Try

case class FunctionMetadataFactory(implicit up:UserProfile, mat:Materializer, ec:ExecutionContext,services:Services) extends Logging with DataMetadataFactory {
class FunctionMetadataFactory(implicit up:UserProfile, mat:Materializer, ec:ExecutionContext,services:Services) extends Logging with DataMetadataFactory {

import io.circe.generic.auto._

Expand Down
2 changes: 1 addition & 1 deletion server/src/main/scala/ch/wsl/box/rest/routes/Export.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Export extends Data with Logging {
import io.circe.generic.auto._


override def metadataFactory(implicit up: UserProfile, mat: Materializer, ec: ExecutionContext,services:Services): DataMetadataFactory = ExportMetadataFactory()
override def metadataFactory(implicit up: UserProfile, mat: Materializer, ec: ExecutionContext,services:Services): DataMetadataFactory = new ExportMetadataFactory()


override def data(function: String, params: Json, lang: String)(implicit up: UserProfile, mat:Materializer, ec: ExecutionContext,system:ActorSystem,services:Services): Future[Option[DataContainer]] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object Functions extends Data {



override def metadataFactory(implicit up: UserProfile, mat: Materializer, ec: ExecutionContext,services:Services): DataMetadataFactory = FunctionMetadataFactory()
override def metadataFactory(implicit up: UserProfile, mat: Materializer, ec: ExecutionContext,services:Services): DataMetadataFactory = new FunctionMetadataFactory()

def functions = ch.wsl.box.model.boxentities.BoxFunction

Expand Down
4 changes: 2 additions & 2 deletions server/src/main/scala/ch/wsl/box/rest/routes/v1/Admin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ case class Admin(session:BoxSession)(implicit ec:ExecutionContext, userProfile:
def form = pathPrefix(EntityKind.BOX_FORM.kind) {
pathPrefix(Segment) { lang =>
pathPrefix(Segment) { name =>
Form(name, lang,BoxActionsRegistry().tableActions,BoxFormMetadataFactory(),userProfile.db,EntityKind.BOX_FORM.kind,schema = BoxSchema.schema).route
Form(name, lang,BoxActionsRegistry().tableActions,new BoxFormMetadataFactory(),userProfile.db,EntityKind.BOX_FORM.kind,schema = BoxSchema.schema).route
}
}
}

def forms = path(EntityKind.BOX_FORM.plural) {
get {
complete(services.connection.adminDB.run(BoxFormMetadataFactory().list))
complete(services.connection.adminDB.run(new BoxFormMetadataFactory().list))
}
}

Expand Down
4 changes: 2 additions & 2 deletions server/src/main/scala/ch/wsl/box/rest/routes/v1/ApiV1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ case class ApiV1(appVersion:String)(implicit ec:ExecutionContext, sessionManager
ui ~
uiFile ~
Cache.resetRoute() ~
PublicArea().route ~
PrivateArea().route
new PublicArea().route ~
new PrivateArea().route
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import io.circe.Json

import scala.concurrent.ExecutionContext

case class PrivateArea(implicit ec:ExecutionContext, sessionManager: SessionManager[BoxSession], mat:Materializer, system:ActorSystem, services: Services) {
class PrivateArea(implicit ec:ExecutionContext, sessionManager: SessionManager[BoxSession], mat:Materializer, system:ActorSystem, services: Services) {

import Directives._
import ch.wsl.box.jdbc.Connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import ch.wsl.box.services.Services
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}

case class PublicArea(implicit ec:ExecutionContext, mat:Materializer, system:ActorSystem,services:Services) {
class PublicArea(implicit ec:ExecutionContext, mat:Materializer, system:ActorSystem,services:Services) {

lazy val publicEntities:Future[Seq[BoxPublicEntities.Row]] = services.connection.adminDB.run(BoxPublicEntities.table.result)

Expand Down

0 comments on commit a6189db

Please sign in to comment.