Skip to content

Commit

Permalink
Upgrade Mill to 0.11.0 (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi authored Jun 7, 2023
1 parent b7d8ea6 commit a03b76e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Run tests
run: ./mill -i all __.publishArtifacts __.test
run: ./mill -i __.publishArtifacts + __.test

check-binary-compatibility:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
0.10.5
0.11.0

92 changes: 21 additions & 71 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
import mill._, scalalib._, scalajslib._, scalanativelib._, publish._
import mill.scalalib.api.Util.isScala3
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.1.4`
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $ivy.`com.github.lolgab::mill-mima::0.0.23`
import de.tobiasroeser.mill.vcs.version.VcsVersion
import $ivy.`com.github.lolgab::mill-mima::0.0.13`
import com.github.lolgab.mill.mima._

val dottyCommunityBuildVersion = sys.props.get("dottyVersion").toList

val scalaVersions =
"2.12.16" :: "2.13.8" :: "2.11.12" :: "3.1.3" :: dottyCommunityBuildVersion

val scalaJSVersions = scalaVersions.map((_, "1.10.1"))
val scalaNativeVersions = scalaVersions.map((_, "0.4.5"))

trait PPrintModule extends PublishModule with Mima {
def artifactName = "pprint"
Seq("2.12.16", "2.13.8", "2.11.12", "3.1.3") ++ dottyCommunityBuildVersion

trait PPrintModule
extends CrossScalaModule with PublishModule with PlatformScalaModule with Mima {
def publishVersion = VcsVersion.vcsState().format()

def mimaPreviousVersions = Seq("0.7.3", "0.8.0") ++ VcsVersion.vcsState().lastTag.toSeq

def crossScalaVersion: String

def pomSettings = PomSettings(
description = artifactName(),
organization = "com.lihaoyi",
Expand All @@ -35,81 +28,38 @@ trait PPrintModule extends PublishModule with Mima {
Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi")
)
)
}
trait PPrintMainModule extends CrossScalaModule {
def millSourcePath = super.millSourcePath / offset

def ivyDeps = Agg(
ivy"com.lihaoyi::fansi::0.4.0",
ivy"com.lihaoyi::sourcecode::0.3.0"
)
def compileIvyDeps =
if (crossScalaVersion.startsWith("2")) Agg(
ivy"${scalaOrganization()}:scala-reflect:${scalaVersion()}",
ivy"${scalaOrganization()}:scala-compiler:${scalaVersion()}"
)
else Agg.empty[Dep]
def offset: os.RelPath = os.rel
def sources = T.sources(
super.sources()
.flatMap(source =>
Seq(
PathRef(source.path / os.up / source.path.last),
PathRef(source.path / os.up / os.up / source.path.last),
)
)

def compileIvyDeps = Agg.when(crossScalaVersion.startsWith("2"))(
ivy"${scalaOrganization()}:scala-reflect:${scalaVersion()}",
ivy"${scalaOrganization()}:scala-compiler:${scalaVersion()}"
)
}


trait PPrintTestModule extends ScalaModule with TestModule.Utest {
def crossScalaVersion: String
def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.8.0")
def offset: os.RelPath = os.rel
def millSourcePath = super.millSourcePath / os.up

def sources = T.sources(
super.sources()
.++(CrossModuleBase.scalaVersionPaths(crossScalaVersion, s => millSourcePath / s"src-$s" ))
.flatMap(source =>
Seq(
PathRef(source.path / os.up / "test" / source.path.last),
PathRef(source.path / os.up / os.up / "test" / source.path.last),
)
)
.distinct
)
}

object pprint extends Module {
object jvm extends Cross[JvmPPrintModule](scalaVersions:_*)
class JvmPPrintModule(val crossScalaVersion: String)
extends PPrintMainModule with ScalaModule with PPrintModule {
object test extends Tests with PPrintTestModule{
val crossScalaVersion = JvmPPrintModule.this.crossScalaVersion
}
object jvm extends Cross[JvmPPrintModule](scalaVersions)
trait JvmPPrintModule extends PPrintModule{
object test extends ScalaTests with PPrintTestModule
}

object js extends Cross[JsPPrintModule](scalaJSVersions:_*)
class JsPPrintModule(val crossScalaVersion: String, crossJSVersion: String)
extends PPrintMainModule with ScalaJSModule with PPrintModule {

def offset = os.up
def scalaJSVersion = crossJSVersion
object test extends Tests with PPrintTestModule{
def offset = os.up
val crossScalaVersion = JsPPrintModule.this.crossScalaVersion
}
object js extends Cross[JsPPrintModule](scalaVersions)
trait JsPPrintModule extends PPrintModule with ScalaJSModule {
def scalaJSVersion = "1.10.1"
object test extends ScalaJSTests with PPrintTestModule
}

object native extends Cross[NativePPrintModule](scalaNativeVersions:_*)
class NativePPrintModule(val crossScalaVersion: String, crossScalaNativeVersion: String)
extends PPrintMainModule with ScalaNativeModule with PPrintModule {
def offset = os.up
def scalaNativeVersion = crossScalaNativeVersion
object test extends Tests with PPrintTestModule{
def offset = os.up
val crossScalaVersion = NativePPrintModule.this.crossScalaVersion
}
object native extends Cross[NativePPrintModule](scalaVersions)
trait NativePPrintModule extends PPrintModule with ScalaNativeModule {
def scalaNativeVersion = "0.4.5"
object test extends ScalaNativeTests with PPrintTestModule
}

}
22 changes: 19 additions & 3 deletions mill
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
# 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=0.10.5

set -e

if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
DEFAULT_MILL_VERSION=0.11.0
fi

if [ -z "$MILL_VERSION" ] ; then
if [ -f ".mill-version" ] ; then
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)"
elif [ -f ".config/mill-version" ] ; then
MILL_VERSION="$(head -n 1 .config/mill-version 2> /dev/null)"
elif [ -f "mill" ] && [ "$0" != "mill" ] ; then
MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2)
else
Expand All @@ -35,15 +40,26 @@ if [ ! -s "$MILL_EXEC_PATH" ] ; then
fi
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download
MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION_TAG}/$MILL_VERSION${ASSEMBLY}"
MILL_DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/$MILL_VERSION/mill-dist-$MILL_VERSION.jar"
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

if [ -z "$MILL_MAIN_CLI" ] ; then
MILL_MAIN_CLI="${0}"
fi

MILL_FIRST_ARG=""
if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then
# Need to preserve the first position of those listed options
MILL_FIRST_ARG=$1
shift
fi

unset MILL_DOWNLOAD_PATH
unset MILL_VERSION

exec $MILL_EXEC_PATH "$@"
exec $MILL_EXEC_PATH $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@"

0 comments on commit a03b76e

Please sign in to comment.