Skip to content

Commit b681c30

Browse files
dlinovandr83
authored andcommitted
Add support for Scala 2.13 and drop support for Scala 2.10
1 parent fad7e4c commit b681c30

File tree

5 files changed

+32
-16
lines changed

5 files changed

+32
-16
lines changed

build.sbt

+16-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ val scalaconfig = project
77
organization := "com.github.andr83",
88
name := "scalaconfig",
99
version := "0.6-SNAPSHOT",
10-
scalaVersion := "2.12.8",
10+
scalaVersion := "2.13.3",
1111
scalacOptions += "-Xlog-implicits",
12-
crossScalaVersions := Seq("2.10.6", "2.11.0", "2.12.0"),
12+
crossScalaVersions := Seq("2.11.12", "2.12.12", "2.13.3"),
1313
isSnapshot := version.value.endsWith("-SNAPSHOT"),
1414
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8"),
1515
resolvers ++= Seq(
@@ -35,10 +35,22 @@ val scalaconfig = project
3535
pomIncludeRepository := { _ => false },
3636
libraryDependencies ++= Seq(
3737
Library.typesafeConfig % "provided",
38+
Library.scalaCollectionCompat,
3839
Library.scalaTest % "test",
39-
Library.shapeless,
40-
compilerPlugin(Library.scalaMacrosParadise cross CrossVersion.full)
40+
Library.shapeless
4141
),
42+
Compile / scalacOptions ++= {
43+
CrossVersion.partialVersion(scalaVersion.value) match {
44+
case Some((2, n)) if n >= 13 => "-Ymacro-annotations" :: Nil
45+
case _ => Nil
46+
}
47+
},
48+
libraryDependencies ++= {
49+
CrossVersion.partialVersion(scalaVersion.value) match {
50+
case Some((2, n)) if n >= 13 => Nil
51+
case _ => compilerPlugin(Library.scalaMacrosParadise cross CrossVersion.full) :: Nil
52+
}
53+
},
4254
pomExtra := {
4355
<url>https://github.com/andr83/scalaconfig</url>
4456
<licenses>

project/Dependencies.scala

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import sbt._
22

33

44
object Version {
5-
val typesafeConfig = "1.3.1"
6-
val scalaTest = "3.0.1"
7-
val shapeless = "2.3.2"
8-
val scalaMacrosParadise = "2.1.0"
5+
val typesafeConfig = "1.4.0"
6+
val scalaCollectionCompat = "2.1.6"
7+
val scalaTest = "3.2.0"
8+
val shapeless = "2.3.3"
9+
val scalaMacrosParadise = "2.1.1"
910
}
1011

1112
object Library {
1213
val typesafeConfig = "com.typesafe" % "config" % Version.typesafeConfig
1314
val scalaTest = "org.scalatest" %% "scalatest" % Version.scalaTest
1415
val shapeless = "com.chuusai" %% "shapeless" % Version.shapeless
16+
val scalaCollectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % Version.scalaCollectionCompat
1517
val scalaMacrosParadise = "org.scalamacros" % "paradise" % Version.scalaMacrosParadise
1618
}

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 1.2.4
1+
sbt.version = 1.3.13

src/main/scala/com/github/andr83/scalaconfig/instances/DefaultReader.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.github.andr83.scalaconfig.{FakePath, Reader}
66
import com.typesafe.config.{Config, ConfigValue}
77

88
import scala.collection.JavaConverters._
9-
import scala.collection.generic.CanBuildFrom
9+
import scala.collection.compat._
1010
import scala.concurrent.duration.{FiniteDuration, NANOSECONDS}
1111
import scala.language.higherKinds
1212

@@ -48,7 +48,7 @@ trait DefaultReader {
4848
}
4949
})
5050

51-
implicit def traversableReader[A: Reader, C[_]](implicit cbf: CanBuildFrom[Nothing, A, C[A]]): Reader[C[A]] = Reader.pureV((config: Config, path: String) => {
51+
implicit def traversableReader[A: Reader, C[_]](implicit factory: Factory[A, C[A]]): Reader[C[A]] = Reader.pureV((config: Config, path: String) => {
5252
val reader = implicitly[Reader[A]]
5353
val list = config.getList(path).asScala
5454

@@ -58,9 +58,9 @@ trait DefaultReader {
5858
}) partition (_.isLeft)
5959

6060
if (errors.nonEmpty) {
61-
Left(errors.flatMap(_.left.get))
61+
Left(errors.flatMap(_.left.get).toSeq)
6262
} else {
63-
val builder = cbf()
63+
val builder = factory.newBuilder
6464
builder.sizeHint(list.size)
6565
res.foreach {
6666
case Right(a) => builder += a

src/test/scala/com/github/andr83/scalaconfig/ReaderSpec.scala

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ package com.github.andr83.scalaconfig
33
import java.util.Properties
44

55
import com.typesafe.config.{Config, ConfigFactory, ConfigValue, ConfigValueType}
6-
import org.scalatest.{FlatSpec, Inside, Matchers}
6+
import org.scalatest.Inside
7+
import org.scalatest.flatspec.AnyFlatSpec
8+
import org.scalatest.matchers.should.Matchers
79

810
import scala.concurrent.duration._
911

1012
/**
1113
* @author andr83
1214
*/
13-
class ReaderSpec extends FlatSpec with Matchers with Inside {
15+
class ReaderSpec extends AnyFlatSpec with Matchers with Inside {
1416

1517
"String value reader" should "read string" in {
1618
val config = ConfigFactory.parseString(s"stringField = SomeString")
@@ -21,7 +23,7 @@ class ReaderSpec extends FlatSpec with Matchers with Inside {
2123
"String value" should "be read as symbol also" in {
2224
val config = ConfigFactory.parseString(s"stringField = SomeString")
2325

24-
config.asUnsafe[Symbol]("stringField") should equal('SomeString)
26+
config.asUnsafe[Symbol]("stringField") should equal(Symbol("SomeString"))
2527
}
2628

2729
"Int value reader" should "read int" in {

0 commit comments

Comments
 (0)