Skip to content
Merged
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
47 changes: 0 additions & 47 deletions .travis.yml

This file was deleted.

67 changes: 41 additions & 26 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,69 @@ lazy val quiver = project
skip in publish := true
)

val CatsVersion = "2.2.0"
val SilencerVersion = "1.7.1"
val CatsVersion = "2.6.1"
val ScalacheckShapeless = "1.2.5"
val CollectionsCompat = "2.2.0"
val CollectionsCompat = "2.5.0"
val ScodecVersion = "1.11.7"
val Scodec2Version = "2.0.0"
val Scala212Version = "2.12.14"
val Scala213Version = "2.13.6"
val Scala3Version = "3.0.1"

lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("core"))
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-free" % CatsVersion,
"org.scala-lang.modules" %%% "scala-collection-compat" % CollectionsCompat,
"org.typelevel" %%% "cats-laws" % CatsVersion % Test,
"com.github.alexarchambault" %%% "scalacheck-shapeless_1.14" % ScalacheckShapeless % Test
"org.typelevel" %%% "cats-free" % CatsVersion,
"org.scala-lang.modules" %%% "scala-collection-compat" % CollectionsCompat,
"org.typelevel" %%% "cats-laws" % CatsVersion % Test
)
)
.settings(commonSettings)
.settings(silenceCompat)
.settings(coverageEnabled := scalaBinaryVersion.value != "2.13")
.settings(silenceUnusedImport)
.settings(coverageEnabled := scalaBinaryVersion.value == "2.13")
.jsSettings(coverageEnabled := false)

val commonSettings = Seq(
organization in Global := "io.getnelson.quiver",
scalaVersion in Global := crossScalaVersions.value.head,
crossScalaVersions in Global := Seq("2.13.3", "2.12.12"),
val silenceUnusedImport = Seq(
scalacOptions ++= {
if (scalaBinaryVersion.value.startsWith("2."))
Seq(
"-Wconf:cat=unused-imports&site=quiver:s,any:wv",
"-Wconf:cat=unused-imports:s,any:wv"
)
else Seq.empty
}
)

val silenceCompat = Seq(
libraryDependencies ++= Seq(
compilerPlugin(
"com.github.ghik" % "silencer-plugin" % SilencerVersion cross CrossVersion.full
),
"com.github.ghik" % "silencer-lib" % SilencerVersion % Provided cross CrossVersion.full
),
scalacOptions in Compile ++= Seq(
"""-P:silencer:lineContentFilters=import scala\.collection\.compat\._"""
)
val commonSettings = Seq(
organization := "io.getnelson.quiver",
scalaVersion := Scala212Version,
crossScalaVersions := Seq(Scala212Version, Scala213Version, Scala3Version)
)

lazy val codecs = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("codecs"))
.dependsOn(core % "test->test;compile->compile")
.settings(
libraryDependencies += "org.scodec" %%% "scodec-core" % ScodecVersion
libraryDependencies += {
if (scalaVersion.value.startsWith("2."))
"org.scodec" %%% "scodec-core" % ScodecVersion
else "org.scodec" %%% "scodec-core" % Scodec2Version
}
)
.settings(
Compile / unmanagedSourceDirectories ++= {
if (scalaVersion.value.startsWith("2."))
Seq(
(ThisBuild / baseDirectory).value / "codecs" / "src" / "main" / "scala-2"
)
else Seq.empty
}
)
.settings(commonSettings)
.settings(coverageEnabled := scalaBinaryVersion.value != "2.13")
.settings(coverageEnabled := scalaBinaryVersion.value == "2.13")
.jsSettings(coverageEnabled := false)

lazy val docsMappingsAPIDir = settingKey[String](
Expand All @@ -65,7 +79,9 @@ lazy val docs = project
.in(file("quiver-docs"))
.dependsOn(core.jvm, codecs.jvm)
.enablePlugins(MdocPlugin, MicrositesPlugin, ScalaUnidocPlugin)
.settings(commonSettings)
.settings(
crossScalaVersions -= Scala3Version,
unidocProjectFilter in (ScalaUnidoc, unidoc) := inProjects(
core.jvm,
codecs.jvm
Expand All @@ -87,4 +103,3 @@ lazy val docs = project
micrositeDocumentationLabelDescription := "API Documentation",
micrositeBaseUrl := "/quiver"
)
.settings(silenceCompat)
24 changes: 24 additions & 0 deletions codecs/src/main/scala-2/ScodecPlatform.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//: ----------------------------------------------------------------------------
//: Copyright (C) 2015 Verizon. All Rights Reserved.
//:
//: Licensed under the Apache License, Version 2.0 (the "License");
//: you may not use this file except in compliance with the License.
//: You may obtain a copy of the License at
//:
//: http://www.apache.org/licenses/LICENSE-2.0
//:
//: Unless required by applicable law or agreed to in writing, software
//: distributed under the License is distributed on an "AS IS" BASIS,
//: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//: See the License for the specific language governing permissions and
//: limitations under the License.
//:
//: ----------------------------------------------------------------------------
package quiver

import scodec._

private[quiver] trait ScodecPlatform {
def pairCodecs[A, B](l: Codec[A], r: Codec[B]) =
l pairedWith r
}
24 changes: 24 additions & 0 deletions codecs/src/main/scala-3/ScodecPlatform.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//: ----------------------------------------------------------------------------
//: Copyright (C) 2015 Verizon. All Rights Reserved.
//:
//: Licensed under the Apache License, Version 2.0 (the "License");
//: you may not use this file except in compliance with the License.
//: You may obtain a copy of the License at
//:
//: http://www.apache.org/licenses/LICENSE-2.0
//:
//: Unless required by applicable law or agreed to in writing, software
//: distributed under the License is distributed on an "AS IS" BASIS,
//: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//: See the License for the specific language governing permissions and
//: limitations under the License.
//:
//: ----------------------------------------------------------------------------
package quiver

import scodec._

private[quiver] trait ScodecPlatform {
def pairCodecs[A, B](l: Codec[A], r: Codec[B]) =
l :: r
}
23 changes: 12 additions & 11 deletions codecs/src/main/scala/GraphCodecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,28 @@ package quiver

import scodec._

object GraphCodecs {
object GraphCodecs extends ScodecPlatform {

def ledge[N: Codec, A: Codec]: Codec[LEdge[N,A]] =
def ledge[N: Codec, A: Codec]: Codec[LEdge[N, A]] =
(implicitly[Codec[N]] ::
implicitly[Codec[N]] ::
implicitly[Codec[A]]).as[LEdge[N,A]]
implicitly[Codec[N]] ::
implicitly[Codec[A]]).as[LEdge[N, A]]

def lnode[N: Codec, A: Codec]: Codec[LNode[N,A]] =
def lnode[N: Codec, A: Codec]: Codec[LNode[N, A]] =
(implicitly[Codec[N]] ::
implicitly[Codec[A]]).as[LNode[N,A]]
implicitly[Codec[A]]).as[LNode[N, A]]

// needed because sometimes the codecs are greedy which
// makes the whole graph not decode correctly.
private def indexedSeq[A : Codec]: Codec[IndexedSeq[A]] =
private def indexedSeq[A: Codec]: Codec[IndexedSeq[A]] =
codecs.variableSizeBytes(
codecs.int32,
codecs.vector(implicitly[Codec[A]]).xmap(a => a, _.toVector))
codecs.vector(implicitly[Codec[A]]).xmap(a => a, _.toVector)
)

def graph[N: Codec, A: Codec, B: Codec]: Codec[Graph[N,A,B]] =
(indexedSeq(lnode[N,A]) ~ indexedSeq(ledge[N,B])).xmap(
q => safeMkGraph(q._1,q._2),
def graph[N: Codec, A: Codec, B: Codec]: Codec[Graph[N, A, B]] =
pairCodecs(indexedSeq(lnode[N, A]), indexedSeq(ledge[N, B])).xmap(
q => safeMkGraph(q._1, q._2),
g => (g.labNodes, g.labEdges)
)
}
5 changes: 3 additions & 2 deletions codecs/src/test/scala/GraphCodecsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ import org.scalacheck._
import org.scalacheck.Prop._
import scodec.codecs
import scodec.Attempt
import scodec.Codec

object GraphCodecsTest extends Properties("codecs"){
import GraphGen.{arbitraryNode,arbitraryEdge,arbitraryGraph}

implicit val uint8 = codecs.int32
implicit val uint8: Codec[Int] = codecs.int32

def roundTrip[A](typeName: String)(implicit ca: scodec.Codec[A], aa: Arbitrary[A]): Unit = {
val _ = property(s"binary encoding round trip - $typeName") = {
forAll { a: A =>
forAll { (a: A) =>
val result = for {
encoded <- ca.encode(a)
decoded <- ca.decode(encoded)
Expand Down
Loading