Skip to content

Commit 2bbee71

Browse files
authored
Update Mill to 1.0.0 (#169)
1 parent 0fc00e2 commit 2bbee71

File tree

36 files changed

+581
-339
lines changed

36 files changed

+581
-339
lines changed

.github/workflows/actions.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
java: [ '11', '17', '21' ]
19-
name: Tests local for Java ${{ matrix.Java }}
18+
java: [ '11', '21' ]
19+
name: Tests for Java ${{ matrix.Java }}
2020
steps:
2121
- uses: actions/checkout@v3
2222
- name: Setup java
@@ -28,16 +28,16 @@ jobs:
2828
run: |
2929
set -eux
3030
if [ "${{ matrix.java }}" == "21" ]; then
31-
JAVA_OPTS='--add-opens java.base/java.lang=ALL-UNNAMED -Dcask.virtual-threads.enabled=true' ./mill -ikj1 --disable-ticker __.testLocal
31+
JAVA_OPTS='--add-opens java.base/java.lang=ALL-UNNAMED -Dcask.virtual-threads.enabled=true' ./mill -i -k -j1 --disable-ticker __.testForked
3232
else
33-
./mill -ikj1 --disable-ticker __.testLocal
33+
./mill -i -k -j1 --disable-ticker __.testForked
3434
fi
3535
3636
test-examples:
3737
runs-on: ubuntu-latest
3838
strategy:
3939
matrix:
40-
java: [ '11', '17', '21' ]
40+
java: [ '11', '21' ]
4141
name: Tests examples for Java ${{ matrix.Java }}
4242
steps:
4343
- uses: actions/checkout@v3
@@ -51,10 +51,10 @@ jobs:
5151
set -eux
5252
if [ "${{ matrix.java }}" == "21" ]; then
5353
./mill __.publishLocal
54-
JAVA_OPTS='--add-opens java.base/java.lang=ALL-UNNAMED -Dcask.virtual-threads.enabled=true' ./mill -ikj1 --disable-ticker testExamples
54+
JAVA_OPTS='--add-opens java.base/java.lang=ALL-UNNAMED -Dcask.virtual-threads.enabled=true' ./mill -i -k -j1 --disable-ticker testExamples
5555
else
5656
./mill __.publishLocal
57-
./mill -ikj1 --disable-ticker testExamples
57+
./mill -i -k -j1 --disable-ticker testExamples
5858
fi
5959
6060
publish-sonatype:
@@ -98,7 +98,7 @@ jobs:
9898

9999
generate_docs:
100100
if: github.repository == 'com-lihaoyi/cask'
101-
runs-on: ubuntu-20.04
101+
runs-on: ubuntu-latest
102102
env:
103103
LANG: "en_US.UTF-8"
104104
LC_MESSAGES: "en_US.UTF-8"

.mill-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.0
1+
1.0.0

build.mill

Lines changed: 116 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1+
//| mvnDeps:
2+
//| - com.github.lolgab::mill-mima_mill1:0.2.0
3+
//| - "com.lihaoyi::mill-contrib-twirllib:$MILL_VERSION"
4+
15
package build
26

37
import mill._, scalalib._, scalajslib._, publish._
4-
import mill.scalalib.api.ZincWorkerUtil
5-
6-
import $packages._
7-
import $file.ci.upload
8-
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
9-
import $ivy.`com.github.lolgab::mill-mima::0.0.23`
10-
import de.tobiasroeser.mill.vcs.version.VcsVersion
8+
import mill.javalib.api.JvmWorkerUtil
9+
import mill.util.VcsVersion
1110

1211
val scala213 = "2.13.15"
1312
val scala212 = "2.12.20"
@@ -18,7 +17,7 @@ val communityBuildDottyVersion = sys.props.get("dottyVersion").toList
1817
val scalaVersions = List(scala212, scala213, scala3) ++ communityBuildDottyVersion
1918

2019
trait CaskModule extends CrossScalaModule with PublishModule{
21-
def isScala3 = ZincWorkerUtil.isScala3(crossScalaVersion)
20+
def isScala3 = JvmWorkerUtil.isScala3(crossScalaVersion)
2221

2322
def publishVersion = VcsVersion.vcsState().format()
2423

@@ -35,22 +34,22 @@ trait CaskModule extends CrossScalaModule with PublishModule{
3534
}
3635

3736
trait CaskMainModule extends CaskModule {
38-
def ivyDeps = T{
39-
Agg(
40-
ivy"io.undertow:undertow-core:2.3.18.Final",
41-
ivy"com.lihaoyi::upickle:4.0.2"
37+
def mvnDeps = Task {
38+
Seq(
39+
mvn"io.undertow:undertow-core:2.3.18.Final",
40+
mvn"com.lihaoyi::upickle:4.0.2"
4241
) ++
43-
Agg.when(!isScala3)(ivy"org.scala-lang:scala-reflect:$crossScalaVersion")
42+
Option.when(!isScala3)(mvn"org.scala-lang:scala-reflect:$crossScalaVersion")
4443
}
4544

46-
def compileIvyDeps = Agg.when(!isScala3)(ivy"com.lihaoyi:::acyclic:0.3.15")
47-
def scalacOptions = Agg.when(!isScala3)("-P:acyclic:force").toSeq
48-
def scalacPluginIvyDeps = Agg.when(!isScala3)(ivy"com.lihaoyi:::acyclic:0.3.15")
45+
def compileMvnDeps = Option.when(!isScala3)(mvn"com.lihaoyi:::acyclic:0.3.15").toSeq
46+
def scalacOptions = Option.when(!isScala3)("-P:acyclic:force").toSeq
47+
def scalacPluginMvnDeps = Option.when(!isScala3)(mvn"com.lihaoyi:::acyclic:0.3.15").toSeq
4948

50-
object test extends ScalaTests with TestModule.Utest{
51-
def ivyDeps = Agg(
52-
ivy"com.lihaoyi::utest::0.8.4",
53-
ivy"com.lihaoyi::requests::0.9.0"
49+
object test extends ScalaTests with TestModule.Utest {
50+
def mvnDeps = Seq(
51+
mvn"com.lihaoyi::utest::0.8.4",
52+
mvn"com.lihaoyi::requests::0.9.0"
5453
)
5554
}
5655
def moduleDeps = Seq(cask.util.jvm(crossScalaVersion))
@@ -59,35 +58,35 @@ trait CaskMainModule extends CaskModule {
5958
object cask extends Cross[CaskMainModule](scalaVersions) {
6059
object util extends Module {
6160
trait UtilModule extends CaskModule with PlatformScalaModule{
62-
def ivyDeps = Agg(
63-
ivy"com.lihaoyi::sourcecode:0.4.2",
64-
ivy"com.lihaoyi::pprint:0.9.0",
65-
ivy"com.lihaoyi::geny:1.1.1"
61+
def mvnDeps = Seq(
62+
mvn"com.lihaoyi::sourcecode:0.4.2",
63+
mvn"com.lihaoyi::pprint:0.9.0",
64+
mvn"com.lihaoyi::geny:1.1.1"
6665
)
6766
}
6867

6968
object jvm extends Cross[UtilJvmModule](scalaVersions)
7069
trait UtilJvmModule extends UtilModule {
71-
def ivyDeps = super.ivyDeps() ++ Agg(
72-
ivy"com.lihaoyi::castor::0.3.0",
73-
ivy"org.java-websocket:Java-WebSocket:1.5.3"
70+
def mvnDeps = super.mvnDeps() ++ Seq(
71+
mvn"com.lihaoyi::castor::0.3.0",
72+
mvn"org.java-websocket:Java-WebSocket:1.5.3"
7473
)
7574
}
7675

7776
object js extends Cross[UtilJsModule](scala213)
7877
trait UtilJsModule extends UtilModule with ScalaJSModule {
7978
def scalaJSVersion = scalaJS
80-
def ivyDeps = super.ivyDeps() ++ Agg(
81-
ivy"com.lihaoyi::castor::0.3.0",
82-
ivy"org.scala-js::scalajs-dom::2.4.0"
79+
def mvnDeps = super.mvnDeps() ++ Seq(
80+
mvn"com.lihaoyi::castor::0.3.0",
81+
mvn"org.scala-js::scalajs-dom::2.4.0"
8382
)
8483
}
8584
}
8685
}
8786

8887
trait BenchmarkModule extends CrossScalaModule {
8988
def moduleDeps = Seq(cask(crossScalaVersion))
90-
def ivyDeps = Agg[Dep](
89+
def mvnDeps = Seq[Dep](
9190
)
9291
}
9392

@@ -149,8 +148,8 @@ object benchmark extends Cross[BenchmarkModule](build.scalaVersions) with RunMod
149148
println(results.out.text())
150149
}
151150

152-
def runBenchmarks() = T.command {
153-
val projectRoot = T.workspace
151+
def runBenchmarks() = Task.Command {
152+
val projectRoot = mill.api.BuildCtx.workspaceRoot
154153
if (os.proc("which", "wrk").call(check = false).exitCode != 0) {
155154
println("Error: wrk is not installed. Please install wrk first.")
156155
sys.exit(1)
@@ -169,119 +168,123 @@ object benchmark extends Cross[BenchmarkModule](build.scalaVersions) with RunMod
169168
}
170169

171170
trait LocalModule extends CrossScalaModule{
172-
override def millSourcePath = super.millSourcePath / "app"
171+
override def moduleDir = super.moduleDir / "app"
173172
def moduleDeps = Seq(cask(crossScalaVersion))
174173
}
175174

176175

177176

178-
def zippedExamples = T {
179-
val vcsState = VcsVersion.vcsState()
180-
181-
val releaseTag = vcsState.lastTag.getOrElse("")
182-
val label = vcsState.format()
183-
184-
val examples = Seq(
185-
build.example.compress.millSourcePath,
186-
build.example.compress2.millSourcePath,
187-
build.example.compress3.millSourcePath,
188-
build.example.cookies.millSourcePath,
189-
build.example.decorated.millSourcePath,
190-
build.example.decorated2.millSourcePath,
191-
build.example.decoratedContext.millSourcePath,
192-
build.example.endpoints.millSourcePath,
193-
build.example.formJsonPost.millSourcePath,
194-
build.example.httpMethods.millSourcePath,
195-
build.example.minimalApplication.millSourcePath,
196-
build.example.minimalApplication2.millSourcePath,
197-
build.example.minimalApplicationWithLoom.millSourcePath,
198-
build.example.redirectAbort.millSourcePath,
199-
build.example.scalatags.millSourcePath,
200-
build.example.staticFiles.millSourcePath,
201-
build.example.staticFilesWithLoom.millSourcePath,
202-
build.example.staticFiles2.millSourcePath,
203-
build.example.todo.millSourcePath,
204-
build.example.todoApi.millSourcePath,
205-
build.example.todoDb.millSourcePath,
206-
build.example.todoDbWithLoom.millSourcePath,
207-
build.example.twirl.millSourcePath,
208-
build.example.variableRoutes.millSourcePath,
209-
build.example.queryParams.millSourcePath,
210-
build.example.websockets.millSourcePath,
211-
build.example.websockets2.millSourcePath,
212-
build.example.websockets3.millSourcePath,
213-
build.example.websockets4.millSourcePath,
214-
build.example.multipartFormSubmission.millSourcePath,
215-
)
216-
217-
for (example <- examples) yield {
218-
val f = T.ctx().dest
219-
val last = example.last + "-" + label
220-
os.copy(example, f / last)
221-
os.copy(T.workspace / ".mill-version", f / last / ".mill-version")
222-
os.write.over(f / last / "mill", os.read(T.workspace / "mill"))
223-
os.proc("chmod", "+x", f / last / "mill").call(f / last)
224-
os.move(f / last / "package.mill", f / last / "build.mill")
225-
os.write.over(
226-
f / last / "build.mill",
227-
os.read(f / last / "build.mill")
228-
.replaceAll("package build.*", "package build")
229-
.replaceAll("def moduleDeps =.*", "")
230-
.replaceAll("app =>", "")
231-
.replaceFirst(
232-
"object app extends.*\ntrait AppModule extends CrossScalaModule(.*)\\{",
233-
s"object app extends ScalaModule $$1\\{\n def scalaVersion = \"${scala213}\"")
234-
.replaceAll("build.scala3", s"\"${scala3}\"")
235-
.replaceFirst(
236-
"def ivyDeps = Agg\\[Dep\\]\\(",
237-
"def ivyDeps = Agg(\n ivy\"com.lihaoyi::cask:" + releaseTag + "\","
238-
)
177+
def zippedExamples = Task {
178+
mill.api.BuildCtx.withFilesystemCheckerDisabled {
179+
val vcsState = VcsVersion.vcsState()
180+
181+
val releaseTag = vcsState.lastTag.getOrElse("")
182+
val label = vcsState.format()
183+
184+
val examples = Seq(
185+
build.example.compress.moduleDir,
186+
build.example.compress2.moduleDir,
187+
build.example.compress3.moduleDir,
188+
build.example.cookies.moduleDir,
189+
build.example.decorated.moduleDir,
190+
build.example.decorated2.moduleDir,
191+
build.example.decoratedContext.moduleDir,
192+
build.example.endpoints.moduleDir,
193+
build.example.formJsonPost.moduleDir,
194+
build.example.httpMethods.moduleDir,
195+
build.example.minimalApplication.moduleDir,
196+
build.example.minimalApplication2.moduleDir,
197+
build.example.minimalApplicationWithLoom.moduleDir,
198+
build.example.redirectAbort.moduleDir,
199+
build.example.scalatags.moduleDir,
200+
build.example.staticFiles.moduleDir,
201+
build.example.staticFilesWithLoom.moduleDir,
202+
build.example.staticFiles2.moduleDir,
203+
build.example.todo.moduleDir,
204+
build.example.todoApi.moduleDir,
205+
build.example.todoDb.moduleDir,
206+
build.example.todoDbWithLoom.moduleDir,
207+
build.example.twirl.moduleDir,
208+
build.example.variableRoutes.moduleDir,
209+
build.example.queryParams.moduleDir,
210+
build.example.websockets.moduleDir,
211+
build.example.websockets2.moduleDir,
212+
build.example.websockets3.moduleDir,
213+
build.example.websockets4.moduleDir,
214+
build.example.multipartFormSubmission.moduleDir,
239215
)
240216

241-
os.zip(f / s"$last.zip", Seq(f / last))
242-
PathRef(f / s"$last.zip")
217+
for (example <- examples) yield {
218+
val f = Task.ctx().dest
219+
val last = example.last + "-" + label
220+
os.copy(example, f / last)
221+
os.copy(mill.api.BuildCtx.workspaceRoot / ".mill-version", f / last / ".mill-version")
222+
os.write.over(f / last / "mill", os.read(mill.api.BuildCtx.workspaceRoot / "mill"))
223+
os.proc("chmod", "+x", f / last / "mill").call(f / last)
224+
os.move(f / last / "package.mill", f / last / "build.mill")
225+
os.write.over(
226+
f / last / "build.mill",
227+
os.read(f / last / "build.mill")
228+
.replaceAll("package build.*", "package build")
229+
.replaceAll("def moduleDeps =.*", "")
230+
.replaceAll("///", "//|")
231+
.replaceAll("app =>", "")
232+
.replaceFirst(
233+
"object app extends.*\ntrait AppModule extends CrossScalaModule(.*)\\{",
234+
s"object app extends ScalaModule $$1\\{\n def scalaVersion = \"${scala213}\"")
235+
.replaceAll("build.scala3", s"\"${scala3}\"")
236+
.replaceFirst(
237+
"def mvnDeps = Seq\\[Dep\\]\\(",
238+
"def mvnDeps = Seq(\n mvn\"com.lihaoyi::cask:" + releaseTag + "\","
239+
)
240+
)
241+
242+
os.zip(f / s"$last.zip", Seq(f / last))
243+
PathRef(f / s"$last.zip")
244+
}
243245
}
244246
}
245247

246-
def testExamples() = T.command{
248+
def testExamples() = Task.Command{
247249

248250
for(example <- zippedExamples()){
249251
println("Testing " + example.path.last)
250-
val base = T.dest / example.path.baseName
252+
val base = Task.dest / example.path.baseName
251253
os.unzip(example.path, base)
252254
os.perms.set(base / "mill", "rwxrwxrwx")
253255
os.write.over(
254256
base / "build.mill",
255257
os.read(base / "build.mill").replaceAll(
256-
"ivy\"com.lihaoyi::cask:.*\"",
257-
s"""ivy"com.lihaoyi::cask:${VcsVersion.vcsState().format()}""""
258+
"mvn\"com.lihaoyi::cask:.*\"",
259+
s"""mvn"com.lihaoyi::cask:${VcsVersion.vcsState().format()}""""
258260
)
259261
)
260262
os.proc("./mill", "app.test").call(cwd = base, stdout = os.Inherit)
263+
os.proc("./mill", "shutdown").call(cwd = base, stdout = os.Inherit)
261264
}
262265
}
263266

264-
def uploadToGithub() = T.command{
265-
val vcsState = VcsVersion.vcsState()
267+
def uploadToGithub() = Task.Command {
268+
// Separate this out because the Task.Command macro has bugs when
269+
// interacting with request-scala's implicit conversions
270+
doUploadToGithub(VcsVersion.vcsState(), zippedExamples())
271+
}
272+
273+
def doUploadToGithub(vcsState: VcsVersion.State,
274+
zippedExamples: Seq[PathRef])(implicit ctx: mill.api.TaskCtx) = {
266275

267-
val authKey = T.env.apply("AMMONITE_BOT_AUTH_TOKEN")
276+
val authKey = Task.env.apply("AMMONITE_BOT_AUTH_TOKEN")
268277
val releaseTag = vcsState.lastTag.getOrElse("")
269278
val label = vcsState.format()
270279
if (releaseTag == label) {
271280
requests.post(
272281
"https://api.github.com/repos/com-lihaoyi/cask/releases",
273-
data = ujson.write(
274-
ujson.Obj(
275-
"tag_name" -> releaseTag,
276-
"name" -> releaseTag
277-
)
278-
),
282+
data = ujson.Obj("tag_name" -> releaseTag, "name" -> releaseTag),
279283
headers = Seq("Authorization" -> s"token $authKey")
280284
)
281285
}
282286

283-
for(example <- zippedExamples()){
284-
285-
upload.apply(example.path, releaseTag, example.path.last, authKey)
287+
for(example <- zippedExamples){
288+
ci.upload(example.path, releaseTag, example.path.last, authKey)
286289
}
287290
}

ci/upload.mill

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package build.ci
22

3-
import $ivy.`com.lihaoyi::os-lib:0.8.1`
4-
53
@mainargs.main
6-
def apply(uploadedFile: os.Path,
4+
def upload(uploadedFile: os.Path,
75
tagName: String,
86
uploadName: String,
97
authKey: String): String = {

0 commit comments

Comments
 (0)