From 3e99c0d38bd8d08c1503fa5164803e712d21850d Mon Sep 17 00:00:00 2001 From: hrj Date: Mon, 3 Jan 2022 17:21:24 +0530 Subject: [PATCH 1/5] update to scala 3 Signed-off-by: hrj --- .scalafmt.conf | 2 +- build.sbt | 9 +++------ src/main/scala/lc/core/config.scala | 3 +++ src/main/scala/lc/server/Server.scala | 1 + 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 9567408..79c162d 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,3 +1,3 @@ version="3.3.1" maxColumn = 120 -runner.dialect = scala213source3 +runner.dialect = scala3 diff --git a/build.sbt b/build.sbt index a0313f0..fe85472 100644 --- a/build.sbt +++ b/build.sbt @@ -2,25 +2,22 @@ lazy val root = (project in file(".")).settings( inThisBuild( List( organization := "com.example", - scalaVersion := "2.13.7", + scalaVersion := "3.1.0", version := "0.1.0-SNAPSHOT", semanticdbEnabled := true, semanticdbVersion := scalafixSemanticdb.revision, - scalafixScalaBinaryVersion := "2.13" + scalafixScalaBinaryVersion := "3.1" ) ), name := "LibreCaptcha", libraryDependencies += "com.sksamuel.scrimage" % "scrimage-core" % "4.0.24", libraryDependencies += "com.sksamuel.scrimage" % "scrimage-filters" % "4.0.24", - libraryDependencies += "org.json4s" % "json4s-jackson_2.13" % "4.0.3" + libraryDependencies += "org.json4s" %% "json4s-jackson" % "4.0.3" ) Compile / unmanagedResourceDirectories += { baseDirectory.value / "lib" } scalacOptions ++= List( - "-Yrangepos", - "-Ywarn-unused", "-deprecation", - "-Xsource:3" ) javacOptions += "-g:none" compileOrder := CompileOrder.JavaThenScala diff --git a/src/main/scala/lc/core/config.scala b/src/main/scala/lc/core/config.scala index 83d84e3..cee03a4 100644 --- a/src/main/scala/lc/core/config.scala +++ b/src/main/scala/lc/core/config.scala @@ -4,6 +4,9 @@ import scala.io.Source.fromFile import org.json4s.{DefaultFormats, JValue, JObject, JField, JString} import org.json4s.jackson.JsonMethods.{parse, render, pretty} import org.json4s.JsonDSL._ +import org.json4s.StringInput +import org.json4s.jvalue2monadic +import org.json4s.jvalue2extractable import java.io.{FileNotFoundException, File, PrintWriter} import java.{util => ju} import lc.misc.HelperFunctions diff --git a/src/main/scala/lc/server/Server.scala b/src/main/scala/lc/server/Server.scala index 5134373..54af9b7 100644 --- a/src/main/scala/lc/server/Server.scala +++ b/src/main/scala/lc/server/Server.scala @@ -1,6 +1,7 @@ package lc.server import org.json4s.jackson.JsonMethods.parse +import org.json4s.jvalue2extractable import lc.core.Captcha import lc.core.ErrorMessageEnum import lc.core.{Answer, ByteConvert, Error, Id, Parameters} From 0b17419ccf272269193d98ce58d8037c24b70932 Mon Sep 17 00:00:00 2001 From: hrj Date: Mon, 3 Jan 2022 17:24:35 +0530 Subject: [PATCH 2/5] disable unsupported option Signed-off-by: hrj --- build.sbt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index fe85472..f95d684 100644 --- a/build.sbt +++ b/build.sbt @@ -6,7 +6,9 @@ lazy val root = (project in file(".")).settings( version := "0.1.0-SNAPSHOT", semanticdbEnabled := true, semanticdbVersion := scalafixSemanticdb.revision, - scalafixScalaBinaryVersion := "3.1" + + // This is apparently not supported on Scala 3 currently + // scalafixScalaBinaryVersion := "3.1" ) ), name := "LibreCaptcha", From 9688387b9bfdfd9c4658e79cedb71b77577178b9 Mon Sep 17 00:00:00 2001 From: hrj Date: Mon, 3 Jan 2022 17:38:26 +0530 Subject: [PATCH 3/5] remove unsupported rules in scalafix Signed-off-by: hrj --- .scalafix.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/.scalafix.conf b/.scalafix.conf index 5bc5b4e..0a711f8 100644 --- a/.scalafix.conf +++ b/.scalafix.conf @@ -1,8 +1,5 @@ rules=[ - ExplicitResultTypes, - RemoveUnused, DisableSyntax, LeakingImplicitClassVal, NoValInForComprehension, - ProcedureSyntax ] From 4853e6bccf32daaebb4e23b363e047c24f9d2758 Mon Sep 17 00:00:00 2001 From: hrj Date: Mon, 3 Jan 2022 18:26:17 +0530 Subject: [PATCH 4/5] change jar path in test Signed-off-by: hrj --- tests/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.sh b/tests/run.sh index b26a54b..01261a7 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -4,7 +4,7 @@ python3 -m venv testEnv source ./testEnv/bin/activate pip install locust mkdir -p data/ -java -jar target/scala-2.13/LibreCaptcha.jar & +java -jar target/scala-3.1.0/LibreCaptcha.jar & JAVA_PID=$! sleep 4 From e78af739518a67380e25f5bebf064de94d017b05 Mon Sep 17 00:00:00 2001 From: hrj Date: Mon, 3 Jan 2022 18:38:37 +0530 Subject: [PATCH 5/5] update jar path in second test Signed-off-by: hrj --- tests/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.sh b/tests/run.sh index 01261a7..badfafb 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -22,7 +22,7 @@ echo Run functional test cp data/config.json data/config.json.bak cp tests/debug-config.json data/config.json -java -jar target/scala-2.13/LibreCaptcha.jar & +java -jar target/scala-3.1.0/LibreCaptcha.jar & JAVA_PID=$! sleep 4