Skip to content

Commit

Permalink
Format build files according to the Scalafmt config (#832)
Browse files Browse the repository at this point in the history
Co-authored-by: Rui Gonçalves <ruippeixotog@gmail.com>
  • Loading branch information
jcazevedo and ruippeixotog committed Sep 22, 2020
1 parent 11ede7e commit e84b39b
Show file tree
Hide file tree
Showing 25 changed files with 212 additions and 164 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
java-version: ${{ matrix.jdk }}

- name: Check formatting
run: sbt "++${{ matrix.scala }} scalafmtCheckAll"
run: sbt "++${{ matrix.scala }} scalafmtCheckAll; scalafmtSbtCheck"

- name: Compile
run: sbt coverage "++${{ matrix.scala }} compile"
Expand Down
133 changes: 67 additions & 66 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,50 @@ import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._

organization in ThisBuild := "com.github.pureconfig"

lazy val core = (project in file("core")).
enablePlugins(BoilerplatePlugin, SbtOsgi, TutPlugin).
settings(commonSettings).
dependsOn(macros)
lazy val core = (project in file("core"))
.enablePlugins(BoilerplatePlugin, SbtOsgi, TutPlugin)
.settings(commonSettings)
.dependsOn(macros)

// Two special modules for now, since `tests` depend on them. We should improve this organization later by separating
// the test helpers (which all projects' tests should depend on) from the core+generic test implementations.
lazy val `generic-base` = (project in file("modules/generic-base")).
enablePlugins(SbtOsgi, TutPlugin).
dependsOn(core).
settings(commonSettings, tutTargetDirectory := baseDirectory.value)

lazy val generic = (project in file("modules/generic")).
enablePlugins(SbtOsgi, TutPlugin).
dependsOn(core, `generic-base`).
settings(commonSettings, tutTargetDirectory := baseDirectory.value)
lazy val `generic-base` = (project in file("modules/generic-base"))
.enablePlugins(SbtOsgi, TutPlugin)
.dependsOn(core)
.settings(commonSettings, tutTargetDirectory := baseDirectory.value)

lazy val generic = (project in file("modules/generic"))
.enablePlugins(SbtOsgi, TutPlugin)
.dependsOn(core, `generic-base`)
.settings(commonSettings, tutTargetDirectory := baseDirectory.value)
// -----

lazy val macros = (project in file("macros")).
enablePlugins(TutPlugin).
settings(commonSettings)
lazy val macros = (project in file("macros")).enablePlugins(TutPlugin).settings(commonSettings)

lazy val tests = (project in file("tests")).
enablePlugins(BoilerplatePlugin).
settings(commonSettings).
dependsOn(core, generic).
dependsOn(macros % "test->test") // provides helpers to test pureconfig macros
lazy val tests = (project in file("tests"))
.enablePlugins(BoilerplatePlugin)
.settings(commonSettings)
.dependsOn(core, generic)
.dependsOn(macros % "test->test") // provides helpers to test pureconfig macros

// aggregates pureconfig-core and pureconfig-generic with the original "pureconfig" name
lazy val bundle = (project in file("bundle")).
enablePlugins(SbtOsgi, TutPlugin).
settings(commonSettings, tutTargetDirectory := file(".")).
dependsOn(core, generic)

lazy val docs = (project in file("docs")).
enablePlugins(MicrositesPlugin).
settings(commonSettings, publishArtifact := false).
settings(docsSettings).
dependsOn(bundle)

def module(proj: Project) = proj.
enablePlugins(SbtOsgi, TutPlugin).
dependsOn(core).
dependsOn(tests % "test").
dependsOn(generic % "Tut"). // Allow auto-derivation in documentation
settings(commonSettings, tutTargetDirectory := baseDirectory.value)
lazy val bundle = (project in file("bundle"))
.enablePlugins(SbtOsgi, TutPlugin)
.settings(commonSettings, tutTargetDirectory := file("."))
.dependsOn(core, generic)

lazy val docs = (project in file("docs"))
.enablePlugins(MicrositesPlugin)
.settings(commonSettings, publishArtifact := false)
.settings(docsSettings)
.dependsOn(bundle)

def module(proj: Project) = proj
.enablePlugins(SbtOsgi, TutPlugin)
.dependsOn(core)
.dependsOn(tests % "test")
.dependsOn(generic % "Tut") // Allow auto-derivation in documentation
.settings(commonSettings, tutTargetDirectory := baseDirectory.value)

lazy val akka = module(project) in file("modules/akka")
lazy val `akka-http` = module(project) in file("modules/akka-http")
Expand All @@ -72,6 +70,7 @@ lazy val sttp = module(project) in file("modules/sttp")
lazy val yaml = module(project) in file("modules/yaml")

lazy val commonSettings = Seq(
// format: off
homepage := Some(url("https://github.com/pureconfig/pureconfig")),
licenses := Seq("Mozilla Public License, version 2.0" -> url("https://www.mozilla.org/MPL/2.0/")),

Expand All @@ -80,14 +79,13 @@ lazy val commonSettings = Seq(
Developer("leifwickland", "Leif Wickland", "leifwickland@gmail.com", url("https://github.com/leifwickland")),
Developer("jcazevedo", "Joao Azevedo", "joao.c.azevedo@gmail.com", url("https://github.com/jcazevedo")),
Developer("ruippeixotog", "Rui Gonçalves", "ruippeixotog@gmail.com", url("https://github.com/ruippeixotog")),
Developer("derekmorr", "Derek Morr", "morr.derek@gmail.com", url("https://github.com/derekmorr"))),
Developer("derekmorr", "Derek Morr", "morr.derek@gmail.com", url("https://github.com/derekmorr"))
),

crossScalaVersions := Seq(scala211, scala212, scala213),
scalaVersion := scala212,

resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")),
resolvers ++= Seq(Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")),

crossVersionSharedSources(unmanagedSourceDirectories in Compile),
crossVersionSharedSources(unmanagedSourceDirectories in Test),
Expand All @@ -107,7 +105,9 @@ lazy val commonSettings = Seq(

publishMavenStyle := true,
publishArtifact in Test := false,
publishTo := sonatypePublishToBundle.value)
publishTo := sonatypePublishToBundle.value
// format: on
)

lazy val docsSettings = Seq(
micrositeName := "PureConfig",
Expand All @@ -121,14 +121,15 @@ lazy val docsSettings = Seq(
micrositeTheme := "pattern",
micrositeHighlightTheme := "default",
micrositePalette := Map(
"brand-primary" /* link color */ -> "#ab4b4b",
"brand-secondary" /* nav/sidebar back */ -> "#4b4b4b",
"brand-tertiary" /* sidebar top back */ -> "#292929",
"gray-dark" /* section title */ -> "#453E46",
"gray" /* text color */ -> "#837F84",
"gray-light" /* star back */ -> "#E3E2E3",
"gray-lighter" /* code back */ -> "#F4F3F4",
"white-color" -> "#FFFFFF"),
"brand-primary" -> "#ab4b4b", // link color
"brand-secondary" -> "#4b4b4b", // nav/sidebar back
"brand-tertiary" -> "#292929", // sidebar top back
"gray-dark" -> "#453E46", // section title
"gray" -> "#837F84", // text color
"gray-light" -> "#E3E2E3", // star back
"gray-lighter" -> "#F4F3F4", // code back
"white-color" -> "#FFFFFF"
),
micrositeGitterChannel := false, // ugly
mdocExtraArguments += "--no-link-hygiene"
)
Expand All @@ -141,43 +142,42 @@ def crossVersionSharedSources(unmanagedSrcs: SettingKey[Seq[File]]) = {
unmanagedSrcs ++= {
val minor = CrossVersion.partialVersion(scalaVersion.value).map(_._2)
List(
if (minor.exists(_ <= 12)) unmanagedSrcs.value.map { dir => new File(dir.getPath + "-2.12-") } else Nil,
if (minor.exists(_ >= 12)) unmanagedSrcs.value.map { dir => new File(dir.getPath + "-2.12+") } else Nil,
if (minor.exists(_ <= 12)) unmanagedSrcs.value.map { dir => new File(dir.getPath + "-2.12-") }
else Nil,
if (minor.exists(_ >= 12)) unmanagedSrcs.value.map { dir => new File(dir.getPath + "-2.12+") }
else Nil
).flatten
}
}

lazy val lintFlags = {
lazy val allVersionLintFlags = List(
"-encoding", "UTF-8", // yes, this is 2 args
"-encoding",
"UTF-8", // arg for -encoding
"-feature",
"-unchecked",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen")
"-Ywarn-numeric-widen"
)

def withCommon(flags: String*) =
allVersionLintFlags ++ flags

forScalaVersions {
case (2, 11) =>
withCommon(
"-deprecation",
"-Xlint",
"-Xfatal-warnings",
"-Yno-adapted-args",
"-Ywarn-unused-import")
withCommon("-deprecation", "-Xlint", "-Xfatal-warnings", "-Yno-adapted-args", "-Ywarn-unused-import")

case (2, 12) =>
withCommon(
"-deprecation", // Either#right is deprecated on Scala 2.13
"-deprecation", // Either#right is deprecated on Scala 2.13
"-Xlint:_,-unused",
"-Xfatal-warnings",
"-Yno-adapted-args",
"-Ywarn-unused:_,-implicits") // Some implicits are intentionally used just as evidences, triggering warnings
"-Ywarn-unused:_,-implicits" // Some implicits are intentionally used just as evidences, triggering warnings
)

case (2, 13) =>
withCommon(
"-Ywarn-unused:_,-implicits")
withCommon("-Ywarn-unused:_,-implicits")

case _ =>
withCommon()
Expand Down Expand Up @@ -208,4 +208,5 @@ releaseProcess := Seq[ReleaseStep](
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges)
pushChanges
)
5 changes: 4 additions & 1 deletion core/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")
OsgiKeys.importPackage := Seq(
s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""",
"*"
)
6 changes: 4 additions & 2 deletions macros/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ name := "pureconfig-macros"

libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided,
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided)
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided
)

// Scala has excessive warnings about unused implicits on macro exps (https://github.com/scala/bug/issues/10270)
scalacOptions ~= { _.filterNot(_.contains("-Ywarn-unused")) }

developers := List(
Developer("ruippeixotog", "Rui Gonçalves", "ruippeixotog@gmail.com", url("https://github.com/ruippeixotog")))
Developer("ruippeixotog", "Rui Gonçalves", "ruippeixotog@gmail.com", url("https://github.com/ruippeixotog"))
)
11 changes: 8 additions & 3 deletions modules/akka-http/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ crossScalaVersions ~= { _.filterNot(_.startsWith("2.11")) }

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-stream" % "2.6.9" % "provided,Tut",
"com.typesafe.akka" %% "akka-http" % "10.2.0")
"com.typesafe.akka" %% "akka-http" % "10.2.0"
)

developers := List(
Developer("himanshu4141", "Himanshu Yadav", "himanshu4141@gmail.com", url("https://github.com/himanshu4141")))
Developer("himanshu4141", "Himanshu Yadav", "himanshu4141@gmail.com", url("https://github.com/himanshu4141"))
)

osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.module.akkahttp.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")
OsgiKeys.importPackage := Seq(
s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""",
"*"
)
11 changes: 7 additions & 4 deletions modules/akka/build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name := "pureconfig-akka"

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.5.31")
libraryDependencies ++= Seq("com.typesafe.akka" %% "akka-actor" % "2.5.31")

developers := List(
Developer("derekmorr", "Derek Morr", "morr.derek@gmail.com", url("https://github.com/derekmorr")),
Developer("ruippeixotog", "Rui Gonçalves", "ruippeixotog@gmail.com", url("https://github.com/ruippeixotog")))
Developer("ruippeixotog", "Rui Gonçalves", "ruippeixotog@gmail.com", url("https://github.com/ruippeixotog"))
)

osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.module.akka.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")
OsgiKeys.importPackage := Seq(
s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""",
"*"
)
14 changes: 9 additions & 5 deletions modules/circe/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ import Utilities._
name := "pureconfig-circe"

libraryDependencies ++= Seq(
"io.circe" %% "circe-core" % forScalaVersions { case (2, 11) => "0.11.2"; case _ => "0.13.0" }.value,
"io.circe" %% "circe-literal" % forScalaVersions { case (2, 11) => "0.11.2"; case _ => "0.13.0" }.value % Test,
"org.typelevel" %% "jawn-parser" % forScalaVersions { case (2, 11) => "0.14.3"; case _ => "1.0.0" }.value % Test
"io.circe" %% "circe-core" % forScalaVersions { case (2, 11) => "0.11.2"; case _ => "0.13.0" }.value,
"io.circe" %% "circe-literal" % forScalaVersions { case (2, 11) => "0.11.2"; case _ => "0.13.0" }.value % Test,
"org.typelevel" %% "jawn-parser" % forScalaVersions { case (2, 11) => "0.14.3"; case _ => "1.0.0" }.value % Test
)

developers := List(
Developer("moradology", "Nathan Zimmerman", "npzimmerman@gmail.com", url("https://github.com/moradology")))
Developer("moradology", "Nathan Zimmerman", "npzimmerman@gmail.com", url("https://github.com/moradology"))
)

osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.module.circe.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")
OsgiKeys.importPackage := Seq(
s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""",
"*"
)
8 changes: 6 additions & 2 deletions modules/cron4s/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ crossScalaVersions ~= { _.filterNot(_.startsWith("2.11")) }
libraryDependencies += "com.github.alonsodomin.cron4s" %% "cron4s-core" % "0.6.1"

developers := List(
Developer("bardurdam", "Bárður Viberg Dam", "bardurdam@gmail.com", url("https://github.com/bardurdam")))
Developer("bardurdam", "Bárður Viberg Dam", "bardurdam@gmail.com", url("https://github.com/bardurdam"))
)

osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.module.cron4s.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")
OsgiKeys.importPackage := Seq(
s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""",
"*"
)
11 changes: 7 additions & 4 deletions modules/enum/build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name := "pureconfig-enum"

libraryDependencies ++= Seq(
"org.julienrf" %% "enum" % "3.1")
libraryDependencies ++= Seq("org.julienrf" %% "enum" % "3.1")

developers := List(
Developer("melrief", "Mario Pastorelli", "pastorelli.mario@gmail.com", url("https://github.com/melrief")),
Developer("leifwickland", "Leif Wickland", "leifwickland@gmail.com", url("https://github.com/leifwickland")))
Developer("leifwickland", "Leif Wickland", "leifwickland@gmail.com", url("https://github.com/leifwickland"))
)

osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.module.enum.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")
OsgiKeys.importPackage := Seq(
s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""",
"*"
)
11 changes: 6 additions & 5 deletions modules/enumeratum/build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name := "pureconfig-enumeratum"

libraryDependencies ++= Seq(
"com.beachape" %% "enumeratum" % "1.6.1")
libraryDependencies ++= Seq("com.beachape" %% "enumeratum" % "1.6.1")

developers := List(
Developer("aeons", "Bjørn Madsen", "bm@aeons.dk", url("https://github.com/aeons")))
developers := List(Developer("aeons", "Bjørn Madsen", "bm@aeons.dk", url("https://github.com/aeons")))

osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.module.enumeratum.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")
OsgiKeys.importPackage := Seq(
s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""",
"*"
)
12 changes: 6 additions & 6 deletions modules/fs2/build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name := "pureconfig-fs2"

libraryDependencies ++= Seq(
"co.fs2" %% "fs2-core" % "2.1.0",
"co.fs2" %% "fs2-io" % "2.1.0")
libraryDependencies ++= Seq("co.fs2" %% "fs2-core" % "2.1.0", "co.fs2" %% "fs2-io" % "2.1.0")

developers := List(
Developer("keirlawson", "Keir Lawson", "keirlawson@gmail.com", url("https://github.com/keirlawson")))
developers := List(Developer("keirlawson", "Keir Lawson", "keirlawson@gmail.com", url("https://github.com/keirlawson")))

osgiSettings

OsgiKeys.exportPackage := Seq("pureconfig.module.fs2.*")
OsgiKeys.privatePackage := Seq()
OsgiKeys.importPackage := Seq(s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""", "*")
OsgiKeys.importPackage := Seq(
s"""scala.*;version="[${scalaBinaryVersion.value}.0,${scalaBinaryVersion.value}.50)"""",
"*"
)

0 comments on commit e84b39b

Please sign in to comment.