From 87cd32a91f12933d6d1dc51315650410f8b645ab Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Sun, 4 Jun 2023 15:42:11 +0200 Subject: [PATCH] Enable `buildInfoStaticCompiled` on ScalaJSModule and ScalaNativeModule (#2562) Status quo fails linking with a cryptic error message where previous version was working out of the box. This sets the default to the static behavior on Scala.js and Scala Native so users don't need to care. --------- Co-authored-by: Your Name --- build.sc | 3 +-- .../buildinfo/src/mill/contrib/buildinfo/BuildInfo.scala | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build.sc b/build.sc index e50694f4622..2b4b886ff9b 100644 --- a/build.sc +++ b/build.sc @@ -730,8 +730,7 @@ object contrib extends Module { } object buildinfo extends ContribModule { - def compileModuleDeps = Seq(scalalib) - def testModuleDeps = super.testModuleDeps ++ Seq(scalalib) + def moduleDeps = Seq(scalalib, scalajslib, scalanativelib) } object proguard extends ContribModule { diff --git a/contrib/buildinfo/src/mill/contrib/buildinfo/BuildInfo.scala b/contrib/buildinfo/src/mill/contrib/buildinfo/BuildInfo.scala index 3d10cb24894..b291f4f51dc 100644 --- a/contrib/buildinfo/src/mill/contrib/buildinfo/BuildInfo.scala +++ b/contrib/buildinfo/src/mill/contrib/buildinfo/BuildInfo.scala @@ -2,6 +2,8 @@ package mill.contrib.buildinfo import mill.{PathRef, T} import mill.scalalib.{JavaModule, ScalaModule} +import mill.scalanativelib.ScalaNativeModule +import mill.scalajslib.ScalaJSModule trait BuildInfo extends JavaModule { @@ -20,7 +22,11 @@ trait BuildInfo extends JavaModule { * rather than the default behavior of storing them as a JVM resource. Needed * to use BuildInfo on Scala.js which does not support JVM resources */ - def buildInfoStaticCompiled: Boolean = false + def buildInfoStaticCompiled: Boolean = this match { + case _: ScalaJSModule => true + case _: ScalaNativeModule => true + case _ => false + } /** * A mapping of key-value pairs to pass from the Build script to the