Skip to content

Commit

Permalink
Distribute Mill Assembly via Maven Central (#2560)
Browse files Browse the repository at this point in the history
Creates a stub `dist` module whose only purpose is to take the
`dev.assembly` and put it on maven central, which the updated bootstrap
script will download.

This should help reduce the number of external failure points in Mill
bootstrap script; rather than having hard dependency on both Github and
Maven Central, this PR reduces it to only a hard dependency on Maven
Central. Maven Central is also by default a write-only package store.
That means that short of sending them a lawyer letter, the packages
published there are immutable
(https://central.sonatype.org/faq/can-i-change-a-component). This is in
contrast to Github release assets which are read/write.

With Github, a bug in our CI auto-upload system could easily
override/delete/corrupt already-published assemblies, causing a
widespread outage to anyone depending on the bootstrap script (e.g. in
CI) until someone fixes it. It is also vulnerable to Github outages,
which are not unheard of. Distribution via Maven Central removes both
Github outages and over-writing-existing-artifacts as possible failure
modes. While Sonatype can and does have outages, that would already
cause a failure in Mill's bootstrapping, so it would be no worse than it
already is today

The validity of the various URLs and bootstrap scripts etc. have been
tested manually, but end-to-end testing will need to be done post-merge
  • Loading branch information
lihaoyi authored May 31, 2023
1 parent 75acbe7 commit db6d7d2
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,11 @@ object runner extends MillPublishScalaModule {
}
}

object dist extends MillPublishJavaModule{
def jar = dev.assembly()
def moduleDeps = Seq(runner)
}

object dev extends MillPublishScalaModule {
def moduleDeps = Seq(runner)

Expand Down Expand Up @@ -1253,8 +1258,10 @@ object dev extends MillPublishScalaModule {
mill.scalalib.Assembly.Rule.ExcludePattern("mill/local-test-overrides/.*")
)

// All modules that we want to aggregate as part of this `dev` assembly.
// Excluding itself, and the `dist` module that uses it
lazy val allPublishModules = build.millInternal.modules.collect {
case m: PublishModule if m ne this => m
case m: PublishModule if (m ne this) && (m ne dist) => m
}

def assembly = T {
Expand Down Expand Up @@ -1617,13 +1624,18 @@ def millBootstrap = T.sources(T.workspace / "mill")

def bootstrapLauncher = T {
val outputPath = T.ctx.dest / "mill"
val millBootstrapGrepPrefix = "\nDEFAULT_MILL_VERSION="
val millBootstrapGrepPrefix = "(\n *DEFAULT_MILL_VERSION=)"
val millDownloadUrlPrefix = "(\n *MILL_DOWNLOAD_URL=)"
os.write(
outputPath,
os.read(millBootstrap().head.path)
.replaceAll(
millBootstrapGrepPrefix + "[^\\n]+",
millBootstrapGrepPrefix + millVersion()
"$1" + millVersion()
)
.replaceAll(
millDownloadUrlPrefix + "[^\\n]+",
"$1" + "\"https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/\\$MILL_VERSION/mill-dist-\\$MILL_VERSION.jar\""
)
)
os.perms.set(outputPath, "rwxrwxrwx")
Expand Down

0 comments on commit db6d7d2

Please sign in to comment.