diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2019-07-08 07:32:41 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2019-07-08 07:33:15 +0800 |
commit | 084a1d9dfbf67a570148027ddbe1189647d5bb75 (patch) | |
tree | 43517763aaf2abd6bf90375e2057921055d70d99 | |
parent | a8d1adf065f3e494bb91034960afcc7198957a2e (diff) | |
download | mill-084a1d9dfbf67a570148027ddbe1189647d5bb75.tar.gz mill-084a1d9dfbf67a570148027ddbe1189647d5bb75.tar.bz2 mill-084a1d9dfbf67a570148027ddbe1189647d5bb75.zip |
separate launcher from executable assembly
-rwxr-xr-x | build.sc | 70 | ||||
-rwxr-xr-x | main/mill-template | 31 | ||||
-rwxr-xr-x | mill | 2 |
3 files changed, 23 insertions, 80 deletions
@@ -61,8 +61,6 @@ trait MillModule extends MillApiModule{ outer => object main extends MillModule { def moduleDeps = Seq(core, client) - def millBootstrap = T.sources(millSourcePath / "mill-template") - def compileIvyDeps = Agg( ivy"org.scala-lang:scala-reflect:${scalaVersion()}" ) @@ -444,30 +442,14 @@ object integration extends MillModule{ def launcherScript(shellJvmArgs: Seq[String], cmdJvmArgs: Seq[String], shellClassPath: Agg[String], - cmdClassPath: Agg[String], - millBootstrapStringValue: String) = { + cmdClassPath: Agg[String]) = { mill.modules.Jvm.universalScript( shellCommands = { val jvmArgsStr = shellJvmArgs.mkString(" ") def java(mainClass: String) = s"""exec $$JAVACMD $jvmArgsStr $$JAVA_OPTS -cp "${shellClassPath.mkString(":")}" $mainClass "$$@"""" - val bootstrapPrefix = - if (millBootstrapString == "") "" - else { - val cutCount = millBootstrapGrepPrefix.length + 1 - s"""if [ -f "mill" ] ; then - | if [ -z "$$MILL_EXEC_PATH" ] ; then - | MILL_VERSION=$$(grep -F "$millBootstrapGrepPrefix" "$$PWD/mill" | cut -c $cutCount-) - | ${millBootstrapStringValue.replace("\n", "\n ")} - | fi - |fi - | - |""".stripMargin - } - s"""$bootstrapPrefix - | - |if [ -z "$$JAVA_HOME" ] ; then + s"""if [ -z "$$JAVA_HOME" ] ; then | JAVACMD="java" |else | JAVACMD="$$JAVA_HOME/bin/java" @@ -499,13 +481,6 @@ def launcherScript(shellJvmArgs: Seq[String], ) } -val millBootstrapGrepPrefix = "DEFAULT_MILL_VERSION=" - -def millBootstrapString = T{ - os.read(main.millBootstrap().head.path) - .replace(millBootstrapGrepPrefix, millBootstrapGrepPrefix + publishVersion()) -} - object dev extends MillModule{ def moduleDeps = Seq(scalalib, scalajslib, scalanativelib, contrib.scalapblib, contrib.tut, contrib.scoverage) @@ -581,7 +556,7 @@ object dev extends MillModule{ cmdArgs, classpath, classpath, - millBootstrapString() + "" ) } @@ -602,10 +577,11 @@ object dev extends MillModule{ } } -def releaseBase(version: String, - devRunClasspath: Seq[os.Path], - bootstrapString: String) - (implicit ctx: mill.api.Ctx) = { + +def assembly = T{ + + val version = publishVersion()._2 + val devRunClasspath = dev.runClasspath().map(_.path) val filename = if (scala.util.Properties.isWin) "mill.bat" else "mill" val commonArgs = Seq( "-DMILL_VERSION=" + version, @@ -622,8 +598,7 @@ def releaseBase(version: String, shellArgs, cmdArgs, Agg("$0"), - Agg("%~dpnx0"), - bootstrapString + Agg("%~dpnx0") ) ).path, ctx.dest / filename @@ -631,20 +606,19 @@ def releaseBase(version: String, PathRef(ctx.dest / filename) } -def executable = T{ - releaseBase( - publishVersion()._2, - dev.runClasspath().map(_.path), - "" - ) -} +def millBootstrap = T.sources(os.pwd / "mill") -def release = T{ - releaseBase( - publishVersion()._2, - dev.runClasspath().map(_.path), - millBootstrapString() +def launcher = T{ + val millBootstrapGrepPrefix = "DEFAULT_MILL_VERSION=" + os.write( + T.ctx().dest / "mill", + os.read(main.millBootstrap().head.path) + .replaceAll( + millBootstrapGrepPrefix + "[^\\n]+", + millBootstrapGrepPrefix + publishVersion()._2 + ) ) + T.ctx().dest / "mill" } val isMasterCommit = { @@ -699,9 +673,9 @@ def uploadToGithub(authKey: String) = T.command{ .asString } - upload.apply(executable().path, releaseTag, label + "-direct", authKey) + upload.apply(assembly().path, releaseTag, label + "-assembly", authKey) - upload.apply(release().path, releaseTag, label, authKey) + upload.apply(launcher().path, releaseTag, label, authKey) val bootstrapScript = T.ctx().dest / "mill-bootstrap" diff --git a/main/mill-template b/main/mill-template deleted file mode 100755 index 084f5e99..00000000 --- a/main/mill-template +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env sh - -# This is a wrapper script, that automatically download mill from GitHub release pages -# You can give the required mill version with MILL_VERSION env variable -# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION -DEFAULT_MILL_VERSION= - -set -e - -if [ -z "$MILL_VERSION" ] ; then - MILL_VERSION=$DEFAULT_MILL_VERSION -fi - -MILL_DOWNLOAD_PATH="$HOME/.mill/download" -MILL_EXEC_PATH="${MILL_DOWNLOAD_PATH}/$MILL_VERSION" - -if [ ! -x "$MILL_EXEC_PATH" ] ; then - mkdir -p $MILL_DOWNLOAD_PATH - DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download - MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION" - curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" - chmod +x "$DOWNLOAD_FILE" - mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH" - unset DOWNLOAD_FILE - unset MILL_DOWNLOAD_URL -fi - -unset MILL_DOWNLOAD_PATH -unset MILL_VERSION - -exec $MILL_EXEC_PATH "$@"
\ No newline at end of file @@ -32,4 +32,4 @@ fi unset MILL_DOWNLOAD_PATH unset MILL_VERSION -exec $MILL_EXEC_PATH "$@"
\ No newline at end of file +exec $MILL_EXEC_PATH "$@" |