Skip to content

Commit

Permalink
Merge pull request #2161 from tgodzik/set-version
Browse files Browse the repository at this point in the history
bugfix: Never set empty Scala JS version from sbt
  • Loading branch information
tgodzik authored Sep 22, 2023
2 parents 4021c89 + 31f1eee commit 571b328
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
7 changes: 6 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ val integrations = file("integrations")
lazy val sbtBloop: Project = project
.enablePlugins(ScriptedPlugin)
.disablePlugins(ScalafixPlugin)
.enablePlugins(BuildInfoPlugin)
.in(integrations / "sbt-bloop")
.settings(
scriptedBufferLog := false,
Expand All @@ -347,7 +348,11 @@ lazy val sbtBloop: Project = project
sbtPlugin := true,
sbtVersion := SbtVersion,
target := (file("integrations") / "sbt-bloop" / "target" / SbtVersion).getAbsoluteFile,
libraryDependencies += Dependencies.bloopConfig
libraryDependencies += Dependencies.bloopConfig,
buildInfoPackage := "bloop.integrations.sbt",
buildInfoKeys := List[BuildInfoKey](
"latestScalaJsVersion" -> Dependencies.scalaJs1Version
)
)

lazy val buildpressConfig = (project in file("buildpress-config"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ object BloopDefaults {
private final val CompilerPluginConfig = "plugin->default(compile)"

/** Find native version. Copy pasted from Scala native. */
def findVersion(deps: Seq[ModuleID], org: String): Option[String] = {
def findNativePluginVersion(deps: Seq[ModuleID], org: String): Option[String] = {
def isPlugin(d: ModuleID, org: String) =
d.configurations.toList.contains(CompilerPluginConfig) && d.organization == org
deps.find(isPlugin(_, org)).map(_.revision)
Expand Down Expand Up @@ -762,7 +762,7 @@ object BloopDefaults {
val nativeLinkStubs = ScalaNativeKeys.nativeLinkStubs.?.value.getOrElse(emptyNative.linkStubs)
val nativeCompileOptions = ScalaNativeKeys.nativeCompileOptions.?.value.toList.flatten
val nativeLinkingOptions = ScalaNativeKeys.nativeLinkingOptions.?.value.toList.flatten
val nativeVersion = findVersion(libraryDeps, "org.scala-native").getOrElse(emptyNative.version)
val nativeVersion = findNativePluginVersion(libraryDeps, "org.scala-native").getOrElse(emptyNative.version)

val nativeMode = ScalaNativeKeys.nativeMode.?.value match {
case Some("debug") => Config.LinkerMode.Debug
Expand All @@ -777,25 +777,28 @@ object BloopDefaults {
}
} else if (pluginLabels.contains(ScalaJsPluginLabel)) {
Def.task {
val emptyScalaJs = Config.JsConfig.empty
val scalaJsVersion = findVersion(libraryDeps, "org.scala-js").getOrElse(emptyScalaJs.version)
val scalaJsVersion = libraryDeps
.find(module => module.organization == "org.scala-js" && module.name.startsWith("scalajs-library_"))
.map(_.revision)
.getOrElse(BuildInfo.latestScalaJsVersion)

val scalaJsStage = BloopKeys.bloopScalaJSStage.value match {
case Some(ScalaJsFastOpt) => Config.LinkerMode.Debug
case Some(ScalaJsFullOpt) => Config.LinkerMode.Release
case _ => emptyScalaJs.mode
case _ => Config.LinkerMode.Debug
}

val scalaJsModule = BloopKeys.bloopScalaJSModuleKind.value match {
case Some(NoJSModule) => Config.ModuleKindJS.NoModule
case Some(CommonJSModule) => Config.ModuleKindJS.CommonJSModule
case Some(ESModule) => Config.ModuleKindJS.ESModule
case _ => emptyScalaJs.kind
case _ => Config.ModuleKindJS.NoModule
}

val scalaJsEmitSourceMaps =
ScalaJsKeys.scalaJSEmitSourceMaps.?.value.getOrElse(emptyScalaJs.emitSourceMaps)
ScalaJsKeys.scalaJSEmitSourceMaps.?.value.getOrElse(false)
val jsdom = Some(false)
val jsConfig = Config.JsConfig(scalaJsVersion, scalaJsStage, scalaJsModule, scalaJsEmitSourceMaps, jsdom, None, None, emptyScalaJs.toolchain)
val jsConfig = Config.JsConfig(scalaJsVersion, scalaJsStage, scalaJsModule, scalaJsEmitSourceMaps, jsdom, None, None, Nil)
Config.Platform.Js(jsConfig, mainClass)
}
} else {
Expand Down

0 comments on commit 571b328

Please sign in to comment.