Skip to content

Commit

Permalink
Refactoring build.sbt
Browse files Browse the repository at this point in the history
  • Loading branch information
geirolz committed May 26, 2024
1 parent 3e54a07 commit 15971cc
Showing 1 changed file with 140 additions and 131 deletions.
271 changes: 140 additions & 131 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,32 +1,151 @@
import Dependencies._
import Dependencies.*
import microsites.ExtraMdFileConfig

ThisBuild / name := """fs2-rabbit"""
ThisBuild / scalaVersion := "2.13.12"
ThisBuild / crossScalaVersions := List("2.12.18", "2.13.12", "3.3.1")
ThisBuild / versionScheme := Some("semver-spec")
ThisBuild / organization := "dev.profunktor"
ThisBuild / homepage := Some(url("https://fs2-rabbit.profunktor.dev/"))
ThisBuild / licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))
ThisBuild / developers := List(
Developer(
"gvolpe",
"Gabriel Volpe",
"[email protected]",
url("https://gvolpe.github.io")
)
lazy val noPublish = List(
publish := {},
publishLocal := {},
publishArtifact := false,
publish / skip := true,
crossScalaVersions := Nil
)

lazy val commonSettings = List(
name := "fs2-rabbit",
scalaVersion := "2.13.12",
crossScalaVersions := List("2.12.18", "2.13.12", "3.3.1"),
versionScheme := Some("semver-spec"),
organization := "dev.profunktor",
organizationName := "ProfunKtor",
startYear := Some(2017),
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("https://fs2-rabbit.profunktor.dev/")),
headerLicense := Some(HeaderLicense.ALv2(s"${startYear.value.get}-${java.time.Year.now}", "ProfunKtor")),
Compile / doc / scalacOptions ++= List("-no-link-warnings"),
scalacOptions ++= scalaOptions(scalaVersion.value),
scalacOptions --= List("-Wunused:params", "-Xfatal-warnings"),
libraryDependencies ++= commonDependencies(scalaVersion.value),
resolvers += "Apache public" at "https://repository.apache.org/content/groups/public/",
scalafmtOnCompile := true,
mimaPreviousArtifacts := previousStableVersion.value.map(organization.value %% moduleName.value % _).toSet
)

publish / skip := true
lazy val `fs2-rabbit-root` =
project
.in(file("."))
.disablePlugins(MimaPlugin)
.settings(commonSettings)
.settings(
inThisBuild(
developers := List(
Developer(
"gvolpe",
"Gabriel Volpe",
"[email protected]",
url("https://gvolpe.github.io")
)
)
)
)
.aggregate(`fs2-rabbit`, `fs2-rabbit-circe`, tests, examples, microsite, `fs2-rabbit-testkit`)
.settings(noPublish)

lazy val `fs2-rabbit` =
project
.in(file("core"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= CoreDependencies(scalaVersion.value))
.settings(Test / parallelExecution := false)
.enablePlugins(AutomateHeaderPlugin)

lazy val `fs2-rabbit-circe` =
project
.in(file("json-circe"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= JsonDependencies(scalaVersion.value))
.settings(Test / parallelExecution := false)
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`fs2-rabbit`)

lazy val tests =
project
.in(file("tests"))
.settings(commonSettings: _*)
.settings(noPublish)
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(MimaPlugin)
.settings(libraryDependencies ++= TestsDependencies(scalaVersion.value))
.settings(Test / parallelExecution := false)
.dependsOn(`fs2-rabbit`, `fs2-rabbit-testkit`)

lazy val examples =
project
.in(file("examples"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= ExamplesDependencies(scalaVersion.value))
.settings(noPublish)
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(MimaPlugin)
.dependsOn(`fs2-rabbit`, `fs2-rabbit-circe`)

lazy val `fs2-rabbit-testkit` =
project
.in(file("testkit"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= TestKitDependencies(scalaVersion.value))
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`fs2-rabbit`)

lazy val microsite =
project
.in(file("site"))
.enablePlugins(MicrositesPlugin)
.disablePlugins(MimaPlugin)
.settings(commonSettings: _*)
.settings(noPublish)
.settings(
micrositeName := "Fs2 Rabbit",
micrositeDescription := "RabbitMQ stream-based client",
micrositeAuthor := "ProfunKtor",
micrositeGithubOwner := "profunktor",
micrositeGithubRepo := "fs2-rabbit",
micrositeBaseUrl := "",
micrositeExtraMdFiles := Map(
file("README.md") -> ExtraMdFileConfig(
"index.md",
"home",
Map("title" -> "Home", "position" -> "0")
),
file("CODE_OF_CONDUCT.md") -> ExtraMdFileConfig(
"CODE_OF_CONDUCT.md",
"page",
Map("title" -> "Code of Conduct")
)
),
micrositeExtraMdFilesOutput := (Compile / resourceManaged).value / "jekyll",
micrositeGitterChannel := true,
micrositeGitterChannelUrl := "profunktor-dev/fs2-rabbit",
micrositePushSiteWith := GitHub4s,
micrositeGithubToken := sys.env.get("GITHUB_TOKEN"),
scalacOptions --= List(
"-Werror",
"-Xfatal-warnings",
"-Ywarn-unused-import",
"-Ywarn-numeric-widen",
"-Ywarn-dead-code",
"-Xlint:-missing-interpolator,_"
)
)
.dependsOn(`fs2-rabbit`, `fs2-rabbit-circe`, `examples`)

def scalaOptions(v: String) =
// options
def scalaOptions(v: String): List[String] =
CrossVersion.partialVersion(v) match {
case Some((2, 13)) => List.empty[String]
case Some((3, _)) => List("-source:3.0-migration")
case _ => List("-Xmax-classfile-name", "100")
}

def commonDependencies(v: String) =
def commonDependencies(v: String): List[ModuleID] =
List(
Libraries.amqpClient,
Libraries.catsEffect,
Expand All @@ -44,21 +163,6 @@ def commonDependencies(v: String) =
)
})

val commonSettings = List(
organizationName := "ProfunKtor",
startYear := Some(2017),
licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("https://fs2-rabbit.profunktor.dev/")),
headerLicense := Some(HeaderLicense.ALv2(s"${startYear.value.get}-${java.time.Year.now}", "ProfunKtor")),
Compile / doc / scalacOptions ++= List("-no-link-warnings"),
scalacOptions ++= scalaOptions(scalaVersion.value),
scalacOptions --= List("-Wunused:params", "-Xfatal-warnings"),
libraryDependencies ++= commonDependencies(scalaVersion.value),
resolvers += "Apache public" at "https://repository.apache.org/content/groups/public/",
scalafmtOnCompile := true,
mimaPreviousArtifacts := previousStableVersion.value.map(organization.value %% moduleName.value % _).toSet
)

def CoreDependencies(scalaVersionStr: String): List[ModuleID] =
List(
Libraries.scodecCats,
Expand All @@ -75,14 +179,15 @@ def JsonDependencies(scalaVersionStr: String): List[ModuleID] =
def ExamplesDependencies(scalaVersionStr: String): List[ModuleID] =
List(
Libraries.logback % "runtime",
// Libraries.monix,
// Libraries.monix,
Libraries.zioCore,
Libraries.zioCats,
Libraries.dropwizard,
Libraries.dropwizardJmx
)

def TestKitDependencies(scalaVersionStr: String): List[ModuleID] = List(Libraries.scalaCheck)
def TestKitDependencies(scalaVersionStr: String): List[ModuleID] =
List(Libraries.scalaCheck)

def TestsDependencies(scalaVersionStr: String): List[ModuleID] =
List(
Expand All @@ -91,101 +196,5 @@ def TestsDependencies(scalaVersionStr: String): List[ModuleID] =
Libraries.catsKernelLaws % Test
)

lazy val noPublish = List(
publish := {},
publishLocal := {},
publishArtifact := false,
publish / skip := true,
crossScalaVersions := Nil
)

lazy val `fs2-rabbit-root` = project
.in(file("."))
.disablePlugins(MimaPlugin)
.aggregate(`fs2-rabbit`, `fs2-rabbit-circe`, tests, examples, microsite, `fs2-rabbit-testkit`)
.settings(noPublish)

lazy val `fs2-rabbit` = project
.in(file("core"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= CoreDependencies(scalaVersion.value))
.settings(Test / parallelExecution := false)
.enablePlugins(AutomateHeaderPlugin)

lazy val `fs2-rabbit-circe` = project
.in(file("json-circe"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= JsonDependencies(scalaVersion.value))
.settings(Test / parallelExecution := false)
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`fs2-rabbit`)

lazy val tests = project
.in(file("tests"))
.settings(commonSettings: _*)
.settings(noPublish)
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(MimaPlugin)
.settings(libraryDependencies ++= TestsDependencies(scalaVersion.value))
.settings(Test / parallelExecution := false)
.dependsOn(`fs2-rabbit`, `fs2-rabbit-testkit`)

lazy val examples = project
.in(file("examples"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= ExamplesDependencies(scalaVersion.value))
.settings(noPublish)
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(MimaPlugin)
.dependsOn(`fs2-rabbit`, `fs2-rabbit-circe`)

lazy val `fs2-rabbit-testkit` = project
.in(file("testkit"))
.settings(commonSettings: _*)
.settings(libraryDependencies ++= TestKitDependencies(scalaVersion.value))
.enablePlugins(AutomateHeaderPlugin)
.dependsOn(`fs2-rabbit`)

lazy val microsite = project
.in(file("site"))
.enablePlugins(MicrositesPlugin)
.disablePlugins(MimaPlugin)
.settings(commonSettings: _*)
.settings(noPublish)
.settings(
micrositeName := "Fs2 Rabbit",
micrositeDescription := "RabbitMQ stream-based client",
micrositeAuthor := "ProfunKtor",
micrositeGithubOwner := "profunktor",
micrositeGithubRepo := "fs2-rabbit",
micrositeBaseUrl := "",
micrositeExtraMdFiles := Map(
file("README.md") -> ExtraMdFileConfig(
"index.md",
"home",
Map("title" -> "Home", "position" -> "0")
),
file("CODE_OF_CONDUCT.md") -> ExtraMdFileConfig(
"CODE_OF_CONDUCT.md",
"page",
Map("title" -> "Code of Conduct")
)
),
micrositeExtraMdFilesOutput := (Compile / resourceManaged).value / "jekyll",
micrositeGitterChannel := true,
micrositeGitterChannelUrl := "profunktor-dev/fs2-rabbit",
micrositePushSiteWith := GitHub4s,
micrositeGithubToken := sys.env.get("GITHUB_TOKEN"),
scalacOptions --= List(
"-Werror",
"-Xfatal-warnings",
"-Ywarn-unused-import",
"-Ywarn-numeric-widen",
"-Ywarn-dead-code",
"-Xlint:-missing-interpolator,_"
)
)
.dependsOn(`fs2-rabbit`, `fs2-rabbit-circe`, `examples`)

// CI build
addCommandAlias("buildFs2Rabbit", ";clean;+test;mdoc")

0 comments on commit 15971cc

Please sign in to comment.