Skip to content

Commit 735a06f

Browse files
authored
Merge pull request #26 from eed3si9n/wip/bump
Bump build to sbt 1.3.9
2 parents 84a37ca + 0251b47 commit 735a06f

File tree

11 files changed

+229
-108
lines changed

11 files changed

+229
-108
lines changed

.scalafmt.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version = 2.3.2
2+
edition = 2019-10
13
maxColumn = 100
24
project.git = true
35

@@ -7,3 +9,16 @@ docstrings = JavaDoc
79

810
# This also seems more idiomatic to include whitespace in import x.{ yyy }
911
spaces.inImportCurlyBraces = true
12+
13+
# This also seems more idiomatic to include whitespace in import x.{ yyy }
14+
spaces.inImportCurlyBraces = true
15+
16+
# This is more idiomatic Scala.
17+
# http://docs.scala-lang.org/style/indentation.html#methods-with-numerous-arguments
18+
align.openParenCallSite = false
19+
align.openParenDefnSite = false
20+
21+
# For better code clarity
22+
danglingParentheses = true
23+
24+
trailingCommas = preserve

.travis.yml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
sudo: false
2-
31
language: scala
42

5-
script:
6-
- sbt ++$TRAVIS_SCALA_VERSION test scalafmt::test test:scalafmt::test sbt:scalafmt::test mimaReportBinaryIssues
3+
matrix:
4+
include:
5+
- env: ADOPTOPENJDK=11
6+
script: sbt ++2.12.11! test
7+
- env: ADOPTOPENJDK=8
8+
script: sbt scalafmtCheckAll scalafmtSbtCheck mimaReportBinaryIssues +test
9+
10+
before_install:
11+
# adding $HOME/.sdkman to cache would create an empty directory, which interferes with the initial installation
12+
- "[[ -d /home/travis/.sdkman/ ]] && [[ -d /home/travis/.sdkman/bin/ ]] || rm -rf /home/travis/.sdkman/"
13+
- curl -sL https://get.sdkman.io | bash
14+
- echo sdkman_auto_answer=true > /home/travis/.sdkman/etc/config
15+
- echo sdkman_auto_selfupdate=true >> $HOME/.sdkman/etc/config
16+
- source "/home/travis/.sdkman/bin/sdkman-init.sh"
717

8-
scala:
9-
- 2.10.7
10-
- 2.11.12
11-
- 2.12.8
12-
- 2.13.0
18+
install:
19+
- sdk install java $(sdk list java | grep -o "$ADOPTOPENJDK\.[0-9\.]*hs-adpt" | head -1) || true
20+
- unset _JAVA_OPTIONS
21+
- java -Xmx32m -version
22+
- unset SBT_OPTS
23+
- unset JAVA_OPTS
1324

14-
jdk:
15-
- openjdk8
25+
before_cache:
26+
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete
27+
- find $HOME/.sbt -name "*.lock" -delete
1628

17-
matrix:
18-
include:
19-
- jdk: openjdk11
20-
scala: 2.12.8
29+
cache:
30+
directories:
31+
- $HOME/.cache/coursier
32+
- $HOME/.ivy2/cache
33+
- $HOME/.sbt/boot
34+
- $HOME/.sdkman

build.sbt

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,74 @@
1-
lazy val scalacheck = "org.scalacheck" %% "scalacheck" % "1.14.3"
2-
def scalaXmlDep(scalaV: String): List[ModuleID] =
3-
CrossVersion.partialVersion(scalaV) match {
4-
case Some((2, minor)) if minor <= 10 =>
5-
Nil
6-
case Some((2, 11 | 12)) =>
7-
List("org.scala-lang.modules" %% "scala-xml" % "1.0.6")
8-
case _ =>
9-
List("org.scala-lang.modules" %% "scala-xml" % "1.2.0")
10-
}
1+
import Dependencies._
2+
3+
ThisBuild / organization := "org.scala-sbt"
4+
ThisBuild / organizationHomepage := Some(url("http://scala-sbt.org/"))
5+
ThisBuild / homepage := Some(url("https://github.com/sbt/sbinary"))
6+
ThisBuild / version := "0.5.1-SNAPSHOT"
7+
ThisBuild / scalaVersion := scala212
8+
ThisBuild / crossScalaVersions := Seq(scala210, scala211, scala212, scala213)
9+
ThisBuild / bintrayPackage := "sbinary"
10+
ThisBuild / developers := List(
11+
Developer(
12+
"drmaciver",
13+
"David R. MacIver",
14+
"@drmaciver",
15+
url("https://github.com/DRMacIver")
16+
),
17+
Developer("harrah", "Mark Harrah", "@harrah", url("https://github.com/harrah")),
18+
Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("https://github.com/eed3si9n"))
19+
)
20+
ThisBuild / description := "Library for describing binary formats for Scala types"
21+
ThisBuild / licenses := Seq("MIT" -> new URL("https://github.com/sbt/sbinary/blob/master/LICENSE"))
22+
ThisBuild / scmInfo := Some(
23+
ScmInfo(url("https://github.com/sbt/sbinary"), "git@github.com:sbt/sbinary.git")
24+
)
25+
26+
lazy val root = (project in file("."))
27+
.aggregate(core, treeExample)
28+
.settings(nocomma {
29+
name := "SBinary Root"
30+
publish / skip := true
31+
mimaPreviousArtifacts := Set.empty
32+
})
33+
34+
lazy val core = (project in file("core"))
35+
.settings(nocomma {
36+
name := "SBinary"
37+
38+
mimaPreviousArtifacts := {
39+
Set.empty
40+
}
41+
libraryDependencies += scalacheck % Test
42+
libraryDependencies ++= scalaVersion(scalaXmlDep).value
43+
Compile / unmanagedSourceDirectories += {
44+
val base = (Compile / scalaSource).value.getParentFile
45+
CrossVersion.partialVersion(scalaVersion.value) match {
46+
case Some((2, v)) if v >= 13 =>
47+
base / s"scala-2.13+"
48+
case _ =>
49+
base / s"scala-2.13-"
50+
}
51+
}
52+
Compile / unmanagedResources += (baseDirectory map { _ / "LICENSE" }).value
53+
mimaPreviousArtifacts := {
54+
val versions = Seq("0.5.0")
55+
val crossVersion = if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled
56+
versions.map(v => organization.value % moduleName.value % v cross crossVersion).toSet
57+
},
58+
})
59+
.settings(
60+
relaxOldScala,
61+
Fmpp.templateSettings
62+
)
63+
64+
lazy val treeExample = (project in (file("examples") / "bt"))
65+
.dependsOn(core)
66+
.settings(nocomma {
67+
name := "SBinary Tree Example"
68+
publish / skip := true
69+
mimaPreviousArtifacts := Set.empty
70+
})
71+
.settings(relaxOldScala)
1172

1273
def relaxOldScala: Seq[Setting[_]] = Seq(
1374
scalacOptions := {
@@ -29,64 +90,3 @@ def relaxOldScala: Seq[Setting[_]] = Seq(
2990
}
3091
}
3192
)
32-
33-
lazy val root = (project in file("."))
34-
.aggregate(core, treeExample)
35-
.settings(
36-
inThisBuild(
37-
Seq(
38-
organization := "org.scala-sbt",
39-
organizationHomepage := Some(url("http://scala-sbt.org/")),
40-
homepage := Some(url("https://github.com/sbt/sbinary")),
41-
version := "0.5.1-SNAPSHOT",
42-
scalaVersion := "2.12.7",
43-
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.7", "2.13.0"),
44-
bintrayPackage := "sbinary",
45-
developers := List(
46-
Developer(
47-
"drmaciver",
48-
"David R. MacIver",
49-
"@drmaciver",
50-
url("https://github.com/DRMacIver")
51-
),
52-
Developer("harrah", "Mark Harrah", "@harrah", url("https://github.com/harrah")),
53-
Developer("eed3si9n", "Eugene Yokota", "@eed3si9n", url("https://github.com/eed3si9n"))
54-
),
55-
description := "Library for describing binary formats for Scala types",
56-
licenses := Seq("MIT" -> new URL("https://github.com/sbt/sbinary/blob/master/LICENSE")),
57-
scmInfo := Some(
58-
ScmInfo(url("https://github.com/sbt/sbinary"), "git@github.com:sbt/sbinary.git")
59-
)
60-
)),
61-
name := "SBinary Parent",
62-
skip in publish := true
63-
)
64-
65-
lazy val core = (project in file("core")).settings(
66-
name := "SBinary",
67-
relaxOldScala,
68-
Fmpp.templateSettings,
69-
mimaPreviousArtifacts := {
70-
Set.empty
71-
},
72-
libraryDependencies += scalacheck % Test,
73-
libraryDependencies ++= scalaVersion(scalaXmlDep).value,
74-
unmanagedSourceDirectories in Compile += {
75-
val base = (scalaSource in Compile).value.getParentFile
76-
CrossVersion.partialVersion(scalaVersion.value) match {
77-
case Some((2, v)) if v >= 13 =>
78-
base / s"scala-2.13+"
79-
case _ =>
80-
base / s"scala-2.13-"
81-
}
82-
},
83-
unmanagedResources in Compile += (baseDirectory map { _ / "LICENSE" }).value
84-
)
85-
86-
lazy val treeExample = (project in (file("examples") / "bt"))
87-
.dependsOn(core)
88-
.settings(
89-
name := "SBinary Tree Example",
90-
relaxOldScala,
91-
skip in publish := true
92-
)

core/src/main/scala-2.13-/LowPriorityCollectionTypes.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ package sbinary
33
import scala.collection.generic.CanBuildFrom
44

55
trait LowPriorityCollectionTypes extends Generic {
6-
def canBuildFormat[CC[X] <: Traversable[X], T](implicit bin : Format[T], cbf: CanBuildFrom[Nothing, T, CC[T]]) : Format[CC[T]] =
7-
new LengthEncoded[CC[T], T]{
8-
def build(length : Int, ts : Iterator[T]) = {
6+
def canBuildFormat[CC[X] <: Traversable[X], T](
7+
implicit bin: Format[T],
8+
cbf: CanBuildFrom[Nothing, T, CC[T]]
9+
): Format[CC[T]] =
10+
new LengthEncoded[CC[T], T] {
11+
def build(length: Int, ts: Iterator[T]) = {
912
val builder = cbf.apply()
1013
builder.sizeHint(length)
1114
builder ++= ts
12-
if(ts.hasNext) sys.error("Builder did not consume all input.") // no lazy builders allowed
15+
if (ts.hasNext) sys.error("Builder did not consume all input.") // no lazy builders allowed
1316
builder.result()
1417
}
1518
}

core/src/test/scala/binaryTests.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,14 @@ object FormatTests extends Properties("Formats") {
135135
arb: Arbitrary[T],
136136
equal: Equal[T]
137137
) =
138-
forAll((x: T) =>
139-
try { equal(x, fromByteArray[T](toByteArray(x))) } catch {
140-
case (e: Throwable) => e.printStackTrace; false
141-
})
138+
forAll(
139+
(x: T) =>
140+
try {
141+
equal(x, fromByteArray[T](toByteArray(x)))
142+
} catch {
143+
case (e: Throwable) => e.printStackTrace; false
144+
}
145+
)
142146

143147
def formatSpec[T](name: String)(
144148
implicit

project/Dependencies.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import sbt._
2+
3+
object Dependencies {
4+
val scala210 = "2.10.7"
5+
val scala211 = "2.11.12"
6+
val scala212 = "2.12.11"
7+
val scala213 = "2.13.1"
8+
9+
val scalacheck = "org.scalacheck" %% "scalacheck" % "1.14.3"
10+
def scalaXmlDep(scalaV: String): List[ModuleID] =
11+
CrossVersion.partialVersion(scalaV) match {
12+
case Some((2, minor)) if minor <= 10 =>
13+
Nil
14+
case Some((2, 11 | 12)) =>
15+
List("org.scala-lang.modules" %% "scala-xml" % "1.0.6")
16+
case _ =>
17+
List("org.scala-lang.modules" %% "scala-xml" % "1.2.0")
18+
}
19+
}

project/Fmpp.scala

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,32 @@ import sbt._
22
import Keys._
33

44
object Fmpp {
5+
56
/*** Templating **/
67
lazy val fmpp = TaskKey[Seq[File]]("fmpp")
78
lazy val fmppOptions = SettingKey[Seq[String]]("fmpp-options")
8-
lazy val fmppConfig = config("fmpp") hide
9+
lazy val FmppConfig = config("fmpp") hide
910

1011
lazy val templateSettings = fmppConfig(Test) ++ fmppConfig(Compile) ++ templateBase
1112
lazy val templateBase = Seq(
12-
libraryDependencies += "net.sourceforge.fmpp" % "fmpp" % "0.9.16" % fmppConfig.name,
13-
ivyConfigurations += fmppConfig,
13+
libraryDependencies += "net.sourceforge.fmpp" % "fmpp" % "0.9.16" % FmppConfig,
14+
ivyConfigurations += FmppConfig,
1415
fmppOptions := "--ignore-temporary-files" :: Nil,
15-
fullClasspath in fmppConfig := update.value select configurationFilter(fmppConfig.name) map Attributed.blank
16+
fullClasspath in FmppConfig := update.value select configurationFilter(FmppConfig.name) map Attributed.blank
1617
)
1718

18-
def fmppConfig(c: Configuration): Seq[Setting[_]] = inConfig(c)(Seq(
19-
sourceGenerators += fmpp,
20-
fmpp := fmppTask.value,
21-
mappings in packageSrc ++= managedSources.value pair relativeTo(sourceManaged.value)
22-
))
19+
import sbt.io.Path._
20+
def fmppConfig(c: Configuration): Seq[Setting[_]] =
21+
inConfig(c)(
22+
Seq(
23+
sourceGenerators += fmpp,
24+
fmpp := fmppTask.value,
25+
mappings in packageSrc ++= managedSources.value pair relativeTo(sourceManaged.value)
26+
)
27+
)
2328
lazy val fmppTask =
2429
Def.task {
25-
val cp = (fullClasspath in fmppConfig).value
30+
val cp = (fullClasspath in FmppConfig).value
2631
val r = (runner in fmpp).value
2732
val srcRoot = baseDirectory.value / "src" / "main" / "fmpp"
2833
val sources = (srcRoot ** "*.scala").get
@@ -31,7 +36,7 @@ object Fmpp {
3136
val s = streams.value
3237
IO.delete(output)
3338
val arguments = "-U" +: "all" +: "-S" +: srcRoot.getAbsolutePath +: "-O" +: output.getAbsolutePath +: (args ++ sources.getPaths)
34-
r.run("fmpp.tools.CommandLine", cp.files, arguments, s.log).foreach(sys.error)
39+
r.run("fmpp.tools.CommandLine", cp.files, arguments, s.log) // .foreach(sys.error)
3540
(output ** "*.scala").get
3641
}
3742
}

project/HouseRulesPlugins.scala

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import sbt._
2+
import Keys._
3+
import bintray.BintrayPlugin
4+
import bintray.BintrayPlugin.autoImport._
5+
6+
object HouseRulesPlugin extends AutoPlugin {
7+
override def requires = plugins.JvmPlugin && BintrayPlugin
8+
override def trigger = allRequirements
9+
10+
override def buildSettings: Seq[Def.Setting[_]] = baseBuildSettings
11+
override def projectSettings: Seq[Def.Setting[_]] = baseSettings
12+
13+
lazy val baseBuildSettings: Seq[Def.Setting[_]] = Seq(
14+
bintrayOrganization := Some("sbt"),
15+
bintrayRepository := "maven-releases",
16+
)
17+
18+
lazy val baseSettings: Seq[Def.Setting[_]] = Seq(
19+
bintrayPackage := (ThisBuild / bintrayPackage).value,
20+
bintrayRepository := (ThisBuild / bintrayRepository).value,
21+
scalacOptions ++= Seq("-encoding", "utf8"),
22+
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xlint"),
23+
scalacOptions += "-language:higherKinds",
24+
scalacOptions += "-language:implicitConversions",
25+
scalacOptions ++= "-Xfuture".ifScala213OrMinus.value.toList,
26+
scalacOptions += "-Xlint",
27+
scalacOptions ++= "-Xfatal-warnings"
28+
.ifScala(v => {
29+
sys.props.get("sbt.build.fatal") match {
30+
case Some(_) => java.lang.Boolean.getBoolean("sbt.build.fatal")
31+
case _ => v == 12
32+
}
33+
})
34+
.value
35+
.toList,
36+
scalacOptions ++= "-Yinline-warnings".ifScala211OrMinus.value.toList,
37+
scalacOptions ++= "-Yno-adapted-args".ifScala212OrMinus.value.toList,
38+
scalacOptions += "-Ywarn-dead-code",
39+
scalacOptions += "-Ywarn-numeric-widen",
40+
scalacOptions += "-Ywarn-value-discard",
41+
scalacOptions ++= "-Ywarn-unused-import".ifScala(v => 11 <= v && v <= 12).value.toList
42+
) ++ Seq(Compile, Test).flatMap(
43+
c => scalacOptions in (c, console) --= Seq("-Ywarn-unused-import", "-Xlint")
44+
)
45+
46+
private def scalaPartV = Def setting (CrossVersion partialVersion scalaVersion.value)
47+
48+
private implicit final class AnyWithIfScala[A](val __x: A) {
49+
def ifScala(p: Long => Boolean) =
50+
Def setting (scalaPartV.value collect { case (2, y) if p(y) => __x })
51+
def ifScalaLte(v: Long) = ifScala(_ <= v)
52+
def ifScalaGte(v: Long) = ifScala(_ >= v)
53+
def ifScala211OrMinus = ifScalaLte(11)
54+
def ifScala211OrPlus = ifScalaGte(11)
55+
def ifScala212OrMinus = ifScalaLte(12)
56+
def ifScala213OrMinus = ifScalaLte(13)
57+
}
58+
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.18
1+
sbt.version=1.3.9

project/houserules.sbt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)