Skip to content

Commit d3db7c1

Browse files
authored
Bump Mill to 0.11.0 (#67)
1 parent 3bddd87 commit d3db7c1

File tree

4 files changed

+54
-68
lines changed

4 files changed

+54
-68
lines changed

.github/workflows/actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
distribution: 'temurin'
2727
java-version: ${{ matrix.java }}
2828
- name: Run tests
29-
run: ./mill -i all __.publishArtifacts __.test
29+
run: ./mill -i __.publishArtifacts + __.test
3030
check-binary-compatibility:
3131
runs-on: ubuntu-latest
3232
steps:

.mill-version

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
0.10.12
1+
0.11.0
2+

build.sc

Lines changed: 32 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import mill._, scalalib._, scalajslib._, scalanativelib._, publish._
22
import mill.scalalib.api.ZincWorkerUtil.isScala3
3-
import scalalib._
4-
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.3.1`
3+
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
4+
import $ivy.`com.github.lolgab::mill-mima::0.0.23`
55
import de.tobiasroeser.mill.vcs.version.VcsVersion
6-
import $ivy.`com.github.lolgab::mill-mima::0.0.22`
6+
77
import com.github.lolgab.mill.mima._
88

99
val scala212 = "2.12.17"
@@ -15,21 +15,19 @@ val acyclic = "0.3.8"
1515

1616
val scalaVersions = List(scala212, scala213, scala3)
1717

18-
val scalaJSVersions = scalaVersions.map((_, "1.10.1"))
19-
val scalaNativeVersions = scalaVersions.map((_, "0.4.7"))
18+
trait MainArgsPublishModule
19+
extends PublishModule
20+
with CrossScalaModule
21+
with Mima
22+
with PlatformScalaModule {
2023

21-
trait MainArgsPublishModule extends PublishModule with CrossScalaModule with Mima {
2224
def publishVersion = VcsVersion.vcsState().format()
23-
override def mimaPreviousVersions =
24-
Seq("0.5.0")
2525

26-
override def mimaPreviousArtifacts: T[Agg[Dep]] = T {
27-
if (mimaPreviousVersions().isEmpty) Agg.empty[Dep] else super.mimaPreviousArtifacts()
28-
}
26+
override def mimaPreviousVersions = Seq("0.5.0")
27+
2928

3029
override def versionScheme: T[Option[VersionScheme]] = T(Some(VersionScheme.EarlySemVer))
3130

32-
override def artifactName = "mainargs"
3331
def pomSettings = PomSettings(
3432
description = "Main method argument parser for Scala",
3533
organization = "com.lihaoyi",
@@ -41,21 +39,20 @@ trait MainArgsPublishModule extends PublishModule with CrossScalaModule with Mim
4139
)
4240
)
4341

44-
def scalacOptions = super.scalacOptions() ++ (if (!isScala3(crossScalaVersion))
45-
Seq("-P:acyclic:force")
46-
else Seq.empty)
42+
def scalacOptions =
43+
super.scalacOptions() ++
44+
Option.when(!isScala3(scalaVersion()))("-P:acyclic:force")
4745

4846
def scalacPluginIvyDeps =
49-
super.scalacPluginIvyDeps() ++ (if (!isScala3(crossScalaVersion))
50-
Agg(ivy"com.lihaoyi:::acyclic:${acyclic}")
51-
else Agg.empty)
47+
super.scalacPluginIvyDeps() ++
48+
Option.when(!isScala3(scalaVersion()))(ivy"com.lihaoyi:::acyclic:${acyclic}")
5249

5350
def compileIvyDeps =
54-
super.compileIvyDeps() ++ (if (!isScala3(crossScalaVersion)) Agg(
55-
ivy"com.lihaoyi:::acyclic:${acyclic}",
56-
ivy"org.scala-lang:scala-reflect:$crossScalaVersion"
57-
)
58-
else Agg.empty)
51+
super.compileIvyDeps() ++
52+
Agg.when(!isScala3(crossScalaVersion))(
53+
ivy"com.lihaoyi:::acyclic:${acyclic}",
54+
ivy"org.scala-lang:scala-reflect:$crossScalaVersion"
55+
)
5956

6057
def ivyDeps = Agg(
6158
ivy"org.scala-lang.modules::scala-collection-compat::2.8.1"
@@ -64,64 +61,36 @@ trait MainArgsPublishModule extends PublishModule with CrossScalaModule with Mim
6461

6562
def scalaMajor(scalaVersion: String) = if (isScala3(scalaVersion)) "3" else "2"
6663

67-
trait Common extends CrossScalaModule {
68-
def millSourcePath = build.millSourcePath / "mainargs"
69-
def sources = T.sources(
70-
millSourcePath / "src",
71-
millSourcePath / s"src-$platform",
72-
millSourcePath / s"src-${scalaMajor(scalaVersion())}",
73-
millSourcePath / s"src-${platform}-${scalaMajor(scalaVersion())}"
74-
)
75-
def platform: String
76-
}
77-
7864
trait CommonTestModule extends ScalaModule with TestModule.Utest {
7965
def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.8.1")
80-
def sources = T.sources(
81-
millSourcePath / "src",
82-
millSourcePath / s"src-$platform",
83-
millSourcePath / s"src-${scalaMajor(scalaVersion())}",
84-
millSourcePath / s"src-${platform}-${scalaMajor(scalaVersion())}"
85-
)
86-
def platform: String
8766
}
8867

8968
object mainargs extends Module {
90-
object jvm extends Cross[JvmMainArgsModule](scalaVersions: _*)
91-
class JvmMainArgsModule(val crossScalaVersion: String)
92-
extends Common with ScalaModule with MainArgsPublishModule {
93-
def platform = "jvm"
94-
object test extends Tests with CommonTestModule {
95-
def platform = "jvm"
69+
object jvm extends Cross[JvmMainArgsModule](scalaVersions)
70+
trait JvmMainArgsModule extends MainArgsPublishModule {
71+
object test extends ScalaTests with CommonTestModule {
9672
def ivyDeps = super.ivyDeps() ++ Agg(ivy"com.lihaoyi::os-lib:${osLib}")
9773
}
9874
}
9975

100-
object js extends Cross[JSMainArgsModule](scalaJSVersions: _*)
101-
class JSMainArgsModule(val crossScalaVersion: String, crossJSVersion: String)
102-
extends Common with MainArgsPublishModule with ScalaJSModule {
103-
def platform = "js"
104-
def scalaJSVersion = crossJSVersion
105-
object test extends Tests with CommonTestModule {
106-
def platform = "js"
107-
}
76+
object js extends Cross[JSMainArgsModule](scalaVersions)
77+
trait JSMainArgsModule extends MainArgsPublishModule with ScalaJSModule {
78+
def scalaJSVersion = "1.10.1"
79+
object test extends ScalaJSTests with CommonTestModule
10880
}
10981

110-
object native extends Cross[NativeMainArgsModule](scalaNativeVersions: _*)
111-
class NativeMainArgsModule(val crossScalaVersion: String, crossScalaNativeVersion: String)
112-
extends Common with MainArgsPublishModule with ScalaNativeModule {
113-
def scalaNativeVersion = crossScalaNativeVersion
114-
def platform = "native"
115-
object test extends Tests with CommonTestModule {
116-
def platform = "native"
117-
}
82+
object native extends Cross[NativeMainArgsModule](scalaVersions)
83+
trait NativeMainArgsModule extends MainArgsPublishModule with ScalaNativeModule {
84+
def scalaNativeVersion = "0.4.7"
85+
object test extends ScalaNativeTests with CommonTestModule
11886
}
11987
}
12088

12189
trait ExampleModule extends ScalaModule {
12290
def scalaVersion = scala213
12391
def moduleDeps = Seq(mainargs.jvm(scala213))
12492
}
93+
12594
object example {
12695
object hello extends ExampleModule
12796
object hello2 extends ExampleModule

mill

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
# This is a wrapper script, that automatically download mill from GitHub release pages
44
# You can give the required mill version with MILL_VERSION env variable
55
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
6-
DEFAULT_MILL_VERSION=0.10.5
76

87
set -e
98

9+
if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
10+
DEFAULT_MILL_VERSION=0.11.0
11+
fi
12+
1013
if [ -z "$MILL_VERSION" ] ; then
1114
if [ -f ".mill-version" ] ; then
1215
MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)"
16+
elif [ -f ".config/mill-version" ] ; then
17+
MILL_VERSION="$(head -n 1 .config/mill-version 2> /dev/null)"
1318
elif [ -f "mill" ] && [ "$0" != "mill" ] ; then
1419
MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2)
1520
else
@@ -35,15 +40,26 @@ if [ ! -s "$MILL_EXEC_PATH" ] ; then
3540
fi
3641
DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download
3742
MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
38-
MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION_TAG}/$MILL_VERSION${ASSEMBLY}"
43+
MILL_DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/$MILL_VERSION/mill-dist-$MILL_VERSION.jar"
3944
curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL"
4045
chmod +x "$DOWNLOAD_FILE"
4146
mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH"
4247
unset DOWNLOAD_FILE
4348
unset MILL_DOWNLOAD_URL
4449
fi
4550

51+
if [ -z "$MILL_MAIN_CLI" ] ; then
52+
MILL_MAIN_CLI="${0}"
53+
fi
54+
55+
MILL_FIRST_ARG=""
56+
if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then
57+
# Need to preserve the first position of those listed options
58+
MILL_FIRST_ARG=$1
59+
shift
60+
fi
61+
4662
unset MILL_DOWNLOAD_PATH
4763
unset MILL_VERSION
4864

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

0 commit comments

Comments
 (0)