Skip to content

Commit

Permalink
Support Scala3 (#474)
Browse files Browse the repository at this point in the history
* Prepare build for Scala 3
* Migrate tokenizer
* Setup cross version compatibility between Scala 2/3
* Migrate ValueColumnImpl
* Migrate valueToStatement
* Migrate ToParameterListImpl.caseClass
* Migrate ToParameterListImpl.sealedTrait
* Migration SealedRowParserImpl
* Migration RowParserImpl
  • Loading branch information
cchantep authored Aug 27, 2022
1 parent 1ecea38 commit 3f1f8e4
Show file tree
Hide file tree
Showing 75 changed files with 4,254 additions and 1,316 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: playframework/.github/.github/workflows/cmd.yml@v2
with:
java: 11, 8
scala: 2.11.12, 2.12.16, 2.13.8
scala: 2.11.12, 2.12.16, 2.13.8 # TODO: 3.1.3 (other play modules not ok)
cmd: sbt ++$MATRIX_SCALA docs/test

tests:
Expand All @@ -40,8 +40,8 @@ jobs:
uses: playframework/.github/.github/workflows/cmd.yml@v2
with:
java: 11, 8
scala: 2.11.12, 2.12.16, 2.13.8
cmd: sbt ++$MATRIX_SCALA publishLocal test # scapegoat
scala: 2.11.12, 2.12.16, 2.13.8, 3.1.3
cmd: sbt ++$MATRIX_SCALA publishLocal test

finish:
name: Finish
Expand Down
2 changes: 1 addition & 1 deletion .scalafix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ OrganizeImports {
"re:javax?\\.",
"scala.language", "scala.util", "scala.collection",
"scala.",
"akka.",
"akka.actor", "akka.stream", "akka.",
"play.",
"resource.",
"acolyte.",
Expand Down
13 changes: 11 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
runner.dialect = scala213
version = 3.5.8

runner.dialect = Scala213Source3
project.layout = StandardConvention

align.preset = true
assumeStandardLibraryStripMargin = true
danglingParentheses.preset = true
Expand All @@ -10,5 +14,10 @@ rewrite.rules = [ AvoidInfix, RedundantParens, SortModifiers, PreferCurlyFors ]
rewrite.sortModifiers.order = [ "private", "protected", "final", "sealed", "abstract", "implicit", "override", "lazy" ]
spaces.inImportCurlyBraces = true # more idiomatic to include whitepsace in import x.{ yyy }
trailingCommas = preserve

newlines.afterCurlyLambda = preserve
version = 3.5.9
newlines.beforeCurlyLambdaParams = multilineWithCaseOnly

literals.long=Upper
literals.float=Upper
literals.double=Upper
18 changes: 12 additions & 6 deletions akka/src/test/scala/anorm/AkkaStreamSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@ import scala.collection.immutable.Seq
import scala.concurrent.Future
import scala.concurrent.duration._

import akka.actor.ActorSystem

import akka.stream.Materializer
import akka.stream.scaladsl.{ Keep, Sink, Source }

import acolyte.jdbc.QueryResult
import acolyte.jdbc.AcolyteDSL.withQueryResult
import acolyte.jdbc.Implicits._
import acolyte.jdbc.QueryResult
import acolyte.jdbc.RowLists.stringList

import org.specs2.concurrent.ExecutionEnv

final class AkkaStreamSpec(implicit ee: ExecutionEnv) extends org.specs2.mutable.Specification {

"Akka Stream" title
"Akka Stream".title

implicit lazy val system: ActorSystem = ActorSystem("anorm-tests")

implicit lazy val system = akka.actor.ActorSystem("knox-core-tests")
implicit def materializer = akka.stream.ActorMaterializer.create(system)
implicit def materializer: Materializer =
akka.stream.ActorMaterializer.create(system)

// Akka-Contrib issue with Akka-Stream > 2.5.4
// import akka.stream.contrib.TestKit.assertAllStagesStopped
Expand Down Expand Up @@ -66,8 +71,9 @@ final class AkkaStreamSpec(implicit ee: ExecutionEnv) extends org.specs2.mutable

"on success" in assertAllStagesStopped {
withQueryResult(stringList :+ "A" :+ "B" :+ "C") { implicit con =>
runAsync(Sink.seq[String]) must beLike[ResultSet] { case rs =>
(rs.isClosed must beTrue).and(rs.getStatement.isClosed must beTrue).and(con.isClosed must beFalse)
runAsync(Sink.seq[String]) must beLike[ResultSet] {
case rs =>
(rs.isClosed must beTrue).and(rs.getStatement.isClosed must beTrue).and(con.isClosed must beFalse)
}.await(0, 5.seconds)
}
}
Expand Down
Loading

0 comments on commit 3f1f8e4

Please sign in to comment.