Skip to content

Commit

Permalink
Define reasonable platformSuffix in MillBuildPlatformModule (#2635)
Browse files Browse the repository at this point in the history
It's a typical use case to add plugin dependencies to a meta-build. To
make this more convenient, we set the `platformSuffix` to
`_mill<binary-platform>`.

Pull request: #2635
  • Loading branch information
lefou authored Jun 27, 2023
1 parent 916a5cd commit c537f29
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
4 changes: 4 additions & 0 deletions runner/src/mill/runner/MillBuildRootModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import mill.scalalib.api.Versions
import os.{Path, rel}
import pprint.Util.literalize
import FileImportGraph.backtickWrap
import mill.main.BuildInfo

import scala.util.Try

/**
Expand Down Expand Up @@ -112,6 +114,8 @@ class MillBuildRootModule()(implicit
)
}

override def platformSuffix: T[String] = s"_mill${BuildInfo.millBinPlatform}"

override def generatedSources: T[Seq[PathRef]] = T {
generateScriptSources()
}
Expand Down
26 changes: 10 additions & 16 deletions runner/src/mill/runner/MillIvy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@ package mill.runner

object MillIvy {
def processMillIvyDepSignature(signatures: Set[String]): Set[String] = {
// replace platform notation and empty version
val millSigs: Set[String] = for (signature <- signatures) yield {

if (signature.endsWith(":") && signature.count(_ == ":") == 4) signature + "$MILL_VERSION"
// else
signature.split("[:]") match {
case Array(org, "", pname, "", version)
if org.length > 0 && pname.length > 0 && version.length > 0 =>
s"${org}::${pname}_mill$$MILL_BIN_PLATFORM:${version}"
case Array(org, "", "", pname, "", version)
if org.length > 0 && pname.length > 0 && version.length > 0 =>
s"${org}:::${pname}_mill$$MILL_BIN_PLATFORM:${version}"
case Array(org, "", name) if org.length > 0 && name.length > 0 && signature.endsWith(":") =>
s"${org}::${name}:$$MILL_VERSION"
case _ => signature
val millSigs: Set[String] =
for (signature <- signatures) yield {
signature.split("[:]") match {
case Array(org, "", name)
if org.length > 0 && name.length > 0 && signature.endsWith(":") =>
// replace empty version with Mill Version Placeholder
signature + "$MILL_VERSION"
case _ => signature
}
}
}

// replace special MILL_ placeholders
val replaced = millSigs.map(_
.replace("$MILL_VERSION", mill.main.BuildInfo.millVersion)
.replace("${MILL_VERSION}", mill.main.BuildInfo.millVersion)
Expand Down

0 comments on commit c537f29

Please sign in to comment.