Skip to content

Commit

Permalink
Close #239 - Support Scala Native
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-lee committed Oct 13, 2024
1 parent 9490c9e commit 41d4e1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
39 changes: 23 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import sbtcrossproject.CrossProject

lazy val core = module("core", crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
libraryDependencies ++= List(libs.tests.scalaCollectionCompat),
libraryDependencies ++= List(libs.tests.scalaCollectionCompat.value),
// (Compile / compile) / scalacOptions ++= (if (isGhaPublishing) List.empty[String]
// else ProjectInfo.commonWarts(scalaVersion.value)),
// (Test / compile) / scalacOptions ++= (if (isGhaPublishing) List.empty[String]
Expand Down Expand Up @@ -96,7 +96,7 @@ lazy val coreNative = core.native.settings(nativeSettings)

lazy val decver = module("decver", crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
libraryDependencies ++= List(libs.tests.scalaCollectionCompat),
libraryDependencies ++= List(libs.tests.scalaCollectionCompat.value),
)
.dependsOn(core % props.IncludeTest)

Expand All @@ -121,7 +121,7 @@ lazy val docs = (project in file("docs-gen-tmp/docs"))
val latestVersion = s"git describe --tags $tag".!!.trim.stripPrefix("v")

List(
"io.kevinlee" %%% "just-semver-core" % latestVersion,
"io.kevinlee" %%% "just-semver-core" % latestVersion,
"io.kevinlee" %%% "just-semver-decver" % latestVersion,
)
},
Expand Down Expand Up @@ -202,7 +202,7 @@ lazy val props =

final val HedgehogVersion = "0.9.0"

final val HedgehogLatestVersion = "0.10.1"
val HedgehogLatestVersion = "0.11.0-RC1"

val ScalaCollectionCompatVersion = "2.12.0"

Expand All @@ -213,22 +213,27 @@ lazy val libs =

lazy val tests = new {

def hedgehogLibs(scalaVersion: String): List[ModuleID] = {
lazy val hedgehogLibs = Def.setting {
val scalaV = scalaVersion.value
val hedgehogVersion =
if (scalaVersion.startsWith("3.0"))
if (scalaV.startsWith("3.0"))
props.HedgehogVersion
else
props.HedgehogLatestVersion

List(
"qa.hedgehog" %% "hedgehog-core" % hedgehogVersion % Test,
"qa.hedgehog" %% "hedgehog-runner" % hedgehogVersion % Test,
"qa.hedgehog" %% "hedgehog-sbt" % hedgehogVersion % Test
// TODO: Once Hedgehog v0.11.0 or higher is released put the old ones back.
// "qa.hedgehog" %%% "hedgehog-core" % hedgehogVersion % Test,
// "qa.hedgehog" %%% "hedgehog-runner" % hedgehogVersion % Test,
// "qa.hedgehog" %%% "hedgehog-sbt" % hedgehogVersion % Test
"io.kevinlee" %%% "hedgehog-core" % hedgehogVersion % Test,
"io.kevinlee" %%% "hedgehog-runner" % hedgehogVersion % Test,
"io.kevinlee" %%% "hedgehog-sbt" % hedgehogVersion % Test
)
}

val scalaCollectionCompat =
"org.scala-lang.modules" %% "scala-collection-compat" % props.ScalaCollectionCompatVersion % Test
lazy val scalaCollectionCompat =
Def.setting("org.scala-lang.modules" %%% "scala-collection-compat" % props.ScalaCollectionCompatVersion % Test)
}
}

Expand Down Expand Up @@ -277,18 +282,20 @@ def module(projectName: String, crossProject: CrossProject.Builder): CrossProjec
((Compile / unmanagedSourceDirectories).value ++ moreSrcs).distinct
},
// useAggressiveScalacOptions := true,
libraryDependencies :=
libraryDependencies := {
lazy val hedgehogAll = libs.tests.hedgehogLibs.value
crossVersionProps(Seq.empty[ModuleID], SemVer.parseUnsafe(scalaVersion.value)) {
case (SemVer.Major(3), SemVer.Minor(0), _) =>
libs.tests.hedgehogLibs(scalaVersion.value) ++ libraryDependencies.value ++
hedgehogAll ++ libraryDependencies.value ++
libraryDependencies.value.filterNot(m => m.organization == "org.wartremover" && m.name == "wartremover")

case (Major(3), _, _) =>
libs.tests.hedgehogLibs(scalaVersion.value) ++ libraryDependencies.value
hedgehogAll ++ libraryDependencies.value

case x =>
libs.tests.hedgehogLibs(scalaVersion.value) ++ libraryDependencies.value
},
hedgehogAll ++ libraryDependencies.value
}
},
libraryDependencies := (
if (isScala3(scalaVersion.value)) {
libraryDependencies
Expand Down
3 changes: 1 addition & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ addSbtPlugin("io.kevinlee" % "sbt-docusaur" % "0.15.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.1")

addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.15")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.2")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")

addSbtPlugin("org.scalameta" % "sbt-native-image" % "0.3.4")
Expand All @@ -20,4 +20,3 @@ addSbtPlugin("io.kevinlee" % "sbt-devoops-scala" % sbtDevOopsVersion)
addSbtPlugin("io.kevinlee" % "sbt-devoops-sbt-extra" % sbtDevOopsVersion)
addSbtPlugin("io.kevinlee" % "sbt-devoops-github" % sbtDevOopsVersion)
addSbtPlugin("io.kevinlee" % "sbt-devoops-starter" % sbtDevOopsVersion)

0 comments on commit 41d4e1d

Please sign in to comment.