Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

Scala 2.13 support + Dependencies Update #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ val repo = "[email protected]:jto/validation.git"
val org = "io.github.jto"
val license = ("Apache License", url("http://www.apache.org/licenses/LICENSE-2.0.txt"))

val catsVersion = "1.2.0"
val jodaConvertVersion = "2.1.1"
val jodaTimeVersion = "2.10"
val kindProjectorVersion = "0.9.7"
val parserCombinatorsVersion = "1.1.1"
val playVersion = "2.6.3"
val scalacVersion = "2.12.6"
val scalatestVersion = "3.2.0-SNAP10"
val scalaXmlVersion = "1.1.0"
val catsVersion = "2.0.0"
val jodaConvertVersion = "2.2.1"
val jodaTimeVersion = "2.10.4"
val kindProjectorVersion = "0.10.3"
val parserCombinatorsVersion = "1.1.2"
val playVersion = "2.7.4"
val scalacVersion = "2.13.0"
val scalatestVersion = "3.0.8"
val scalaXmlVersion = "1.2.0"

lazy val root = aggregate("validation", validationJVM, validationJS, docs).in(file("."))
lazy val validationJVM = aggregate("validationJVM", coreJVM, formJVM, delimitedJVM, jsonAstJVM, `validation-playjson`, `validation-xml`, `date-tests`)
Expand All @@ -25,6 +25,7 @@ lazy val `validation-core` =
.crossType(CrossType.Pure)
.settings(validationSettings: _*)
.settings(generateBoilerplate: _*)
.settings(libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value)
lazy val coreJVM = `validation-core`.jvm
lazy val coreJS = `validation-core`.js
lazy val core = aggregate("validation-core", coreJVM, coreJS)
Expand Down Expand Up @@ -111,16 +112,17 @@ lazy val validationSettings = settings ++ dependencies ++ doPublish ++ scoverage

lazy val settings = Seq(
scalaVersion := scalacVersion,
crossScalaVersions := Seq(scalacVersion, "2.11.12"),
crossScalaVersions := Seq(scalacVersion, "2.12.10", "2.11.12"),
organization := org,
scalacOptions ++= commonScalacOptions,
scalacOptions in (Compile, console) ~= (_ filterNot (_ == "-Ywarn-unused-import")),
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value.filterNot(_ == "-Xfatal-warnings"),
scalacOptions -= "-Xfatal-warnings",
resolvers ++= commonResolvers,
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"),
scalaJSStage in Global := FastOptStage,
parallelExecution := false,
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.0" % "test"
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.1" % "test"
)

val commonScalacOptions = Seq(
Expand All @@ -136,13 +138,11 @@ val commonScalacOptions = Seq(
"-Xfatal-warnings",
"-Xlint",
// "-Yinline-warnings",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Ywarn-unused-import",
"-Xfuture",
"-Ypartial-unification"
//"-Ypartial-unification"
)

val commonResolvers = Seq(
Expand All @@ -157,7 +157,7 @@ val dependencies = Seq(
"joda-time" % "joda-time" % jodaTimeVersion,
"org.joda" % "joda-convert" % jodaConvertVersion
),
addCompilerPlugin("org.spire-math" %% "kind-projector" % kindProjectorVersion)
addCompilerPlugin("org.typelevel" %% "kind-projector" % kindProjectorVersion)
)

val generateBoilerplate = Seq(
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.1
sbt.version=1.3.2
27 changes: 20 additions & 7 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
resolvers += Resolver.url(
"tpolecat-sbt-plugin-releases",
url("http://dl.bintray.com/content/tpolecat/sbt-plugin-releases"))(
url("https://dl.bintray.com/content/tpolecat/sbt-plugin-releases"))(
Resolver.ivyStylePatterns)

addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.7")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.12")

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.29")

addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7")

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.2")

addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.3")

addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.8")

addSbtPlugin("org.duhemm" % "sbt-errors-summary" % "0.6.3")

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.24")

addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.5")
6 changes: 3 additions & 3 deletions validation-core/src/main/scala/Formatter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object To {
w.writes(o)
}

case class Reader[I](path: Path = Path(Nil)) {
final case class Reader[I](path: Path = Path(Nil)) {

/**
* When applied, the rule will lookup for data at the given path, and apply the `sub` Rule on it
Expand Down Expand Up @@ -112,7 +112,7 @@ case class Reader[I](path: Path = Path(Nil)) {
def \(child: PathNode): Reader[I] = Reader(path \ child)
}

case class Writer[I](path: Path = Path(Nil)) {
final case class Writer[I](path: Path = Path(Nil)) {

/**
* Create a Write that convert data to type `I`, and put it at Path `path`
Expand Down Expand Up @@ -156,7 +156,7 @@ object Formatting {
def apply[IR, IW] = new Formatting[IR, IW] {}
}

case class Formatter[IR, IW](path: Path = Path(Nil)) {
final case class Formatter[IR, IW](path: Path = Path(Nil)) {

def format[JJ, J, O](subR: => RuleLike[J, O], subW: => WriteLike[O, JJ])(
implicit r: Path => RuleLike[IR, J],
Expand Down
4 changes: 2 additions & 2 deletions validation-core/src/main/scala/Path.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package jto.validation

sealed trait PathNode
case class KeyPathNode(key: String) extends PathNode {
final case class KeyPathNode(key: String) extends PathNode {
override def toString = key
}

case class IdxPathNode(idx: Int) extends PathNode {
final case class IdxPathNode(idx: Int) extends PathNode {
override def toString = s"[$idx]"
}

Expand Down
2 changes: 1 addition & 1 deletion validation-core/src/main/scala/SyntaxObs.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package jto.validation

case class ~[A, B](_1: A, _2: B)
final case class ~[A, B](_1: A, _2: B)

trait SyntaxCombine[M[_]] {
def apply[A, B](ma: M[A], mb: M[B]): M[A ~ B]
Expand Down
2 changes: 1 addition & 1 deletion validation-core/src/main/scala/ValidationError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package jto.validation
* @param message the error message
* @param args the error message arguments
*/
case class ValidationError(messages: Seq[String], args: Any*) {
final case class ValidationError(messages: Seq[String], args: Any*) {
lazy val message = messages.last
}

Expand Down
2 changes: 1 addition & 1 deletion validation-delimited/src/test/scala/RulesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.scalatest._
class RulesSpec extends WordSpec with Matchers {
"Rules" should {
"demonstrate typical usage" in {
case class Contact(name: String, email: String, birthday: Option[String])
final case class Contact(name: String, email: String, birthday: Option[String])

val contactReads = From[Delimited] { __ =>
(
Expand Down
2 changes: 1 addition & 1 deletion validation-form/src/main/scala/Writes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait Writes

implicit def mapW[I](implicit w: WriteLike[I, Seq[String]]) =
Write[Map[String, I], PM] { m =>
toPM(m.mapValues(w.writes))
toPM(m.map { case (k,v) => k -> w.writes(v) } )
}

implicit def spm[O](implicit w: WriteLike[O, PM]) =
Expand Down
4 changes: 2 additions & 2 deletions validation-form/src/test/scala/FormatSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.scalatest._
import scala.Function.unlift

class FormatSpec extends WordSpec with Matchers {
case class User(id: Long, name: String)
final case class User(id: Long, name: String)
val luigi = User(1, "Luigi")

"Format" should {
Expand Down Expand Up @@ -389,7 +389,7 @@ class FormatSpec extends WordSpec with Matchers {
}

"format recursive" when {
case class RecUser(name: String, friends: Seq[RecUser] = Nil)
final case class RecUser(name: String, friends: Seq[RecUser] = Nil)
val u = RecUser("bob", Seq(RecUser("tom")))

val m = Map("name" -> Seq("bob"),
Expand Down
38 changes: 19 additions & 19 deletions validation-form/src/test/scala/MacroSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ import jto.validation._
import jto.validation.forms._
import org.scalatest._

case class User(age: Int, name: String)
case class Dog(name: String, master: User)
case class Cat(name: String)
case class RecUser(name: String,
final case class User(age: Int, name: String)
final case class Dog(name: String, master: User)
final case class Cat(name: String)
final case class RecUser(name: String,
cat: Option[Cat] = None,
hobbies: Seq[String] = Seq(),
friends: Seq[RecUser] = Seq())
case class User1(name: String, friend: Option[User1] = None)
case class UserMap(name: String, friends: Map[String, UserMap] = Map())
final case class User1(name: String, friend: Option[User1] = None)
final case class UserMap(name: String, friends: Map[String, UserMap] = Map())

case class Toto(name: String)
case class Toto2(name: Option[String])
case class Toto3(name: List[Double])
case class Toto4(name: Set[Long])
case class Toto5(name: Map[String, Int])
case class Toto6(name: Seq[Dog])
case class UserFail(name: String, bd: Toto)
final case class Toto(name: String)
final case class Toto2(name: Option[String])
final case class Toto3(name: List[Double])
final case class Toto4(name: Set[Long])
final case class Toto5(name: Map[String, Int])
final case class Toto6(name: Seq[Dog])
final case class UserFail(name: String, bd: Toto)

case class Id[A](id: A)
case class C1[A](id: Id[A], name: String)
final case class Id[A](id: A)
final case class C1[A](id: Id[A], name: String)

case class X(
final case class X(
_1: String,
_2: String,
_3: String,
Expand All @@ -47,15 +47,15 @@ case class X(
_21: String
)

case class Program(id: Long,
final case class Program(id: Long,
name: String,
logoPath: Option[String],
logoThumb: Option[String])
object Program {
def programs = List.empty[Program]
}

case class Person(name: String, age: Int)
final case class Person(name: String, age: Int)
object Person {
implicit val personRule = {
import Rules._
Expand All @@ -67,7 +67,7 @@ object Person {
}
}

case class Person2(names: List[String])
final case class Person2(names: List[String])

object Person2 {
implicit val personRule = {
Expand Down
14 changes: 7 additions & 7 deletions validation-form/src/test/scala/RulesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,9 @@ class RulesSpec extends WordSpec with Matchers {

"validate subclasses (and parse the concrete class)" when {

trait A
case class B(foo: Int) extends A
case class C(bar: Int) extends A
sealed trait A
final case class B(foo: Int) extends A
final case class C(bar: Int) extends A

val b = Map("name" -> Seq("B"), "foo" -> Seq("4"))
val c = Map("name" -> Seq("C"), "bar" -> Seq("6"))
Expand Down Expand Up @@ -498,12 +498,12 @@ class RulesSpec extends WordSpec with Matchers {
}

"perform complex validation" in {
case class Contact(firstname: String,
final case class Contact(firstname: String,
lastname: String,
company: Option[String],
informations: Seq[ContactInformation])

case class ContactInformation(
final case class ContactInformation(
label: String, email: Option[String], phones: Seq[String])

val validM = Map("firstname" -> Seq("Julien"),
Expand Down Expand Up @@ -596,14 +596,14 @@ class RulesSpec extends WordSpec with Matchers {
}

"read recursive" when {
case class RecUser(name: String, friends: Seq[RecUser] = Nil)
final case class RecUser(name: String, friends: Seq[RecUser] = Nil)
val u = RecUser("bob", Seq(RecUser("tom")))

val m = Map("name" -> Seq("bob"),
"friends[0].name" -> Seq("tom"),
"friends[0].friends" -> Seq())

case class User1(name: String, friend: Option[User1] = None)
final case class User1(name: String, friend: Option[User1] = None)
val u1 = User1("bob", Some(User1("tom")))
val m1 = Map("name" -> Seq("bob"), "friend.name" -> Seq("tom"))

Expand Down
12 changes: 6 additions & 6 deletions validation-form/src/test/scala/WritesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import scala.Function.unlift

class WritesSpec extends WordSpec with Matchers {

case class Contact(firstname: String,
final case class Contact(firstname: String,
lastname: String,
company: Option[String],
informations: Seq[ContactInformation])

case class ContactInformation(
final case class ContactInformation(
label: String, email: Option[String], phones: Seq[String])

val contact = Contact(
Expand Down Expand Up @@ -53,7 +53,7 @@ class WritesSpec extends WordSpec with Matchers {
"n" -> Seq("5"))
(Path \ "n").write(optionW(intW)).writes(None) shouldBe Map.empty

case class Foo(name: String)
final case class Foo(name: String)
implicit val wf =
(Path \ "name").write[String, UrlFormEncoded].contramap((_: Foo).name)
val wmf = (Path \ "maybe").write[Option[Foo], UrlFormEncoded]
Expand Down Expand Up @@ -346,12 +346,12 @@ class WritesSpec extends WordSpec with Matchers {
}

"write recursive" when {
case class RecUser(name: String, friends: List[RecUser] = Nil)
final case class RecUser(name: String, friends: List[RecUser] = Nil)
val u = RecUser("bob", List(RecUser("tom")))

val m = Map("name" -> Seq("bob"), "friends[0].name" -> Seq("tom"))

case class User1(name: String, friend: Option[User1] = None)
final case class User1(name: String, friend: Option[User1] = None)
val u1 = User1("bob", Some(User1("tom")))
val m1 = Map("name" -> Seq("bob"), "friend.name" -> Seq("tom"))

Expand Down Expand Up @@ -404,7 +404,7 @@ class WritesSpec extends WordSpec with Matchers {
}

object TestValueClass {
case class Id(value: String) extends AnyVal
final case class Id(value: String) extends AnyVal
object Id {
implicit val writes: Write[Id, String] = Write(id => id.value)
}
Expand Down
Loading