val scala3: String = "3.8.3"

ThisBuild / scalaVersion  := scala3
ThisBuild / versionScheme := Some("semver-spec")
ThisBuild / gsProjectName := "gs-std"

ThisBuild / licenses := Seq(
  "Apache 2.0" -> url(
    "https://git.garrity.co/garrity-software/gs-std/src/branch/main/LICENSE"
  )
)

val noPublishSettings = Seq(
  publish := {}
)

val sharedSettings = Seq(
  scalaVersion               := scala3,
  version                    := semVerSelected.value,
  coverageFailOnMinimum      := true,
  coverageMinimumStmtTotal   := 100,
  coverageMinimumBranchTotal := 100
)

val Deps = new {

  val Cats = new {
    val Core: ModuleID   = "org.typelevel" %% "cats-core"   % "2.13.0"
    val Effect: ModuleID = "org.typelevel" %% "cats-effect" % "3.7.0"
  }

  val Fs2 = new {
    val Core: ModuleID = "co.fs2" %% "fs2-core" % "3.13.0"
    val IO: ModuleID   = "co.fs2" %% "fs2-io"   % "3.13.0"
  }

  val MUnit: ModuleID = "org.scalameta" %% "munit" % "1.3.0" % Test
}

lazy val testSettings = Seq(
  libraryDependencies ++= Seq(
    Deps.MUnit
  )
)

lazy val `gs-std` = project
  .in(file("."))
  .aggregate(core, io, effect)
  .settings(sharedSettings)
  .settings(testSettings)
  .settings(name := s"${gsProjectName.value}-v${semVerMajor.value}")

lazy val core = project
  .in(file("modules/core"))
  .settings(sharedSettings)
  .settings(testSettings)
  .settings(name := s"${gsProjectName.value}-core-v${semVerMajor.value}")

lazy val io = project
  .in(file("modules/io"))
  .settings(sharedSettings)
  .settings(testSettings)
  .settings(name := s"${gsProjectName.value}-io-v${semVerMajor.value}")
  .settings(
    libraryDependencies ++= Seq(
      Deps.Cats.Core,
      Deps.Cats.Effect,
      Deps.Fs2.Core,
      Deps.Fs2.IO
    )
  )

lazy val effect = project
  .in(file("modules/effect"))
  .dependsOn(core)
  .dependsOn(io % "test->compile")
  .settings(sharedSettings)
  .settings(testSettings)
  .settings(name := s"${gsProjectName.value}-effect-v${semVerMajor.value}")
  .settings(
    libraryDependencies ++= Seq(Deps.Cats.Core, Deps.Cats.Effect, Deps.Fs2.Core)
  )
