Permalink
Browse files

Minimal config of scalafmt, have not yet run it on source

  • Loading branch information...
mpilquist committed Jan 3, 2018
1 parent 5c2cd62 commit a0109358256f93f84e47713fbbef729d8bdf3a3b
Showing with 126 additions and 74 deletions.
  1. +125 −74 build.sbt
  2. +1 −0 project/plugins.sbt
View
199 build.sbt
@@ -27,14 +27,23 @@ lazy val commonSettings = Seq(
"-language:postfixOps",
"-Ypartial-unification"
) ++
(if (scalaBinaryVersion.value startsWith "2.12") List(
"-Xlint",
"-Xfatal-warnings",
"-Yno-adapted-args",
"-Ywarn-value-discard",
"-Ywarn-unused-import"
) else Nil) ++ (if (scalaBinaryVersion.value startsWith "2.11") List("-Xexperimental") else Nil), // 2.11 needs -Xexperimental to enable SAM conversion
scalacOptions in (Compile, console) ~= {_.filterNot("-Ywarn-unused-import" == _).filterNot("-Xlint" == _).filterNot("-Xfatal-warnings" == _)},
(if (scalaBinaryVersion.value startsWith "2.12")
List(
"-Xlint",
"-Xfatal-warnings",
"-Yno-adapted-args",
"-Ywarn-value-discard",
"-Ywarn-unused-import"
)
else Nil) ++ (if (scalaBinaryVersion.value startsWith "2.11")
List("-Xexperimental")
else
Nil), // 2.11 needs -Xexperimental to enable SAM conversion
scalacOptions in (Compile, console) ~= {
_.filterNot("-Ywarn-unused-import" == _)
.filterNot("-Xlint" == _)
.filterNot("-Xfatal-warnings" == _)
},
scalacOptions in (Compile, console) += "-Ydelambdafy:inline",
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value,
libraryDependencies ++= Seq(
@@ -43,7 +52,9 @@ lazy val commonSettings = Seq(
"org.scalacheck" %%% "scalacheck" % "1.13.5" % "test",
"org.typelevel" %%% "cats-laws" % "1.0.1" % "test"
),
scmInfo := Some(ScmInfo(url("https://github.com/functional-streams-for-scala/fs2"), "git@github.com:functional-streams-for-scala/fs2.git")),
scmInfo := Some(
ScmInfo(url("https://github.com/functional-streams-for-scala/fs2"),
"git@github.com:functional-streams-for-scala/fs2.git")),
homepage := Some(url("https://github.com/functional-streams-for-scala/fs2")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
initialCommands := s"""
@@ -52,19 +63,20 @@ lazy val commonSettings = Seq(
import scala.concurrent.ExecutionContext.Implicits.global
""",
doctestWithDependencies := false,
doctestTestFramework := DoctestTestFramework.ScalaTest
doctestTestFramework := DoctestTestFramework.ScalaTest,
scalafmtOnCompile := true
) ++ testSettings ++ scaladocSettings ++ publishingSettings ++ releaseSettings
lazy val testSettings = Seq(
fork in Test := ! isScalaJSProject.value,
fork in Test := !isScalaJSProject.value,
parallelExecution in Test := false,
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF"),
publishArtifact in Test := true
)
def scmBranch(v: String): String = {
val Some(ver) = Version(v)
if(ver.qualifier.exists(_ == "-SNAPSHOT"))
if (ver.qualifier.exists(_ == "-SNAPSHOT"))
// support branch (0.9.0-SNAPSHOT -> series/0.9)
s"series/${ver.copy(subversions = ver.subversions.take(1), qualifier = None).string}"
else
@@ -74,8 +86,10 @@ def scmBranch(v: String): String = {
lazy val scaladocSettings = Seq(
scalacOptions in (Compile, doc) ++= Seq(
"-doc-source-url", s"${scmInfo.value.get.browseUrl}/tree/${scmBranch(version.value)}€{FILE_PATH}.scala",
"-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath,
"-doc-source-url",
s"${scmInfo.value.get.browseUrl}/tree/${scmBranch(version.value)}€{FILE_PATH}.scala",
"-sourcepath",
baseDirectory.in(LocalRootProject).value.getAbsolutePath,
"-implicits",
"-implicits-sound-shadowing",
"-implicits-show-all"
@@ -95,9 +109,15 @@ lazy val publishingSettings = Seq(
credentials ++= (for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq,
} yield
Credentials("Sonatype Nexus Repository Manager",
"oss.sonatype.org",
username,
password)).toSeq,
publishMavenStyle := true,
pomIncludeRepository := { _ => false },
pomIncludeRepository := { _ =>
false
},
pomExtra := {
<developers>
{for ((username, name) <- contributors) yield
@@ -116,7 +136,9 @@ lazy val publishingSettings = Seq(
override def transform(n: Node) =
if (f(n)) NodeSeq.Empty else n
}
val stripTestScope = stripIf { n => n.label == "dependency" && (n \ "scope").text == "test" }
val stripTestScope = stripIf { n =>
n.label == "dependency" && (n \ "scope").text == "test"
}
new RuleTransformer(stripTestScope).transform(node)(0)
}
)
@@ -136,7 +158,8 @@ lazy val commonJsSettings = Seq(
jsEnv := new org.scalajs.jsenv.nodejs.NodeJSEnv(),
scalacOptions in Compile += {
val dir = project.base.toURI.toString.replaceFirst("[^/]+/?$", "")
val url = "https://raw.githubusercontent.com/functional-streams-for-scala/fs2"
val url =
"https://raw.githubusercontent.com/functional-streams-for-scala/fs2"
s"-P:scalajs:mapSourceURI:$dir->$url/${scmBranch(version.value)}/"
}
)
@@ -158,7 +181,7 @@ lazy val mimaSettings = Seq(
organization.value % (normalizedName.value + "_" + scalaBinaryVersion.value) % pv
}.toSet,
mimaBinaryIssueFilters ++= Seq(
)
)
)
def previousVersion(currentVersion: String): Option[String] = {
@@ -168,111 +191,139 @@ def previousVersion(currentVersion: String): Option[String] = {
else Some(s"$x.$y.${z.toInt - 1}")
}
lazy val root = project
.in(file("."))
.settings(commonSettings)
.settings(noPublish)
.aggregate(coreJVM, coreJS, io, scodecJVM, scodecJS, benchmark)
lazy val root = project.in(file(".")).
settings(commonSettings).
settings(noPublish).
aggregate(coreJVM, coreJS, io, scodecJVM, scodecJS, benchmark)
lazy val core = crossProject.in(file("core")).
settings(commonSettings: _*).
settings(
lazy val core = crossProject
.in(file("core"))
.settings(commonSettings: _*)
.settings(
name := "fs2-core",
libraryDependencies += "org.typelevel" %%% "cats-effect" % "0.8"
).
jsSettings(commonJsSettings: _*)
libraryDependencies += "org.typelevel" %%% "cats-effect" % "0.8",
sourceDirectories in (Compile, scalafmt) ++= Seq(
baseDirectory.value / "../shared/src/main/scala",
baseDirectory.value / "../js/src/main/scala"
)
)
.jsSettings(commonJsSettings: _*)
lazy val coreJVM = core.jvm.enablePlugins(SbtOsgi).
settings(
lazy val coreJVM = core.jvm
.enablePlugins(SbtOsgi)
.settings(
OsgiKeys.exportPackage := Seq("fs2.*"),
OsgiKeys.privatePackage := Seq(),
OsgiKeys.importPackage := {
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
Seq(s"""scala.*;version="[$major.$minor,$major.${minor+1})"""", "*")
Seq(s"""scala.*;version="[$major.$minor,$major.${minor + 1})"""", "*")
},
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
OsgiKeys.additionalHeaders := Map(
"-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings,
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, minor)) if minor >= 13 =>
Seq("org.scala-lang.modules" %% "scala-parallel-collections" % "0.1.2" % "test")
Seq(
"org.scala-lang.modules" %% "scala-parallel-collections" % "0.1.2" % "test")
case _ =>
Seq()
}
}
).
settings(mimaSettings)
)
.settings(mimaSettings)
lazy val coreJS = core.js.disablePlugins(DoctestPlugin, MimaPlugin)
lazy val io = project.in(file("io")).
enablePlugins(SbtOsgi).
settings(commonSettings).
settings(mimaSettings).
settings(
lazy val io = project
.in(file("io"))
.enablePlugins(SbtOsgi)
.settings(commonSettings)
.settings(mimaSettings)
.settings(
name := "fs2-io",
OsgiKeys.exportPackage := Seq("fs2.io.*"),
OsgiKeys.privatePackage := Seq(),
OsgiKeys.importPackage := {
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
Seq(s"""scala.*;version="[$major.$minor,$major.${minor+1})"""", """fs2.*;version="${Bundle-Version}"""", "*")
Seq(s"""scala.*;version="[$major.$minor,$major.${minor + 1})"""",
"""fs2.*;version="${Bundle-Version}"""",
"*")
},
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
OsgiKeys.additionalHeaders := Map(
"-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings
).dependsOn(coreJVM % "compile->compile;test->test")
)
.dependsOn(coreJVM % "compile->compile;test->test")
lazy val scodec = crossProject.in(file("scodec")).
settings(commonSettings).
settings(
lazy val scodec = crossProject
.in(file("scodec"))
.settings(commonSettings)
.settings(
name := "fs2-scodec",
libraryDependencies += "org.scodec" %%% "scodec-bits" % "1.1.5"
).dependsOn(core % "compile->compile;test->test")
libraryDependencies += "org.scodec" %%% "scodec-bits" % "1.1.5",
sourceDirectories in (Compile, scalafmt) ++= Seq(
baseDirectory.value / "../shared/src/main/scala",
baseDirectory.value / "../js/src/main/scala"
)
)
.dependsOn(core % "compile->compile;test->test")
.jsSettings(commonJsSettings: _*)
lazy val scodecJVM = scodec.jvm.
enablePlugins(SbtOsgi).
settings(mimaSettings).
settings(
lazy val scodecJVM = scodec.jvm
.enablePlugins(SbtOsgi)
.settings(mimaSettings)
.settings(
OsgiKeys.exportPackage := Seq("fs2.interop.scodec.*"),
OsgiKeys.privatePackage := Seq(),
OsgiKeys.importPackage := {
val Some((major, minor)) = CrossVersion.partialVersion(scalaVersion.value)
Seq(s"""scala.*;version="[$major.$minor,$major.${minor+1})"""", """fs2.*;version="${Bundle-Version}"""", "*")
Seq(s"""scala.*;version="[$major.$minor,$major.${minor + 1})"""",
"""fs2.*;version="${Bundle-Version}"""",
"*")
},
OsgiKeys.additionalHeaders := Map("-removeheaders" -> "Include-Resource,Private-Package"),
OsgiKeys.additionalHeaders := Map(
"-removeheaders" -> "Include-Resource,Private-Package"),
osgiSettings
)
lazy val scodecJS = scodec.js.disablePlugins(DoctestPlugin, MimaPlugin)
lazy val benchmarkMacros = project.in(file("benchmark-macros")).
disablePlugins(MimaPlugin).
settings(commonSettings).
settings(noPublish).
settings(
lazy val benchmarkMacros = project
.in(file("benchmark-macros"))
.disablePlugins(MimaPlugin)
.settings(commonSettings)
.settings(noPublish)
.settings(
name := "fs2-benchmark-macros",
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch),
addCompilerPlugin(
"org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch),
libraryDependencies += scalaOrganization.value % "scala-reflect" % scalaVersion.value
)
lazy val benchmark = project.in(file("benchmark")).
disablePlugins(MimaPlugin).
settings(commonSettings).
settings(noPublish).
settings(
lazy val benchmark = project
.in(file("benchmark"))
.disablePlugins(MimaPlugin)
.settings(commonSettings)
.settings(noPublish)
.settings(
name := "fs2-benchmark"
)
.settings(
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch),
addCompilerPlugin(
"org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch),
libraryDependencies += scalaOrganization.value % "scala-reflect" % scalaVersion.value
)
.enablePlugins(JmhPlugin)
.dependsOn(io, benchmarkMacros)
lazy val docs = project.in(file("docs")).
enablePlugins(TutPlugin).
settings(commonSettings).
settings(
lazy val docs = project
.in(file("docs"))
.enablePlugins(TutPlugin)
.settings(commonSettings)
.settings(
name := "fs2-docs",
tutSourceDirectory := file("docs") / "src",
tutTargetDirectory := file("docs"),
scalacOptions ~= {_.filterNot("-Ywarn-unused-import" == _)}
).dependsOn(coreJVM, io)
scalacOptions ~= { _.filterNot("-Ywarn-unused-import" == _) }
)
.dependsOn(coreJVM, io)
View
@@ -9,3 +9,4 @@ addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.5.2")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.27")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.20")
addSbtPlugin("com.lucidchart" % "sbt-scalafmt-coursier" % "1.15")

0 comments on commit a010935

Please sign in to comment.