Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,15 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
scala: [2.12.21]
java:
- temurin@11
- temurin@17
- temurin@21
- temurin@25
scala: [3.8.4]
java: [temurin@17, temurin@21, temurin@25]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup Java (temurin@11)
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 11
cache: sbt

- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v5
Expand Down Expand Up @@ -72,7 +60,7 @@ jobs:
uses: sbt/setup-sbt@v1

- name: Check that workflows are up to date
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
run: sbt --client '++ ${{ matrix.scala }}; githubWorkflowCheck'

- name: Build project
run: sbt test
Expand Down
37 changes: 19 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ Global / onChangedBuildSource := ReloadOnSourceChanges
noPublishSettings

// GitHub Actions config
val javaVersions = Seq(11, 17, 21, 25).map(v => JavaSpec.temurin(v.toString))
val javaVersions = Seq(17, 21, 25).map(v => JavaSpec.temurin(v.toString))

ThisBuild / githubWorkflowJavaVersions := javaVersions
ThisBuild / githubWorkflowArtifactUpload := false
ThisBuild / githubWorkflowBuildMatrixFailFast := Some(false)
ThisBuild / githubWorkflowTargetBranches := Seq("master")
ThisBuild / githubWorkflowPublishTargetBranches := Seq()
ThisBuild / githubWorkflowUseSbtThinClient := true

def isJava(v: Int) = s"matrix.java == '${javaVersions.find(_.version == v.toString).get.render}'"

Expand All @@ -24,15 +25,15 @@ ThisBuild / githubWorkflowBuild := Seq(
)

lazy val core = simpleProj(projectMatrix.in(file("core")), "core", List(
Platform.Jvm,
Platform.Js,
Platform.Native,
BuildPlatform.Jvm,
BuildPlatform.Js,
BuildPlatform.Native,
))
.settings(publishSettings)
.settings(
libraryDependencies ++= Seq(
catsCore.value % Optional,
izumiReflect.value,
catsCore % Optional,
izumiReflect,
),
Compile / sourceGenerators += Def.task {
val generators = new File("git rev-parse --show-toplevel".!!.trim) / "generators"
Expand All @@ -53,21 +54,21 @@ lazy val core = simpleProj(projectMatrix.in(file("core")), "core", List(

lazy val http4s = http4sProj(projectMatrix.in(file("http4s")), "http4s")(axis => _ => _.settings(
libraryDependencies ++= Seq(
axis.dep("core").value,
axis.dep("dsl").value,
axis.dep("core"),
axis.dep("dsl"),
)
))
.settings(publishSettings)
.settings(scalacOptions ~= (_.filterNot(_ == "-Wunused:nowarn")))
.dependsOn(core % "compile->compile;test->test")

lazy val play = playProj(projectMatrix.in(file("play")), "play")(axis => _ => _.settings(
libraryDependencies ++= Seq(axis.dep("play").value),
libraryDependencies ++= Seq(axis.dep("play")),
))
.settings(publishSettings)
.dependsOn(core % "compile->compile;test->test")

lazy val bench = http4sProj(projectMatrix.in(file("bench")), "bench", _ => List(Platform.Jvm))(
lazy val bench = http4sProj(projectMatrix.in(file("bench")), "bench", _ => List(BuildPlatform.Jvm))(
_ => sjsNowarnGlobalECSettings,
)
.settings(noPublishSettings)
Expand All @@ -82,11 +83,11 @@ def http4sImplDoc(dir: File, axis: Http4sAxis.Value): (File, String) =
def playDepString(axis: PlayAxis.Value): String =
s""""bondlink" %% "routing-play_${axis.suffix}" % "$currentVersion""""

lazy val docs = http4sProj(projectMatrix.in(file("routing-docs")), "routing-docs", _ => List(Platform.Jvm))(
lazy val docs = http4sProj(projectMatrix.in(file("routing-docs")), "routing-docs", _ => List(BuildPlatform.Jvm))(
axis => _ => _.settings(
scalacOptions -= "-Werror",
mdocVariables ++= {
val playAxisDeps = PlayAxis.all.map(_.dep("fake")).join.value
val playAxisDeps = PlayAxis.all.map(_.dep("fake"))
Map(
"VERSION" -> currentVersion,
"GITHUB_REPO_URL" -> githubRepoUrl,
Expand Down Expand Up @@ -143,22 +144,22 @@ publishDocsSite := Def.taskDyn {
)
}.value

lazy val example = http4sProj(projectMatrix.in(file("example")), "example", _ => List(Platform.Jvm))(
lazy val example = http4sProj(projectMatrix.in(file("example")), "example", _ => List(BuildPlatform.Jvm))(
axis => sjsNowarnGlobalECSettings.andThen(_.andThen(_.settings(
libraryDependencies ++= Seq(
axis.dep("circe").value,
axis.dep("ember-server").value,
axis.dep("circe"),
axis.dep("ember-server"),
),
dependencyOverrides ++= Seq(
axis.dep("core").value
axis.dep("core")
),
))),
)
.settings(noPublishSettings)
.settings(
libraryDependencies ++= Seq(
circeDep("core").value,
circeDep("generic").value,
circeDep("core"),
circeDep("generic"),
"org.slf4j" % "slf4j-api" % "2.0.18",
"org.slf4j" % "slf4j-simple" % "2.0.18"
)
Expand Down
71 changes: 34 additions & 37 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ package routing

import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport.{mimaFailOnNoPrevious, mimaPreviousArtifacts}
import java.io.File
import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
import sbt._
import sbt.Keys._
import sbt.internal.ProjectMatrix
import sbtprojectmatrix.ProjectMatrixPlugin.autoImport._
import sbts3publish.S3PublishPlugin.autoImport.{s3PublishBucket, s3Release}
import scala.sys.process._

object Build {
lazy val currentVersion = "5.1.0"
lazy val scalaVersions = Seq("2.13.18", "3.3.8")
lazy val latestScalaV = scalaVersions.find(_.startsWith("3.")).get
lazy val kindProjector = compilerPlugin("org.typelevel" % "kind-projector" % "0.13.4" cross CrossVersion.full)
lazy val kindProjector = compilerPlugin(("org.typelevel" % "kind-projector" % "0.13.4").cross(CrossVersion.full))

def profileTraceOpts(baseDir: File, name: String): Seq[String] = {
val dir = baseDir / ".traces"
Expand Down Expand Up @@ -98,7 +95,7 @@ object Build {
publish / skip := false,
s3PublishBucket := "bondlink-maven-repo",
resolvers += "bondlink-maven-repo" at "https://maven.bondlink-cdn.com",
mimaPreviousArtifacts := Set(organization.value %%% (moduleName.value match {
mimaPreviousArtifacts := Set(organization.value %% (moduleName.value match {
case s if s.startsWith(s"routing-http4s_$http4sV1Milestone") => s"routing-http4s_${http4sV1Milestone.toLowerCase}44"
case s => s
}) % "5.0.0"),
Expand All @@ -112,32 +109,32 @@ object Build {
mimaFailOnNoPrevious := false,
)

sealed abstract class Platform(val s: String)
object Platform {
case object Jvm extends Platform("jvm")
case object Js extends Platform("js")
case object Native extends Platform("native")
sealed abstract class BuildPlatform(val s: String)
object BuildPlatform {
case object Jvm extends BuildPlatform("jvm")
case object Js extends BuildPlatform("js")
case object Native extends BuildPlatform("native")
}

type ProjSettings = Platform => Project => Project
type ProjSettings = BuildPlatform => Project => Project

def nativeProj(f: Project => Project): Project => Project =
f.andThen(_.enablePlugins(scala.scalanative.sbtplugin.ScalaNativePlugin))

val sjsNowarnGlobalECSettings: ProjSettings =
_ match {
case Platform.Js => _.settings(scalacOptions += "-P:scalajs:nowarnGlobalExecutionContext")
case Platform.Jvm | Platform.Native => identity
case BuildPlatform.Js => _.settings(scalacOptions += "-P:scalajs:nowarnGlobalExecutionContext")
case BuildPlatform.Jvm | BuildPlatform.Native => identity
}

def sjsProj(f: Project => Project): Project => Project =
f.andThen(_.enablePlugins(org.scalajs.sbtplugin.ScalaJSPlugin))

def platformAxes(platforms: List[Platform]): List[(Platform, VirtualAxis)] =
def platformAxes(platforms: List[BuildPlatform]): List[(BuildPlatform, VirtualAxis)] =
platforms.map {
case p @ Platform.Jvm => (p, VirtualAxis.jvm)
case p @ Platform.Js => (p, VirtualAxis.js)
case p @ Platform.Native => (p, VirtualAxis.native)
case p @ BuildPlatform.Jvm => (p, VirtualAxis.jvm)
case p @ BuildPlatform.Js => (p, VirtualAxis.js)
case p @ BuildPlatform.Native => (p, VirtualAxis.native)
}

def baseProj(matrix: ProjectMatrix, nme: String) =
Expand All @@ -153,16 +150,16 @@ object Build {
))

platform match {
case Platform.Jvm => base
case Platform.Js => sjsProj(base)
case Platform.Native => nativeProj(base)
case BuildPlatform.Jvm => base
case BuildPlatform.Js => sjsProj(base)
case BuildPlatform.Native => nativeProj(base)
}
}

def simpleProj(
matrix: ProjectMatrix,
nme: String,
platforms: List[Platform],
platforms: List[BuildPlatform],
extraSettings: ProjSettings = _ => identity,
) =
platformAxes(platforms).foldLeft(baseProj(matrix, nme)) { case (acc, (platform, axis)) =>
Expand All @@ -174,7 +171,7 @@ object Build {
}

def axesProj[V](matrix: ProjectMatrix, nme: String, axes: List[V])(
platforms: V => List[Platform],
platforms: V => List[BuildPlatform],
extraSettings: V => ProjSettings,
)(implicit va: V => VirtualAxis) =
axes
Expand All @@ -191,9 +188,9 @@ object Build {

case class LibAxesProj[V](axes: List[V])(
suffix: V => String,
defaultPlatforms: V => List[Platform],
defaultPlatforms: V => List[BuildPlatform],
) {
def apply(matrix: ProjectMatrix, nme: String, platforms: V => List[Platform] = defaultPlatforms)(
def apply(matrix: ProjectMatrix, nme: String, platforms: V => List[BuildPlatform] = defaultPlatforms)(
settings: V => ProjSettings,
)(implicit va: V => VirtualAxis) =
axesProj(matrix, nme, axes)(
Expand Down Expand Up @@ -221,30 +218,30 @@ object Build {
}

val defaultHttp4sPlatforms = (_: Http4sAxis.Value) match {
case Http4sAxis.v0_23 | Http4sAxis.v1_0_0_M46 => List(Platform.Jvm, Platform.Js)
case Http4sAxis.v0_23 | Http4sAxis.v1_0_0_M46 => List(BuildPlatform.Jvm, BuildPlatform.Js)
}
lazy val http4sProj = LibAxesProj(Http4sAxis.all)(_.suffix, defaultHttp4sPlatforms)

val defaultPlayPlatforms = (_: PlayAxis.Value) => List(Platform.Jvm)
val defaultPlayPlatforms = (_: PlayAxis.Value) => List(BuildPlatform.Jvm)
lazy val playProj = LibAxesProj(PlayAxis.all)(_.suffix, defaultPlayPlatforms)

val scalacheckVersion = "1.19.0"
val scalacheckDep = Def.setting("org.scalacheck" %%% "scalacheck" % scalacheckVersion)
val scalacheckDep = "org.scalacheck" %% "scalacheck" % scalacheckVersion

val testSettings = Seq(
libraryDependencies += scalacheckDep.value % "test",
libraryDependencies += scalacheckDep % Test,
Test / testOptions ++= Seq(Tests.Argument(TestFrameworks.ScalaCheck, "-verbosity", "2")) ++
Option(System.getProperty("testIterations")).map(_.toInt)
.map(n => Seq(Tests.Argument(TestFrameworks.ScalaCheck, "-minSuccessfulTests", n.toString)))
.getOrElse(Seq())
)

val catsCore = Def.setting("org.typelevel" %%% "cats-core" % "2.13.0")
val izumiReflect = Def.setting("dev.zio" %%% "izumi-reflect" % "3.0.9")
val catsCore = "org.typelevel" %% "cats-core" % "2.13.0"
val izumiReflect = "dev.zio" %% "izumi-reflect" % "3.0.9"
val http4sV1Milestone = "1.0.0-M"

object Http4sAxis extends Enumeration {
protected case class HAVal(suffix: String, dep: String => Def.Initialize[ModuleID], comment: String) extends super.Val { self =>
protected case class HAVal(suffix: String, dep: String => ModuleID, comment: String) extends super.Val { self =>
lazy val axis: VirtualAxis.WeakAxis =
new VirtualAxis.WeakAxis {
val suffix = self.suffix
Expand All @@ -256,14 +253,14 @@ object Build {
implicit def valueToHAVal(v: Value): HAVal = v.asInstanceOf[HAVal]
implicit def valueToVirtualAxis(v: Value): VirtualAxis.WeakAxis = v.axis

val v0_23 = HAVal("0.23", proj => Def.setting("org.http4s" %%% s"http4s-$proj" % "0.23.34"), "latest stable on cats effect 3")
val v1_0_0_M46 = HAVal(s"${http4sV1Milestone}46", proj => Def.setting("org.http4s" %%% s"http4s-$proj" % "1.0.0-M46"), "latest development on cats effect 3")
val v0_23 = HAVal("0.23", proj => "org.http4s" %% s"http4s-$proj" % "0.23.34", "latest stable on cats effect 3")
val v1_0_0_M46 = HAVal(s"${http4sV1Milestone}46", proj => "org.http4s" %% s"http4s-$proj" % "1.0.0-M46", "latest development on cats effect 3")

lazy val all = values.toList
}

object PlayAxis extends Enumeration {
protected case class PAVal(suffix: String, dep: String => Def.Initialize[ModuleID]) extends super.Val { self =>
protected case class PAVal(suffix: String, dep: String => ModuleID) extends super.Val { self =>
lazy val axis: VirtualAxis.WeakAxis =
new VirtualAxis.WeakAxis {
val suffix = self.suffix
Expand All @@ -275,11 +272,11 @@ object Build {
implicit def valueToPAVal(v: Value): PAVal = v.asInstanceOf[PAVal]
implicit def valueToVirtualAxis(v: Value): VirtualAxis.WeakAxis = v.axis

val v3_0 = PAVal("3.0", proj => Def.setting("org.playframework" %%% proj % "3.0.11"))
val v2_9 = PAVal("2.9", proj => Def.setting("com.typesafe.play" %%% proj % "2.9.11"))
val v3_0 = PAVal("3.0", proj => "org.playframework" %% proj % "3.0.11")
val v2_9 = PAVal("2.9", proj => "com.typesafe.play" %% proj % "2.9.11")

lazy val all = values.toList
}

def circeDep(proj: String) = Def.setting("io.circe" %%% s"circe-$proj" % "0.14.15")
def circeDep(proj: String) = "io.circe" %% s"circe-$proj" % "0.14.15"
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.12.12
sbt.version=2.0.0
2 changes: 0 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
resolvers += "bondlink-maven-repo" at "https://maven.bondlink-cdn.com"

addSbtPlugin("bondlink" % "sbt-s3-publish" % "0.0.1")
addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.11.0")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.30.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.6")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.21.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.12")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.9.0" )
Expand Down
Loading