Skip to content

Commit

Permalink
Drop Java 8 support (#2890)
Browse files Browse the repository at this point in the history
* Drop Java 8 support

* Fix compilation

* clean

* Fix test

* Fix test

* Fix test

* Fix test

* Fix test

* Fix test

* Fix test

* rebase on master

* Fix tests

* Fix tests

* Fix test

* Fix tests

* Fix Scala 2.12 compilation

* Fix test

* Fix compilation
  • Loading branch information
guizmaii authored Sep 30, 2023
1 parent 5402d84 commit cbc1a49
Show file tree
Hide file tree
Showing 29 changed files with 110 additions and 99 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ on:
types: [ published ] # Triggers the CI when a new Github Release is published

env:
JAVA_OPTS: -Xms6G -Xmx6G -XX:+UseG1GC
JDK_JAVA_OPTIONS: -Xms6G -Xmx6G -XX:+UseG1GC # See https://stackoverflow.com/a/73708006
# See:
# - https://stackoverflow.com/a/73708006
# - https://stackoverflow.com/questions/73465937/apache-spark-3-3-0-breaks-on-java-17-with-cannot-access-class-sun-nio-ch-direct
JDK_JAVA_OPTIONS: -Xms6G -Xmx6G -XX:+UseG1GC --add-exports java.base/sun.nio.ch=ALL-UNNAMED

jobs:
build:
Expand Down Expand Up @@ -68,7 +70,7 @@ jobs:
uses: actions/setup-java@v3.12.0
with:
distribution: temurin
java-version: '8'
java-version: '17'
check-latest: true

- name: Build modules
Expand All @@ -91,7 +93,7 @@ jobs:
uses: actions/setup-java@v3.12.0
with:
distribution: temurin
java-version: '8'
java-version: '17'
check-latest: true
- run: |
sbt ++2.12.x -Dquill.scala.version=2.12.x -Dquill.macro.log=false ci-release
Expand Down
22 changes: 4 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ lazy val scala213Modules =

lazy val scala3Modules = Seq[sbt.ClasspathDep[sbt.ProjectReference]](`quill-engine`, `quill-util`)

def javaMainVersion = {
val javaVersion = System.getProperty("java.version")
val versionSplit = javaVersion.split('.')
if (versionSplit.head.equals("1")) {
versionSplit(1).toInt
} else {
versionSplit(0).toInt
}
}

def isScala213 = {
val scalaVersion = sys.props.get("quill.scala.version")
scalaVersion.map(_.startsWith("2.13")).getOrElse(false)
Expand Down Expand Up @@ -221,12 +211,7 @@ lazy val `quill-engine` =
("com.github.takayahilton" %% "sql-formatter" % "1.2.1").cross(CrossVersion.for3Use2_13),
"io.suzaku" %% "boopickle" % "1.4.0",
"com.lihaoyi" %% "pprint" % "0.8.1",
// caffeine 3.x doesn't support Java version lower than 11
if (javaMainVersion >= 11) {
"com.github.ben-manes.caffeine" % "caffeine" % "3.1.8"
} else {
"com.github.ben-manes.caffeine" % "caffeine" % "2.9.3"
}
"com.github.ben-manes.caffeine" % "caffeine" % "3.1.8"
),
coverageExcludedPackages := "<empty>;.*AstPrinter;.*Using;io.getquill.Model;io.getquill.ScalarTag;io.getquill.QuotationTag"
)
Expand Down Expand Up @@ -587,7 +572,7 @@ lazy val excludeFilterSettings = Seq(

excludeTests match {
case ExcludeTests.Include =>
excludePaths(List())
excludePaths(List.empty)
case _ =>
excludePaths(paths)
}
Expand Down Expand Up @@ -666,8 +651,9 @@ lazy val basicSettings = excludeFilterSettings ++ Seq(
Test / unmanagedClasspath ++= Seq(
baseDirectory.value / "src" / "test" / "resources"
),
javacOptions := Seq("-source", "11", "-target", "11"),
scalacOptions ++= Seq(
"-release:8",
"-release:11",
"-encoding",
"UTF-8",
"-feature",
Expand Down
14 changes: 3 additions & 11 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export CASSANDRA_DC=datacenter1
export ORIENTDB_HOST=127.0.0.1
export ORIENTDB_PORT=12424

export JAVA_OPTS="-Dquill.macro.log=false -Dquill.scala.version=$SCALA_VERSION -Xms3g -Xmx3g -Xss5m -XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC"
export JAVA_OPTS="-Dquill.macro.log=false -Dquill.scala.version=$SCALA_VERSION -Xms3g -Xmx3g -Xss5m -XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation"

modules=$1
echo "Start build modules: $modules"
Expand Down Expand Up @@ -164,27 +164,19 @@ function wait_for_bigdata() {

function base_build() {
echo "build.sh =:> Base Build Specified"
export JAVA_OPTS="-Dquill.macro.log=false -Dquill.scala.version=$SCALA_VERSION -Xms4g -Xmx4g -Xss10m -XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC"
export JAVA_OPTS="-Dquill.macro.log=false -Dquill.scala.version=$SCALA_VERSION -Xms4g -Xmx4g -Xss10m -XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation "
echo "build.sh =:> Starting Base Build Primary"
sbt "sbt -Dmodules=base $SBT_ARGS test"
}

function db_build() {
echo "build.sh =:> DB Build Specified"
wait_for_databases
export JAVA_OPTS="-Dquill.macro.log=false -Dquill.scala.version=$SCALA_VERSION -Xms4g -Xmx4g -Xss10m -XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC"
export JAVA_OPTS="-Dquill.macro.log=false -Dquill.scala.version=$SCALA_VERSION -Xms4g -Xmx4g -Xss10m -XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation "
echo "build.sh =:> Starting DB Build Primary"
./build/aware_run.sh "sbt -Dmodules=db $SBT_ARGS test"
}

function js_build() {
echo "build.sh =:> JS Build Specified"
show_mem
export JAVA_OPTS="-Dquill.macro.log=false -Dquill.scala.version=$SCALA_VERSION -Xms4g -Xmx4g -Xss10m -XX:ReservedCodeCacheSize=256m -XX:+TieredCompilation -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC"
echo "build.sh =:> Starting JS Build Primary"
sbt -Dmodules=js $SBT_ARGS test
}

function async_build() {
echo "build.sh =:> Async Build Specified"
wait_for_mysql_postgres
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
List(1f, 3f),
List(5d),
List(LocalDate.now()),
List(Instant.now()),
List(
Instant.now().truncatedTo(java.time.temporal.ChronoUnit.MILLIS)
), // See https://stackoverflow.com/a/74781779/2431728
List(UUID.randomUUID())
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.getquill.context.cassandra.alpakka

import io.getquill.context.cassandra.CollectionsSpec

import java.time.temporal.ChronoUnit
import java.time.{Instant, LocalDate}
import java.util.UUID

Expand All @@ -20,11 +21,13 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {

val e = MapsEntity(
1,
Map("1" -> BigDecimal(1)),
Map(1 -> 1d, 2 -> 2d, 3 -> 3d),
Map(1L -> 3f),
Map(true -> LocalDate.now()),
Map(UUID.randomUUID() -> Instant.now())
Map("1" -> BigDecimal(1)),
Map(1 -> 1d, 2 -> 2d, 3 -> 3d),
Map(1L -> 3f),
Map(true -> LocalDate.now()),
Map(
UUID.randomUUID() -> Instant.now().truncatedTo(ChronoUnit.MILLIS)
) // See https://stackoverflow.com/a/74781779/2431728
)
val q = quote(query[MapsEntity])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.getquill.context.cassandra.alpakka

import io.getquill.context.cassandra.CollectionsSpec

import java.time.temporal.ChronoUnit
import java.time.{Instant, LocalDate}
import java.util.UUID

Expand Down Expand Up @@ -33,7 +34,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
Set(1f, 3f),
Set(5d),
Set(LocalDate.now()),
Set(Instant.now()),
Set(Instant.now().truncatedTo(ChronoUnit.MILLIS)), // See https://stackoverflow.com/a/74781779/2431728
Set(UUID.randomUUID())
)
val q = quote(query[SetsEntity])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.getquill.context.cassandra

import java.util.{Date, UUID}
import java.time.{Instant, LocalDate}
import java.util.UUID

class ListsEncodingSpec extends CollectionsSpec {
val ctx = testSyncDB
Expand Down Expand Up @@ -34,7 +34,9 @@ class ListsEncodingSpec extends CollectionsSpec {
List(1f, 3f),
List(5d),
List(LocalDate.now()),
List(Instant.now()),
List(
Instant.now().truncatedTo(java.time.temporal.ChronoUnit.MILLIS)
), // See https://stackoverflow.com/a/74781779/2431728
List(UUID.randomUUID())
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.getquill.context.cassandra

import java.time.temporal.ChronoUnit
import java.time.{Instant, LocalDate}
import java.util.{Date, UUID}
import java.util.UUID

class MapsEncodingSpec extends CollectionsSpec {
val ctx = testSyncDB
Expand All @@ -17,11 +18,13 @@ class MapsEncodingSpec extends CollectionsSpec {
)
val e = MapsEntity(
1,
Map("1" -> BigDecimal(1)),
Map(1 -> 1d, 2 -> 2d, 3 -> 3d),
Map(1L -> 3f),
Map(true -> LocalDate.now()),
Map(UUID.randomUUID() -> Instant.now())
Map("1" -> BigDecimal(1)),
Map(1 -> 1d, 2 -> 2d, 3 -> 3d),
Map(1L -> 3f),
Map(true -> LocalDate.now()),
Map(
UUID.randomUUID() -> Instant.now().truncatedTo(ChronoUnit.MILLIS)
) // See https://stackoverflow.com/a/74781779/2431728
)
val q = quote(query[MapsEntity])

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.getquill.context.cassandra

import java.time.temporal.ChronoUnit
import java.time.{Instant, LocalDate}
import java.util.{Date, UUID}
import java.util.UUID

class SetsEncodingSpec extends CollectionsSpec {
val ctx = testSyncDB
Expand Down Expand Up @@ -30,7 +31,7 @@ class SetsEncodingSpec extends CollectionsSpec {
Set(1f, 3f),
Set(5d),
Set(LocalDate.now()),
Set(Instant.now()),
Set(Instant.now().truncatedTo(ChronoUnit.MILLIS)), // See https://stackoverflow.com/a/74781779/2431728
Set(UUID.randomUUID())
)
val q = quote(query[SetsEntity])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ object OptionOps {
}
}
implicit class StringOptionExt(opt: Option[String]) {
def andNotEmpty = opt.flatMap(s => if (s.trim.isEmpty) None else Some(s))
def andNotEmpty: Option[String] = opt.flatMap(s => if (s.trim.isEmpty) None else Some(s))
}
}
8 changes: 3 additions & 5 deletions quill-core/src/main/scala/io/getquill/context/Expand.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package io.getquill.context

import io.getquill.{IdiomContext, NamingStrategy}
import io.getquill.ast._
import io.getquill.NamingStrategy
import io.getquill.idiom._
import io.getquill.IdiomContext
import io.getquill.quat.Quat

object CanDoBatchedInsert {
def apply(ast: Ast, idiom: Idiom, statement: Token, isReturning: Boolean, idiomContext: IdiomContext): Boolean = {
Expand All @@ -17,8 +15,8 @@ object CanDoBatchedInsert {
else {
val validations =
for {
_ <- validateConcatenatedIterationPossible(statement).right
_ <- validateIdiomSupportsConcatenatedIteration(idiom, isReturning).right
_ <- validateConcatenatedIterationPossible(statement)
_ <- validateIdiomSupportsConcatenatedIteration(idiom, isReturning)
} yield ()

validations match {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package io.getquill.util

import collection.immutable.ListSet
import collection.mutable.{LinkedHashMap => MMap, Builder}
import scala.language.higherKinds
import scala.collection.immutable.ListSet
import scala.collection.mutable
import scala.collection.mutable.{LinkedHashMap => MMap}

object OrderedGroupByExt {
implicit class GroupByOrderedImplicitImpl[A](val t: Traversable[A]) extends AnyVal {
implicit final class GroupByOrderedImplicitImpl[A](private val t: Iterable[A]) extends AnyVal {
def groupByOrderedUnique[K](f: A => K): Map[K, ListSet[A]] =
groupByGen(ListSet.newBuilder[A])(f)

def groupByOrdered[K](f: A => K): Map[K, List[A]] =
groupByGen(List.newBuilder[A])(f)

def groupByGen[K, C[_]](makeBuilder: => Builder[A, C[A]])(f: A => K): Map[K, C[A]] = {
val map = MMap[K, Builder[A, C[A]]]()
def groupByGen[K, C[_]](makeBuilder: => mutable.Builder[A, C[A]])(f: A => K): Map[K, C[A]] = {
val map = MMap[K, mutable.Builder[A, C[A]]]()
for (i <- t) {
val key = f(i)
val builder = map.get(key) match {
Expand Down
2 changes: 2 additions & 0 deletions quill-core/src/test/scala/io/getquill/base/EncodingSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.getquill.base
import io.getquill.context.Context

import java.util.Date
import scala.annotation.nowarn

trait EncodingSpec extends Spec {

Expand Down Expand Up @@ -167,6 +168,7 @@ trait EncodingSpec extends Spec {
)
)

@nowarn("msg=match may not be exhaustive")
def verify(result: List[EncodingTestEntity]) =
result match {
case List(e1, e2) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package io.getquill.context.jasync.mysql

import java.time.{LocalDate, LocalDateTime}

import io.getquill.context.sql.EncodingSpec

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await
import scala.concurrent.{Await, Future}
import scala.concurrent.duration.Duration
import java.util.Date
import io.getquill.Query
import io.getquill.context.jasync.mysql

import java.time.temporal.ChronoUnit

class MysqlJAsyncEncodingSpec extends EncodingSpec {

Expand Down Expand Up @@ -88,7 +90,11 @@ class MysqlJAsyncEncodingSpec extends EncodingSpec {

"decode LocalDate and LocalDateTime types" in {
case class DateEncodingTestEntity(v1: LocalDate, v2: LocalDateTime, v3: LocalDateTime)
val entity = DateEncodingTestEntity(LocalDate.now, LocalDateTime.now, LocalDateTime.now)
val entity = DateEncodingTestEntity(
LocalDate.now,
LocalDateTime.now.truncatedTo(ChronoUnit.MILLIS),
LocalDateTime.now.truncatedTo(ChronoUnit.MILLIS)
)
val r = for {
_ <- testContext.run(query[DateEncodingTestEntity].delete)
_ <- testContext.run(query[DateEncodingTestEntity].insertValue(lift(entity)))
Expand Down Expand Up @@ -131,7 +137,7 @@ class MysqlJAsyncEncodingSpec extends EncodingSpec {

"encodes custom type inside singleton object" in {
object Singleton {
def apply()(implicit c: TestContext) = {
def apply()(implicit c: TestContext): Future[Seq[Long]] = {
import c._
for {
_ <- c.run(query[EncodingTestEntity].delete)
Expand All @@ -144,7 +150,7 @@ class MysqlJAsyncEncodingSpec extends EncodingSpec {
Await.result(Singleton(), Duration.Inf)
}

private def prepareEncodingTestEntity() = {
private def prepareEncodingTestEntity(): Unit = {
val prepare = for {
_ <- testContext.run(delete)
_ <- testContext.run(liftQuery(insertValues).foreach(e => insert(e)))
Expand Down
Loading

0 comments on commit cbc1a49

Please sign in to comment.