Skip to content

Commit

Permalink
SBT: refactor external library dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Feb 11, 2025
1 parent e39ea06 commit 4ef8c3e
Showing 1 changed file with 35 additions and 60 deletions.
95 changes: 35 additions & 60 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,16 @@ lazy val runtime = project
)
.dependsOn(interfaces)

val excludePprint = ExclusionRule(organization = "com.lihaoyi")
val excludeCollection =
ExclusionRule(organization = "org.scala-lang.modules", name = "scala-collection-compat_2.13")
lazy val depScalameta = Def.settings(
libraryDependencies += {
val sm = ("org.scalameta" %% "scalameta" % V.scalameta).excludeAll("com.lihaoyi")
if (isScala3.value)
sm.excludeAll(
"org.scala-lang.modules" % s"scala-collection-compat_${scalaBinaryVersion.value}"
).cross(CrossVersion.for3Use2_13)
else sm
}
)

lazy val parser = crossProject(JVMPlatform, NativePlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
Expand All @@ -220,19 +227,7 @@ lazy val cli = project
"com.lihaoyi" %% "pprint" % V.pprint,
"org.scalameta" %% "metaconfig-typesafe-config" % V.metaconfig
),
libraryDependencies ++= crossSetting(
scalaVersion.value,
if2 = List(
("org.scalameta" %% "scalameta" % V.scalameta)
.excludeAll(excludePprint)
),
if3 = List(
("org.scalameta" %% "scalameta" % V.scalameta)
.excludeAll(excludePprint)
.excludeAll(excludeCollection)
.cross(CrossVersion.for3Use2_13)
)
)
depScalameta
)
.dependsOn(parser.jvm)

Expand All @@ -249,21 +244,13 @@ lazy val mdoc = project
scalaVersion,
scalaBinaryVersion
),
libraryDependencies ++= crossSetting(
scalaVersion.value,
if3 = List(
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value,
("org.scalameta" %% "scalameta" % V.scalameta)
.excludeAll(excludePprint)
.excludeAll(excludeCollection)
.cross(CrossVersion.for3Use2_13)
),
if2 = List(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
("org.scalameta" %% "scalameta" % V.scalameta)
.excludeAll(excludePprint)
)
),
depScalameta,
libraryDependencies += {
if (isScala3.value)
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value
else
"org.scala-lang" % "scala-compiler" % scalaVersion.value
},
libraryDependencies ++= jsoniter,
libraryDependencies ++= List(
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0",
Expand Down Expand Up @@ -299,9 +286,7 @@ val tests = project
.settings(
sharedSettings,
publish / skip := true,
libraryDependencies ++= List(
"org.scalameta" %% "munit" % V.munit
),
libraryDependencies += depMunit,
buildInfoPackage := "tests",
buildInfoKeys := Seq[BuildInfoKey](
scalaVersion,
Expand All @@ -318,9 +303,7 @@ val jsdocs = project
scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.CommonJSModule)
},
libraryDependencies ++= List(
"org.scala-js" %%% "scalajs-dom" % scalajsDom
),
depJsDom,
scalaJSUseMainModuleInitializer := true,
Compile / npmDependencies ++= List(
"ms" -> "2.1.1"
Expand All @@ -337,9 +320,7 @@ val jswebsitedocs = project
scalaJSLinkerConfig ~= {
_.withModuleKind(ModuleKind.ESModule)
},
libraryDependencies ++= List(
"org.scala-js" %%% "scalajs-dom" % scalajsDom
)
depJsDom
)
.enablePlugins(ScalaJSPlugin)

Expand All @@ -348,9 +329,7 @@ lazy val worksheets = project
.settings(
sharedSettings,
publish / skip := true,
libraryDependencies ++= List(
"org.scalameta" %% "munit" % V.munit % Test
)
libraryDependencies += depMunit % Test
)
.dependsOn(mdoc, tests)

Expand All @@ -369,19 +348,11 @@ lazy val unit = project
"io.github.cibotech" %% "evilplot" % "0.9.2"
)
),
libraryDependencies ++= List(
"org.scalameta" %% "munit" % V.munit % Test
),
libraryDependencies ++= crossSetting(
scalaVersion.value,
if3 = List(
("co.fs2" %% "fs2-core" % V.fs2)
.cross(CrossVersion.for3Use2_13)
),
if2 = List(
"co.fs2" %% "fs2-core" % V.fs2
)
),
libraryDependencies += depMunit % Test,
libraryDependencies += {
val dep = "co.fs2" %% "fs2-core" % V.fs2
if (isScala3.value) dep.cross(CrossVersion.for3Use2_13) else dep
},
buildInfoPackage := "tests.cli",
buildInfoKeys := Seq[BuildInfoKey](
"testsInputClassDirectory" -> (testsInput / Compile / classDirectory).value
Expand All @@ -396,9 +367,7 @@ lazy val unitJS = project
sharedSettings,
publish / skip := true,
Compile / unmanagedSourceDirectories ++= multiScalaDirectories("tests/unit-js").value,
libraryDependencies ++= List(
"org.scalameta" %% "munit" % V.munit % Test
),
libraryDependencies += depMunit % Test,
buildInfoPackage := "tests.js",
buildInfoKeys := Seq[BuildInfoKey](
"testsInputClassDirectory" -> (testsInput / Compile / classDirectory).value
Expand Down Expand Up @@ -429,7 +398,7 @@ lazy val plugin = project
libraryDependencies ++= List(
"org.jsoup" % "jsoup" % "1.12.1",
"org.scalacheck" %% "scalacheck" % V.scalacheck % Test,
"org.scalameta" %% "munit" % V.munit % Test,
depMunit % Test,
"org.scalameta" %% "testkit" % V.scalameta % Test
),
Compile / resourceGenerators += Def.task {
Expand Down Expand Up @@ -563,3 +532,9 @@ def localCrossPublishProject(ref: Project, scalaV: String): Def.Initialize[Task[
)
val _ = Project.extract(newState).runTask(ref / publishLocal, newState)
}

val depMunit = "org.scalameta" %% "munit" % V.munit

lazy val depJsDom = Def.settings(
libraryDependencies += "org.scala-js" %%% "scalajs-dom" % scalajsDom
)

0 comments on commit 4ef8c3e

Please sign in to comment.