Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 2.13.0-M4 #16

Merged
merged 1 commit into from
Jun 13, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ scala:
- 2.10.7
- 2.11.12
- 2.12.4
- 2.13.0-M3
- 2.13.0-M4

jdk:
- oraclejdk8
21 changes: 17 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
lazy val scalacheck = "org.scalacheck" %% "scalacheck" % "1.13.5"
lazy val scalacheck = "org.scalacheck" %% "scalacheck" % "1.14.0"
def scalaXmlDep(scalaV: String): List[ModuleID] =
CrossVersion.partialVersion(scalaV) match {
case Some((2, minor)) if minor <= 10 =>
Nil
case _ =>
case Some((2, 11 | 12)) =>
List("org.scala-lang.modules" %% "scala-xml" % "1.0.6")
case _ =>
List("org.scala-lang.modules" %% "scala-xml" % "1.1.0")
}

def relaxOldScala: Seq[Setting[_]] = Seq(
scalacOptions := {
val old = scalacOptions.value
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 12 =>
old
old filterNot Set(
"-Yno-adapted-args"
)
case _ =>
old filterNot (Set(
"-Xfatal-warnings",
Expand All @@ -34,7 +38,7 @@ lazy val root = (project in file("."))
homepage := Some(url("https://github.com/sbt/sbinary")),
version := "0.4.5-SNAPSHOT",
scalaVersion := "2.12.4",
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.4", "2.13.0-M3"),
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.4", "2.13.0-M4"),
bintrayPackage := "sbinary",
developers := List(
Developer(
Expand Down Expand Up @@ -63,6 +67,15 @@ lazy val core = (project in file("core")).settings(
Fmpp.templateSettings,
libraryDependencies += scalacheck % Test,
libraryDependencies ++= scalaVersion(scalaXmlDep).value,
unmanagedSourceDirectories in Compile += {
val base = (scalaSource in Compile).value.getParentFile
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v >= 13 =>
base / s"scala-2.13+"
case _ =>
base / s"scala-2.13-"
}
},
unmanagedResources in Compile += (baseDirectory map { _ / "LICENSE" }).value
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sbinary;

import Operations._;
import scala.collection._;
import generic.CanBuildFrom

trait BasicTypes extends CoreProtocol{
implicit def optionsAreFormat[S](implicit bin : Format[S]) : Format[Option[S]] = new Format[Option[S]]{
Expand Down Expand Up @@ -41,19 +40,6 @@ trait BasicTypes extends CoreProtocol{
</#list>
}

trait LowPriorityCollectionTypes extends Generic {
def canBuildFormat[CC[X] <: Traversable[X], T](implicit bin : Format[T], cbf: CanBuildFrom[Nothing, T, CC[T]]) : Format[CC[T]] =
new LengthEncoded[CC[T], T]{
def build(length : Int, ts : Iterator[T]) = {
val builder = cbf.apply()
builder.sizeHint(length)
builder ++= ts
if(ts.hasNext) sys.error("Builder did not consume all input.") // no lazy builders allowed
builder.result()
}
}
}

trait CollectionTypes extends BasicTypes with LowPriorityCollectionTypes {
implicit def listFormat[T](implicit bin : Format[T]) : Format[List[T]] = canBuildFormat[List, T]

Expand Down
16 changes: 16 additions & 0 deletions core/src/main/scala-2.13+/LowPriorityCollectionTypes.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package sbinary

import scala.collection.Factory

trait LowPriorityCollectionTypes extends Generic {
def canBuildFormat[CC[X] <: Iterable[X], T](implicit bin : Format[T], cbf: Factory[T, CC[T]]) : Format[CC[T]] =
new LengthEncoded[CC[T], T]{
def build(length : Int, ts : Iterator[T]) = {
val builder = cbf.newBuilder
builder.sizeHint(length)
builder ++= ts
if(ts.hasNext) sys.error("Builder did not consume all input.") // no lazy builders allowed
builder.result()
}
}
}
16 changes: 16 additions & 0 deletions core/src/main/scala-2.13-/LowPriorityCollectionTypes.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package sbinary

import scala.collection.generic.CanBuildFrom

trait LowPriorityCollectionTypes extends Generic {
def canBuildFormat[CC[X] <: Traversable[X], T](implicit bin : Format[T], cbf: CanBuildFrom[Nothing, T, CC[T]]) : Format[CC[T]] =
new LengthEncoded[CC[T], T]{
def build(length : Int, ts : Iterator[T]) = {
val builder = cbf.apply()
builder.sizeHint(length)
builder ++= ts
if(ts.hasNext) sys.error("Builder did not consume all input.") // no lazy builders allowed
builder.result()
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 3 additions & 5 deletions project/Fmpp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ object Fmpp {
def fmppConfig(c: Configuration): Seq[Setting[_]] = inConfig(c)(Seq(
sourceGenerators += fmpp,
fmpp := fmppTask.value,
scalaSource := baseDirectory.value / (Defaults.prefix(configuration.value.name) + "src"),
mappings in packageSrc := managedSources.value pair relativeTo(sourceManaged.value),
sources := managedSources.value
mappings in packageSrc ++= managedSources.value pair relativeTo(sourceManaged.value)
))
lazy val fmppTask =
Def.task {
val cp = (fullClasspath in fmppConfig).value
val r = (runner in fmpp).value
val sources = unmanagedSources.value
val srcRoot = scalaSource.value
val srcRoot = baseDirectory.value / "src" / "main" / "fmpp"
val sources = (srcRoot ** "*.scala").get
val output = sourceManaged.value
val args = fmppOptions.value
val s = streams.value
Expand Down