Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the scala-library dependency for (generic) platform modules #2739

Merged
merged 2 commits into from
Sep 15, 2023
Merged
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
8 changes: 5 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,16 @@ trait MillPublishScalaModule extends MillScalaModule with MillPublishJavaModule
/** Publishable module which contains strictly handled API. */
trait MillStableScalaModule extends MillPublishScalaModule with Mima {
import com.github.lolgab.mill.mima._
// MIMA doesn't properly ignore things which are nested inside other private things
// so we have to put explicit ignores here (https://github.com/lightbend/mima/issues/771)
override def mimaBinaryIssueFilters: T[Seq[ProblemFilter]] = Seq(
// MIMA doesn't properly ignore things which are nested inside other private things
// so we have to put explicit ignores here (https://github.com/lightbend/mima/issues/771)
ProblemFilter.exclude[Problem]("mill.eval.ProfileLogger*"),
ProblemFilter.exclude[Problem]("mill.eval.GroupEvaluator*"),
ProblemFilter.exclude[Problem]("mill.eval.Tarjans*"),
ProblemFilter.exclude[Problem]("mill.define.Ctx#Impl*"),
ProblemFilter.exclude[Problem]("mill.resolve.ResolveNotFoundHandler*")
ProblemFilter.exclude[Problem]("mill.resolve.ResolveNotFoundHandler*"),
// See https://github.com/com-lihaoyi/mill/pull/2739
ProblemFilter.exclude[ReversedMissingMethodProblem]("mill.scalajslib.ScalaJSModule.mill$scalajslib$ScalaJSModule$$super$scalaLibraryIvyDeps")
)
def mimaPreviousVersions: T[Seq[String]] = Settings.mimaBaseVersions

Expand Down
16 changes: 15 additions & 1 deletion scalajslib/src/mill/scalajslib/ScalaJSModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import mainargs.Flag
import mill.api.{Loose, PathRef, Result, internal}
import mill.scalalib.api.ZincWorkerUtil
import mill.scalalib.Lib.resolveDependencies
import mill.scalalib.{Dep, DepSyntax, Lib, TestModule}
import mill.scalalib.{CrossVersion, Dep, DepSyntax, Lib, TestModule}
import mill.testrunner.{TestResult, TestRunner, TestRunnerUtils}
import mill.define.{Command, Target, Task}
import mill.scalajslib.api._
Expand Down Expand Up @@ -34,6 +34,20 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer =>

def scalaJSWorkerVersion = T { ZincWorkerUtil.scalaJSWorkerVersion(scalaJSVersion()) }

override def scalaLibraryIvyDeps = T {
val deps = super.scalaLibraryIvyDeps()
if (ZincWorkerUtil.isScala3(scalaVersion())) {
// Since Dotty/Scala3, Scala.JS is published with a platform suffix
deps.map(dep =>
dep.copy(cross = dep.cross match {
case c: CrossVersion.Constant => c.copy(platformed = true)
case c: CrossVersion.Binary => c.copy(platformed = true)
case c: CrossVersion.Full => c.copy(platformed = true)
})
)
} else deps
}

def scalaJSWorkerClasspath = T {
mill.util.Util.millProjectModule(
artifact = s"mill-scalajslib-worker-${scalaJSWorkerVersion()}",
Expand Down
2 changes: 1 addition & 1 deletion scalalib/src/mill/scalalib/Dep.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ object CrossVersion {
implicit def rw: RW[Full] = macroRW
}

def empty(platformed: Boolean) = Constant(value = "", platformed)
def empty(platformed: Boolean): Constant = Constant(value = "", platformed)

implicit def rw: RW[CrossVersion] = RW.merge(Constant.rw, Binary.rw, Full.rw)
}
Expand Down
4 changes: 1 addition & 3 deletions scalalib/src/mill/scalalib/Lib.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,11 @@ object Lib {
def scalaRuntimeIvyDeps(scalaOrganization: String, scalaVersion: String): Loose.Agg[Dep] =
if (ZincWorkerUtil.isDotty(scalaVersion)) {
Agg(
// note that dotty-library has a binary version suffix, hence the :: is necessary here
ivy"$scalaOrganization::dotty-library:$scalaVersion".forceVersion()
)
} else if (ZincWorkerUtil.isScala3(scalaVersion))
Agg(
// note that dotty-library has a binary version suffix, hence the :: is necessary here
ivy"$scalaOrganization::scala3-library::$scalaVersion".forceVersion()
ivy"$scalaOrganization::scala3-library:$scalaVersion".forceVersion()
)
else
Agg(
Expand Down