ing-bank / scruid

Scala + Druid: Scruid. A library that allows you to compose queries in Scala, and parse the result back into typesafe classes.
Apache License 2.0
115 stars 29 forks source link

Cross-build for Scala 2.11, 2.12 and 2.13 #80

Closed anskarl closed 4 years ago

anskarl commented 4 years ago

Scruid can now cross-build for Scala 2.11, 2.12 and 2.13.

All dependencies have been upgraded, in order to support Scala 2.13. The changes are outlined below:

Circe related changes

Streaming JSON support with Circe is provided by akka-streams-json v0.4.0. However, Circe from version 0.12.0-M4 and later dropped the support for Scala 2.11. As a result, for Scala 2.11 builds, Scruid depends on version 0.11.1 of Circe, while for Scala 2.12+ builds depends on Circe version 0.12.1.

In the current version of Scruid, trait io.circe.java8.time.JavaTimeDecoders is provided by the artifact circe-java8 and is only available in Circe v0.11.1. In Scruid, trait JavaTimeDecoders is extended by DruidResult and DruidClient. For recent versions of Circe (e.g., 0.12.1), as it has been noted here, the java.time instances are now included in the Encoder and Decoder companion objects and therefore the artifact circe-java8 does not exists anymore. To overcome that issue, trait JavaTimeDecoders in Scruid is being replaced by a new utility trait ing.wbaa.druid.client.CirceDecoders which is defined differently per Scala version (see SBT Scala-version specific source directory). For instance, trait CirceDecoders for Scala 2.11 is defined in src/main/scala-2.11/ing/wbaa/druid/client/CirceDecoders.scala and extends the JavaTimeDecoders:

package ing.wbaa.druid.client

import io.circe.java8.time._

trait CirceDecoders extends JavaTimeDecoders

While the same trait for Scala 2.12 is defined in src/main/scala-2.12/ing/wbaa/druid/client/CirceDecoders.scala and does not extends JavaTimeDecoders.

Scala 2.13 related changes

Minor code changes in ing.wbaa.druid.client.DruidAdvancedHttpClient and ing.wbaa.druid.dql.DQLSpec to address the follow warnings in Scala 2.13:

Since symbol literal is now deprecated in Scala 2.13, the documentation examples use the d"some_dim" notation for dimensions.

Compiler settings for Scala 2.13:

CircleCI

When cross-building I was getting java.lang.OutOfMemoryError: Metaspace in CircleCI (not locally). Although I changed the memory settings in .sbtopts as well as in .cicleci/config.yml (e.g., Xmx4G and XX:MaxMetaspaceSize=512M) I was still getting java.lang.OutOfMemoryError: Metaspace. As a result, I also defined separate runs in .cicleci/config.yml, each one for the desired Scala version:

      - run: sbt ++2.11.12 compile
      - run: sbt ++2.12.9 compile
      - run: sbt ++2.13.1 compile