From 87008d80f6c10540251793998de2ba5cbba1c0bb Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 22 Oct 2024 07:58:21 +0800 Subject: [PATCH 1/9] Update .mill-version --- .mill-version | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.mill-version b/.mill-version index 98cd2344e4..53cf705c90 100644 --- a/.mill-version +++ b/.mill-version @@ -1,2 +1 @@ -0.11.11 - +0.12.0-RC3-102-b8217f From 23754d549a44038eaf62c169b9e2025e232108b6 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 22 Oct 2024 08:35:27 +0800 Subject: [PATCH 2/9] wip --- build.mill | 167 +++++++++++ build.sc | 267 ------------------ ci/package.mill | 1 + ci/{upload.sc => upload.mill} | 2 +- example/compress/package.mill | 18 ++ example/compress2/package.mill | 18 ++ example/compress3/build.sc | 14 - example/compress3/package.mill | 18 ++ example/cookies/build.sc | 14 - .../build.sc => cookies/package.mill} | 4 + example/decorated/build.sc | 14 - example/decorated/package.mill | 18 ++ example/decorated2/build.sc | 14 - example/decorated2/package.mill | 18 ++ example/endpoints/build.sc | 14 - example/endpoints/package.mill | 18 ++ .../formJsonPost/{build.sc => package.mill} | 4 + .../httpMethods/{build.sc => package.mill} | 4 + example/minimalApplication/build.sc | 14 - example/minimalApplication/package.mill | 18 ++ example/minimalApplication2/build.sc | 14 - example/minimalApplication2/package.mill | 18 ++ example/package.mill | 1 + example/queryParams/build.sc | 14 - example/queryParams/package.mill | 18 ++ example/redirectAbort/build.sc | 14 - example/redirectAbort/package.mill | 18 ++ example/scalatags/{build.sc => package.mill} | 4 + .../staticFiles/{build.sc => package.mill} | 4 + .../staticFiles2/{build.sc => package.mill} | 4 + example/todo/{build.sc => package.mill} | 4 + example/todoApi/build.sc | 14 - .../build.sc => todoApi/package.mill} | 4 + example/todoDb/{build.sc => package.mill} | 4 + example/twirl/{build.sc => package.mill} | 5 +- example/variableRoutes/build.sc | 14 - example/variableRoutes/package.mill | 18 ++ .../build.sc => websockets/package.mill} | 4 + .../build.sc => websockets2/package.mill} | 4 + .../build.sc => websockets3/package.mill} | 4 + .../build.sc => websockets4/package.mill} | 1 + 41 files changed, 421 insertions(+), 423 deletions(-) create mode 100644 build.mill delete mode 100644 build.sc create mode 100644 ci/package.mill rename ci/{upload.sc => upload.mill} (98%) create mode 100644 example/compress/package.mill create mode 100644 example/compress2/package.mill delete mode 100644 example/compress3/build.sc create mode 100644 example/compress3/package.mill delete mode 100644 example/cookies/build.sc rename example/{compress/build.sc => cookies/package.mill} (65%) delete mode 100644 example/decorated/build.sc create mode 100644 example/decorated/package.mill delete mode 100644 example/decorated2/build.sc create mode 100644 example/decorated2/package.mill delete mode 100644 example/endpoints/build.sc create mode 100644 example/endpoints/package.mill rename example/formJsonPost/{build.sc => package.mill} (64%) rename example/httpMethods/{build.sc => package.mill} (69%) delete mode 100644 example/minimalApplication/build.sc create mode 100644 example/minimalApplication/package.mill delete mode 100644 example/minimalApplication2/build.sc create mode 100644 example/minimalApplication2/package.mill create mode 100644 example/package.mill delete mode 100644 example/queryParams/build.sc create mode 100644 example/queryParams/package.mill delete mode 100644 example/redirectAbort/build.sc create mode 100644 example/redirectAbort/package.mill rename example/scalatags/{build.sc => package.mill} (68%) rename example/staticFiles/{build.sc => package.mill} (77%) rename example/staticFiles2/{build.sc => package.mill} (77%) rename example/todo/{build.sc => package.mill} (76%) delete mode 100644 example/todoApi/build.sc rename example/{compress2/build.sc => todoApi/package.mill} (65%) rename example/todoDb/{build.sc => package.mill} (72%) rename example/twirl/{build.sc => package.mill} (82%) delete mode 100644 example/variableRoutes/build.sc create mode 100644 example/variableRoutes/package.mill rename example/{websockets2/build.sc => websockets/package.mill} (69%) rename example/{websockets3/build.sc => websockets2/package.mill} (69%) rename example/{websockets4/build.sc => websockets3/package.mill} (69%) rename example/{websockets/build.sc => websockets4/package.mill} (90%) diff --git a/build.mill b/build.mill new file mode 100644 index 0000000000..30e766a3f5 --- /dev/null +++ b/build.mill @@ -0,0 +1,167 @@ +package build + +import mill._, scalalib._, scalajslib._, publish._ +import mill.scalalib.api.ZincWorkerUtil + +import $packages._ +import $file.ci.upload +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 + +val scala213 = "2.13.10" +val scala212 = "2.12.17" +val scala3 = "3.2.2" +val scalaJS = "1.13.0" +val communityBuildDottyVersion = sys.props.get("dottyVersion").toList + +val scalaVersions = List(scala212, scala213, scala3) ++ communityBuildDottyVersion + +trait CaskModule extends CrossScalaModule with PublishModule{ + def isScala3 = ZincWorkerUtil.isScala3(crossScalaVersion) + + def publishVersion = VcsVersion.vcsState().format() + + def pomSettings = PomSettings( + description = artifactName(), + organization = "com.lihaoyi", + url = "https://github.com/com-lihaoyi/cask", + licenses = Seq(License.MIT), + versionControl = VersionControl.github("com-lihaoyi", "cask"), + developers = Seq( + Developer("lihaoyi", "Li Haoyi","https://github.com/lihaoyi") + ) + ) +} + +trait CaskMainModule extends CaskModule { + def ivyDeps = T{ + Agg( + ivy"io.undertow:undertow-core:2.3.10.Final", + ivy"com.lihaoyi::upickle:3.0.0" + ) ++ + Agg.when(!isScala3)(ivy"org.scala-lang:scala-reflect:$crossScalaVersion") + } + + def compileIvyDeps = Agg.when(!isScala3)(ivy"com.lihaoyi:::acyclic:0.3.6") + def scalacOptions = Agg.when(!isScala3)("-P:acyclic:force").toSeq + def scalacPluginIvyDeps = Agg.when(!isScala3)(ivy"com.lihaoyi:::acyclic:0.3.6") + + object test extends ScalaTests with TestModule.Utest{ + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0" + ) + } + def moduleDeps = Seq(cask.util.jvm(crossScalaVersion)) +} + +object cask extends Cross[CaskMainModule](scalaVersions) { + object util extends Module { + trait UtilModule extends CaskModule with PlatformScalaModule{ + def ivyDeps = Agg( + ivy"com.lihaoyi::sourcecode:0.3.0", + ivy"com.lihaoyi::pprint:0.8.1", + ivy"com.lihaoyi::geny:1.0.0" + ) + } + + object jvm extends Cross[UtilJvmModule](scalaVersions) + trait UtilJvmModule extends UtilModule { + def ivyDeps = super.ivyDeps() ++ Agg( + ivy"com.lihaoyi::castor::0.3.0", + ivy"org.java-websocket:Java-WebSocket:1.5.3" + ) + } + + object js extends Cross[UtilJsModule](scala213) + trait UtilJsModule extends UtilModule with ScalaJSModule { + def scalaJSVersion = scalaJS + def ivyDeps = super.ivyDeps() ++ Agg( + ivy"com.lihaoyi::castor::0.3.0", + ivy"org.scala-js::scalajs-dom::2.4.0" + ) + } + } +} + +trait LocalModule extends CrossScalaModule{ + override def millSourcePath = super.millSourcePath / "app" + def moduleDeps = Seq(cask(crossScalaVersion)) +} + + + +def uploadToGithub() = T.command{ + val vcsState = VcsVersion.vcsState() + + val authKey = T.env.apply("AMMONITE_BOT_AUTH_TOKEN") + val releaseTag = vcsState.lastTag.getOrElse("") + val label = vcsState.format() + if (releaseTag == label){ + requests.post( + "https://api.github.com/repos/com-lihaoyi/cask/releases", + data = ujson.write( + ujson.Obj( + "tag_name" -> releaseTag, + "name" -> releaseTag + ) + ), + headers = Seq("Authorization" -> s"token $authKey") + ) + } + + val examples = Seq( + build.example.compress.millSourcePath, + build.example.compress2.millSourcePath, + build.example.compress3.millSourcePath, + build.example.cookies.millSourcePath, + build.example.decorated.millSourcePath, + build.example.decorated2.millSourcePath, + build.example.endpoints.millSourcePath, + build.example.formJsonPost.millSourcePath, + build.example.httpMethods.millSourcePath, + build.example.minimalApplication.millSourcePath, + build.example.minimalApplication2.millSourcePath, + build.example.redirectAbort.millSourcePath, + build.example.scalatags.millSourcePath, + build.example.staticFiles.millSourcePath, + build.example.staticFiles2.millSourcePath, + build.example.todo.millSourcePath, + build.example.todoApi.millSourcePath, + build.example.todoDb.millSourcePath, + build.example.twirl.millSourcePath, + build.example.variableRoutes.millSourcePath, + build.example.queryParams.millSourcePath, + build.example.websockets.millSourcePath, + build.example.websockets2.millSourcePath, + build.example.websockets3.millSourcePath, + build.example.websockets4.millSourcePath, + ) + + for(example <- examples){ + val f = T.ctx().dest + val last = example.last + "-" + label + os.copy(example, f / last) + os.write.over( + f / last / "mill", + os.read(os.pwd / "mill") + ) + os.proc("chmod", "+x", f/last/"mill").call(f/last) + os.write.over( + f / last / "build.sc", + os.read(f / last / "build.sc") + .replaceFirst( + "trait AppModule extends CrossScalaModule\\s*\\{", + s"object app extends ScalaModule \\{\n def scalaVersion = \"${scala213}\"") + .replaceFirst( + "def ivyDeps = Agg\\[Dep\\]\\(", + "def ivyDeps = Agg(\n ivy\"com.lihaoyi::cask:" + releaseTag + "\"," + ) + ) + + os.remove.all(f / "out.zip") + os.proc("zip", "-r", f / "out.zip", last).call(f) + upload.apply(f / "out.zip", releaseTag, last + ".zip", authKey) + } +} diff --git a/build.sc b/build.sc deleted file mode 100644 index c836fcbdf8..0000000000 --- a/build.sc +++ /dev/null @@ -1,267 +0,0 @@ -import mill._, scalalib._, scalajslib._, publish._ -import mill.scalalib.api.ZincWorkerUtil - -import $file.example.compress.build -import $file.example.compress2.build -import $file.example.compress3.build -import $file.example.cookies.build -import $file.example.decorated.build -import $file.example.decorated2.build -import $file.example.endpoints.build -import $file.example.formJsonPost.build -import $file.example.httpMethods.build -import $file.example.minimalApplication.build -import $file.example.minimalApplication2.build -import $file.example.redirectAbort.build -import $file.example.scalatags.build -import $file.example.staticFiles.build -import $file.example.staticFiles2.build -import $file.example.todo.build -import $file.example.todoApi.build -import $file.example.todoDb.build -import $file.example.twirl.build -import $file.example.variableRoutes.build -import $file.example.queryParams.build -import $file.example.websockets.build -import $file.example.websockets2.build -import $file.example.websockets3.build -import $file.example.websockets4.build -import $file.ci.upload -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 - -val scala213 = "2.13.10" -val scala212 = "2.12.17" -val scala3 = "3.2.2" -val scalaJS = "1.13.0" -val communityBuildDottyVersion = sys.props.get("dottyVersion").toList - -val scalaVersions = List(scala212, scala213, scala3) ++ communityBuildDottyVersion - -trait CaskModule extends CrossScalaModule with PublishModule{ - def isScala3 = ZincWorkerUtil.isScala3(crossScalaVersion) - - def publishVersion = VcsVersion.vcsState().format() - - def pomSettings = PomSettings( - description = artifactName(), - organization = "com.lihaoyi", - url = "https://github.com/com-lihaoyi/cask", - licenses = Seq(License.MIT), - versionControl = VersionControl.github("com-lihaoyi", "cask"), - developers = Seq( - Developer("lihaoyi", "Li Haoyi","https://github.com/lihaoyi") - ) - ) -} - -trait CaskMainModule extends CaskModule { - def ivyDeps = T{ - Agg( - ivy"io.undertow:undertow-core:2.3.10.Final", - ivy"com.lihaoyi::upickle:3.0.0" - ) ++ - Agg.when(!isScala3)(ivy"org.scala-lang:scala-reflect:$crossScalaVersion") - } - - def compileIvyDeps = Agg.when(!isScala3)(ivy"com.lihaoyi:::acyclic:0.3.6") - def scalacOptions = Agg.when(!isScala3)("-P:acyclic:force").toSeq - def scalacPluginIvyDeps = Agg.when(!isScala3)(ivy"com.lihaoyi:::acyclic:0.3.6") - - object test extends ScalaTests with TestModule.Utest{ - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0" - ) - } - def moduleDeps = Seq(cask.util.jvm(crossScalaVersion)) -} - -object cask extends Cross[CaskMainModule](scalaVersions) { - object util extends Module { - trait UtilModule extends CaskModule with PlatformScalaModule{ - def ivyDeps = Agg( - ivy"com.lihaoyi::sourcecode:0.3.0", - ivy"com.lihaoyi::pprint:0.8.1", - ivy"com.lihaoyi::geny:1.0.0" - ) - } - - object jvm extends Cross[UtilJvmModule](scalaVersions) - trait UtilJvmModule extends UtilModule { - def ivyDeps = super.ivyDeps() ++ Agg( - ivy"com.lihaoyi::castor::0.3.0", - ivy"org.java-websocket:Java-WebSocket:1.5.3" - ) - } - - object js extends Cross[UtilJsModule](scala213) - trait UtilJsModule extends UtilModule with ScalaJSModule { - def scalaJSVersion = scalaJS - def ivyDeps = super.ivyDeps() ++ Agg( - ivy"com.lihaoyi::castor::0.3.0", - ivy"org.scala-js::scalajs-dom::2.4.0" - ) - } - } -} - -object example extends Module{ - trait LocalModule extends CrossScalaModule{ - override def millSourcePath = super.millSourcePath / "app" - def moduleDeps = Seq(cask(crossScalaVersion)) - } - - trait CompressModule extends millbuild.example.compress.build.AppModule with LocalModule - object compress extends Cross[CompressModule](scalaVersions) - - trait Compress2Module extends millbuild.example.compress2.build.AppModule with LocalModule - object compress2 extends Cross[Compress2Module](scalaVersions) - - trait Compress3Module extends millbuild.example.compress3.build.AppModule with LocalModule - object compress3 extends Cross[Compress3Module](scalaVersions) - - trait CookiesModule extends millbuild.example.cookies.build.AppModule with LocalModule - object cookies extends Cross[CookiesModule](scalaVersions) - - trait DecoratedModule extends millbuild.example.decorated.build.AppModule with LocalModule - object decorated extends Cross[DecoratedModule](scalaVersions) - - trait Decorated2Module extends millbuild.example.decorated2.build.AppModule with LocalModule - object decorated2 extends Cross[Decorated2Module](scalaVersions) - - trait EndpointsModule extends millbuild.example.endpoints.build.AppModule with LocalModule - object endpoints extends Cross[EndpointsModule](scalaVersions) - - trait FormJsonPostModule extends millbuild.example.formJsonPost.build.AppModule with LocalModule - object formJsonPost extends Cross[FormJsonPostModule](scalaVersions) - - trait HttpMethodsModule extends millbuild.example.httpMethods.build.AppModule with LocalModule - object httpMethods extends Cross[HttpMethodsModule](scalaVersions) - - trait MinimalApplicationModule extends millbuild.example.minimalApplication.build.AppModule with LocalModule - object minimalApplication extends Cross[MinimalApplicationModule](scalaVersions) - - trait MinimalApplication2Module extends millbuild.example.minimalApplication2.build.AppModule with LocalModule - object minimalApplication2 extends Cross[MinimalApplication2Module](scalaVersions) - - trait RedirectAbortModule extends millbuild.example.redirectAbort.build.AppModule with LocalModule - object redirectAbort extends Cross[RedirectAbortModule](scalaVersions) - - trait ScalatagsModule extends millbuild.example.scalatags.build.AppModule with LocalModule - object scalatags extends Cross[ScalatagsModule](scala212, scala213) - - trait StaticFilesModule extends millbuild.example.staticFiles.build.AppModule with LocalModule - object staticFiles extends Cross[StaticFilesModule](scalaVersions) - - trait StaticFiles2Module extends millbuild.example.staticFiles2.build.AppModule with LocalModule - object staticFiles2 extends Cross[StaticFiles2Module](scalaVersions) - - trait TodoModule extends millbuild.example.todo.build.AppModule with LocalModule - object todo extends Cross[TodoModule](scala213) // uses quill, can't enable for Dotty yet - - trait TodoApiModule extends millbuild.example.todoApi.build.AppModule with LocalModule - object todoApi extends Cross[TodoApiModule](scalaVersions) - - trait TodoDbModule extends millbuild.example.todoDb.build.AppModule with LocalModule - object todoDb extends Cross[TodoDbModule](scala213) // uses quill, can't enable for Dotty yet - - trait TwirlModule extends millbuild.example.twirl.build.AppModule with LocalModule - object twirl extends Cross[TwirlModule](scalaVersions) - - trait VariableRoutesModule extends millbuild.example.variableRoutes.build.AppModule with LocalModule - object variableRoutes extends Cross[VariableRoutesModule](scalaVersions) - - trait QueryParamsModule extends millbuild.example.variableRoutes.build.AppModule with LocalModule - object queryParams extends Cross[QueryParamsModule](scalaVersions) - - trait WebsocketsModule extends millbuild.example.websockets.build.AppModule with LocalModule - object websockets extends Cross[WebsocketsModule](scalaVersions) - - trait Websockets2Module extends millbuild.example.websockets2.build.AppModule with LocalModule - object websockets2 extends Cross[Websockets2Module](scalaVersions) - - trait Websockets3Module extends millbuild.example.websockets3.build.AppModule with LocalModule - object websockets3 extends Cross[Websockets3Module](scalaVersions) - - trait Websockets4Module extends millbuild.example.websockets4.build.AppModule with LocalModule - object websockets4 extends Cross[Websockets4Module](scalaVersions) - -} - - - -def uploadToGithub() = T.command{ - val vcsState = VcsVersion.vcsState() - - val authKey = T.env.apply("AMMONITE_BOT_AUTH_TOKEN") - val releaseTag = vcsState.lastTag.getOrElse("") - val label = vcsState.format() - if (releaseTag == label){ - requests.post( - "https://api.github.com/repos/com-lihaoyi/cask/releases", - data = ujson.write( - ujson.Obj( - "tag_name" -> releaseTag, - "name" -> releaseTag - ) - ), - headers = Seq("Authorization" -> s"token $authKey") - ) - } - - val examples = Seq( - millbuild.example.compress.build.millSourcePath, - millbuild.example.compress2.build.millSourcePath, - millbuild.example.compress3.build.millSourcePath, - millbuild.example.cookies.build.millSourcePath, - millbuild.example.decorated.build.millSourcePath, - millbuild.example.decorated2.build.millSourcePath, - millbuild.example.endpoints.build.millSourcePath, - millbuild.example.formJsonPost.build.millSourcePath, - millbuild.example.httpMethods.build.millSourcePath, - millbuild.example.minimalApplication.build.millSourcePath, - millbuild.example.minimalApplication2.build.millSourcePath, - millbuild.example.redirectAbort.build.millSourcePath, - millbuild.example.scalatags.build.millSourcePath, - millbuild.example.staticFiles.build.millSourcePath, - millbuild.example.staticFiles2.build.millSourcePath, - millbuild.example.todo.build.millSourcePath, - millbuild.example.todoApi.build.millSourcePath, - millbuild.example.todoDb.build.millSourcePath, - millbuild.example.twirl.build.millSourcePath, - millbuild.example.variableRoutes.build.millSourcePath, - millbuild.example.queryParams.build.millSourcePath, - millbuild.example.websockets.build.millSourcePath, - millbuild.example.websockets2.build.millSourcePath, - millbuild.example.websockets3.build.millSourcePath, - millbuild.example.websockets4.build.millSourcePath, - ) - - for(example <- examples){ - val f = T.ctx().dest - val last = example.last + "-" + label - os.copy(example, f / last) - os.write.over( - f / last / "mill", - os.read(os.pwd / "mill") - ) - os.proc("chmod", "+x", f/last/"mill").call(f/last) - os.write.over( - f / last / "build.sc", - os.read(f / last / "build.sc") - .replaceFirst( - "trait AppModule extends CrossScalaModule\\s*\\{", - s"object app extends ScalaModule \\{\n def scalaVersion = \"${scala213}\"") - .replaceFirst( - "def ivyDeps = Agg\\[Dep\\]\\(", - "def ivyDeps = Agg(\n ivy\"com.lihaoyi::cask:" + releaseTag + "\"," - ) - ) - - os.remove.all(f / "out.zip") - os.proc("zip", "-r", f / "out.zip", last).call(f) - upload.apply(f / "out.zip", releaseTag, last + ".zip", authKey) - } -} diff --git a/ci/package.mill b/ci/package.mill new file mode 100644 index 0000000000..6a5b3e8b8e --- /dev/null +++ b/ci/package.mill @@ -0,0 +1 @@ +package build.ci \ No newline at end of file diff --git a/ci/upload.sc b/ci/upload.mill similarity index 98% rename from ci/upload.sc rename to ci/upload.mill index 5ec56471cd..519a367ec1 100644 --- a/ci/upload.sc +++ b/ci/upload.mill @@ -1,4 +1,4 @@ -#!/usr/bin/env amm +package build.ci import $ivy.`com.lihaoyi::os-lib:0.8.1` diff --git a/example/compress/package.mill b/example/compress/package.mill new file mode 100644 index 0000000000..19c087b06c --- /dev/null +++ b/example/compress/package.mill @@ -0,0 +1,18 @@ +package build.example.compress +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/compress2/package.mill b/example/compress2/package.mill new file mode 100644 index 0000000000..0710630472 --- /dev/null +++ b/example/compress2/package.mill @@ -0,0 +1,18 @@ +package build.example.compress2 +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/compress3/build.sc b/example/compress3/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/compress3/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/compress3/package.mill b/example/compress3/package.mill new file mode 100644 index 0000000000..1cbfdc8662 --- /dev/null +++ b/example/compress3/package.mill @@ -0,0 +1,18 @@ +package build.example.compress3 +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/cookies/build.sc b/example/cookies/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/cookies/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/compress/build.sc b/example/cookies/package.mill similarity index 65% rename from example/compress/build.sc rename to example/cookies/package.mill index 75de91ef2f..6161b508be 100644 --- a/example/compress/build.sc +++ b/example/cookies/package.mill @@ -1,7 +1,11 @@ +package build.example.cookies import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ diff --git a/example/decorated/build.sc b/example/decorated/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/decorated/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/decorated/package.mill b/example/decorated/package.mill new file mode 100644 index 0000000000..336cab7d41 --- /dev/null +++ b/example/decorated/package.mill @@ -0,0 +1,18 @@ +package build.example.decorated +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/decorated2/build.sc b/example/decorated2/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/decorated2/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/decorated2/package.mill b/example/decorated2/package.mill new file mode 100644 index 0000000000..b7e2963ac4 --- /dev/null +++ b/example/decorated2/package.mill @@ -0,0 +1,18 @@ +package build.example.decorated2 +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/endpoints/build.sc b/example/endpoints/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/endpoints/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/endpoints/package.mill b/example/endpoints/package.mill new file mode 100644 index 0000000000..04b3db8ea2 --- /dev/null +++ b/example/endpoints/package.mill @@ -0,0 +1,18 @@ +package build.example.endpoints +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/formJsonPost/build.sc b/example/formJsonPost/package.mill similarity index 64% rename from example/formJsonPost/build.sc rename to example/formJsonPost/package.mill index b9c65484bc..fae02c3f1e 100644 --- a/example/formJsonPost/build.sc +++ b/example/formJsonPost/package.mill @@ -1,7 +1,11 @@ +package build.example.formJsonPost import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ diff --git a/example/httpMethods/build.sc b/example/httpMethods/package.mill similarity index 69% rename from example/httpMethods/build.sc rename to example/httpMethods/package.mill index edb70116ba..1e75465fca 100644 --- a/example/httpMethods/build.sc +++ b/example/httpMethods/package.mill @@ -1,7 +1,11 @@ +package build.example.httpMethods import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ diff --git a/example/minimalApplication/build.sc b/example/minimalApplication/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/minimalApplication/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/minimalApplication/package.mill b/example/minimalApplication/package.mill new file mode 100644 index 0000000000..0f60dc7f87 --- /dev/null +++ b/example/minimalApplication/package.mill @@ -0,0 +1,18 @@ +package build.example.minimalApplication +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/minimalApplication2/build.sc b/example/minimalApplication2/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/minimalApplication2/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/minimalApplication2/package.mill b/example/minimalApplication2/package.mill new file mode 100644 index 0000000000..26f0cf9c14 --- /dev/null +++ b/example/minimalApplication2/package.mill @@ -0,0 +1,18 @@ +package build.example.minimalApplication2 +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/package.mill b/example/package.mill new file mode 100644 index 0000000000..be69d3431b --- /dev/null +++ b/example/package.mill @@ -0,0 +1 @@ +package build.example \ No newline at end of file diff --git a/example/queryParams/build.sc b/example/queryParams/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/queryParams/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/queryParams/package.mill b/example/queryParams/package.mill new file mode 100644 index 0000000000..f83697e39e --- /dev/null +++ b/example/queryParams/package.mill @@ -0,0 +1,18 @@ +package build.example.queryParams +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/redirectAbort/build.sc b/example/redirectAbort/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/redirectAbort/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/redirectAbort/package.mill b/example/redirectAbort/package.mill new file mode 100644 index 0000000000..f233d4ef1c --- /dev/null +++ b/example/redirectAbort/package.mill @@ -0,0 +1,18 @@ +package build.example.redirectAbort +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/scalatags/build.sc b/example/scalatags/package.mill similarity index 68% rename from example/scalatags/build.sc rename to example/scalatags/package.mill index 21cce09e08..f37a90c143 100644 --- a/example/scalatags/build.sc +++ b/example/scalatags/package.mill @@ -1,7 +1,11 @@ +package build.example.scalatags import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ivy"com.lihaoyi::scalatags:0.12.0" ) diff --git a/example/staticFiles/build.sc b/example/staticFiles/package.mill similarity index 77% rename from example/staticFiles/build.sc rename to example/staticFiles/package.mill index 3f9c2f941b..5b655b7df4 100644 --- a/example/staticFiles/build.sc +++ b/example/staticFiles/package.mill @@ -1,7 +1,11 @@ +package build.example.staticFiles import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def forkWorkingDir = build.millSourcePath def ivyDeps = Agg[Dep]( ) diff --git a/example/staticFiles2/build.sc b/example/staticFiles2/package.mill similarity index 77% rename from example/staticFiles2/build.sc rename to example/staticFiles2/package.mill index 3f9c2f941b..4b28685aba 100644 --- a/example/staticFiles2/build.sc +++ b/example/staticFiles2/package.mill @@ -1,7 +1,11 @@ +package build.example.staticFiles2 import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def forkWorkingDir = build.millSourcePath def ivyDeps = Agg[Dep]( ) diff --git a/example/todo/build.sc b/example/todo/package.mill similarity index 76% rename from example/todo/build.sc rename to example/todo/package.mill index 19d2486230..559e2c522c 100644 --- a/example/todo/build.sc +++ b/example/todo/package.mill @@ -1,7 +1,11 @@ +package build.example.todo import mill._, scalalib._ +object app extends Cross[AppModule](build.scala213) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ivy"org.xerial:sqlite-jdbc:3.42.0.0", ivy"com.lihaoyi::scalasql:0.1.0", diff --git a/example/todoApi/build.sc b/example/todoApi/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/todoApi/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/compress2/build.sc b/example/todoApi/package.mill similarity index 65% rename from example/compress2/build.sc rename to example/todoApi/package.mill index 75de91ef2f..19c8e4b45a 100644 --- a/example/compress2/build.sc +++ b/example/todoApi/package.mill @@ -1,7 +1,11 @@ +package build.example.todoApi import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ diff --git a/example/todoDb/build.sc b/example/todoDb/package.mill similarity index 72% rename from example/todoDb/build.sc rename to example/todoDb/package.mill index 893b424be9..36ee3abf9f 100644 --- a/example/todoDb/build.sc +++ b/example/todoDb/package.mill @@ -1,7 +1,11 @@ +package build.example.todoDb import mill._, scalalib._ +object app extends Cross[AppModule](build.scala213) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ivy"org.xerial:sqlite-jdbc:3.42.0.0", ivy"com.lihaoyi::scalasql:0.1.0", diff --git a/example/twirl/build.sc b/example/twirl/package.mill similarity index 82% rename from example/twirl/build.sc rename to example/twirl/package.mill index 06a078c294..6a1f170fff 100644 --- a/example/twirl/build.sc +++ b/example/twirl/package.mill @@ -1,8 +1,11 @@ +package build.example.twirl import mill._, scalalib._ import $ivy.`com.lihaoyi::mill-contrib-twirllib:` - +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule with mill.twirllib.TwirlModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def twirlScalaVersion = "2.13.10" def twirlVersion = "1.5.1" diff --git a/example/variableRoutes/build.sc b/example/variableRoutes/build.sc deleted file mode 100644 index 75de91ef2f..0000000000 --- a/example/variableRoutes/build.sc +++ /dev/null @@ -1,14 +0,0 @@ -import mill._, scalalib._ - -trait AppModule extends CrossScalaModule{ - - def ivyDeps = Agg[Dep]( - ) - object test extends ScalaTests with TestModule.Utest{ - - def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.8.1", - ivy"com.lihaoyi::requests::0.8.0", - ) - } -} diff --git a/example/variableRoutes/package.mill b/example/variableRoutes/package.mill new file mode 100644 index 0000000000..32034965b7 --- /dev/null +++ b/example/variableRoutes/package.mill @@ -0,0 +1,18 @@ +package build.example.variableRoutes +import mill._, scalalib._ + +object app extends Cross[AppModule](build.scalaVersions) +trait AppModule extends CrossScalaModule{ + + def moduleDeps = Seq(build.cask(crossScalaVersion)) + + def ivyDeps = Agg[Dep]( + ) + object test extends ScalaTests with TestModule.Utest{ + + def ivyDeps = Agg( + ivy"com.lihaoyi::utest::0.8.1", + ivy"com.lihaoyi::requests::0.8.0", + ) + } +} diff --git a/example/websockets2/build.sc b/example/websockets/package.mill similarity index 69% rename from example/websockets2/build.sc rename to example/websockets/package.mill index 7681359512..b0607c0d55 100644 --- a/example/websockets2/build.sc +++ b/example/websockets/package.mill @@ -1,7 +1,11 @@ +package build.example.websockets import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ diff --git a/example/websockets3/build.sc b/example/websockets2/package.mill similarity index 69% rename from example/websockets3/build.sc rename to example/websockets2/package.mill index 7681359512..3e697004a2 100644 --- a/example/websockets3/build.sc +++ b/example/websockets2/package.mill @@ -1,7 +1,11 @@ +package build.example.websockets2 import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ diff --git a/example/websockets4/build.sc b/example/websockets3/package.mill similarity index 69% rename from example/websockets4/build.sc rename to example/websockets3/package.mill index 7681359512..055327045f 100644 --- a/example/websockets4/build.sc +++ b/example/websockets3/package.mill @@ -1,7 +1,11 @@ +package build.example.websockets3 import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ diff --git a/example/websockets/build.sc b/example/websockets4/package.mill similarity index 90% rename from example/websockets/build.sc rename to example/websockets4/package.mill index 7681359512..fdd4d4cfdb 100644 --- a/example/websockets/build.sc +++ b/example/websockets4/package.mill @@ -1,3 +1,4 @@ +package build.example.websockets4 import mill._, scalalib._ trait AppModule extends CrossScalaModule{ From 8493e969fff23a56f835a4e0f9feb625b9965b58 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 22 Oct 2024 10:08:38 +0800 Subject: [PATCH 3/9] . --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 7239806f60..93f093958c 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -27,7 +27,7 @@ jobs: - name: Run tests run: | set -eux - ./mill -i --disable-ticker __.testLocal + ./mill -ij1 --disable-ticker __.testLocal publish-sonatype: if: github.repository == 'com-lihaoyi/cask' && contains(github.ref, 'refs/tags/') From 6b1a9992da6e63901deb54c735eff9f8e5dcee6a Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 22 Oct 2024 10:24:44 +0800 Subject: [PATCH 4/9] wip --- mill | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mill b/mill index 0c5078a0f0..d03a045cb7 100755 --- a/mill +++ b/mill @@ -7,7 +7,7 @@ set -e if [ -z "${DEFAULT_MILL_VERSION}" ] ; then - DEFAULT_MILL_VERSION=0.11.6 + DEFAULT_MILL_VERSION=0.11.12 fi if [ -z "$MILL_VERSION" ] ; then @@ -53,7 +53,9 @@ if [ -z "$MILL_MAIN_CLI" ] ; then fi MILL_FIRST_ARG="" -if [ "$1" = "--bsp" ] || [ "$1" = "-i" ] || [ "$1" = "--interactive" ] || [ "$1" = "--no-server" ] || [ "$1" = "--repl" ] || [ "$1" = "--help" ] ; then + + # first arg is a long flag for "--interactive" or starts with "-i" +if [ "$1" = "--bsp" ] || [ "${1#"-i"}" != "$1" ] || [ "$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 From 99caf480d32152957e75a5d40f3ce4aeaaf6ddac Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 22 Oct 2024 10:32:29 +0800 Subject: [PATCH 5/9] wip --- .github/workflows/actions.yml | 2 +- example/staticFiles/app/src/StaticFiles.scala | 2 +- example/staticFiles/package.mill | 8 +++++--- example/staticFiles2/package.mill | 8 +++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 93f093958c..937bb1e3f5 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -27,7 +27,7 @@ jobs: - name: Run tests run: | set -eux - ./mill -ij1 --disable-ticker __.testLocal + ./mill -ikj1 --disable-ticker __.testLocal publish-sonatype: if: github.repository == 'com-lihaoyi/cask' && contains(github.ref, 'refs/tags/') diff --git a/example/staticFiles/app/src/StaticFiles.scala b/example/staticFiles/app/src/StaticFiles.scala index 00d1aceeb2..1abfac28cf 100644 --- a/example/staticFiles/app/src/StaticFiles.scala +++ b/example/staticFiles/app/src/StaticFiles.scala @@ -6,7 +6,7 @@ object StaticFiles extends cask.MainRoutes{ } @cask.staticFiles("/static/file") - def staticFileRoutes() = "app/resources/cask" + def staticFileRoutes() = "resources/cask" @cask.staticResources("/static/resource") def staticResourceRoutes() = "cask" diff --git a/example/staticFiles/package.mill b/example/staticFiles/package.mill index 5b655b7df4..42d9576569 100644 --- a/example/staticFiles/package.mill +++ b/example/staticFiles/package.mill @@ -2,11 +2,11 @@ package build.example.staticFiles import mill._, scalalib._ object app extends Cross[AppModule](build.scalaVersions) -trait AppModule extends CrossScalaModule{ +trait AppModule extends CrossScalaModule{ app => def moduleDeps = Seq(build.cask(crossScalaVersion)) - def forkWorkingDir = build.millSourcePath + def forkWorkingDir = app.millSourcePath def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ @@ -16,7 +16,9 @@ trait AppModule extends CrossScalaModule{ ivy"com.lihaoyi::requests::0.8.0", ) - def forkWorkingDir = build.millSourcePath + def forkWorkingDir = app.millSourcePath + + def testSandboxWorkingDir = false // redirect this to the forked `test` to make sure static file serving works def testLocal(args: String*) = T.command{ diff --git a/example/staticFiles2/package.mill b/example/staticFiles2/package.mill index 4b28685aba..6dbb77571c 100644 --- a/example/staticFiles2/package.mill +++ b/example/staticFiles2/package.mill @@ -2,11 +2,11 @@ package build.example.staticFiles2 import mill._, scalalib._ object app extends Cross[AppModule](build.scalaVersions) -trait AppModule extends CrossScalaModule{ +trait AppModule extends CrossScalaModule{ app => def moduleDeps = Seq(build.cask(crossScalaVersion)) - def forkWorkingDir = build.millSourcePath + def forkWorkingDir = app.millSourcePath def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ @@ -16,7 +16,9 @@ trait AppModule extends CrossScalaModule{ ivy"com.lihaoyi::requests::0.8.0", ) - def forkWorkingDir = build.millSourcePath + def forkWorkingDir = app.millSourcePath + + def testSandboxWorkingDir = false // redirect this to the forked `test` to make sure static file serving works def testLocal(args: String*) = T.command{ From d3f10dcda0034ed9a29e7885a6b5282fbf19f9da Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 22 Oct 2024 11:08:58 +0800 Subject: [PATCH 6/9] wip --- .github/workflows/actions.yml | 19 ++++++++ build.mill | 82 ++++++++++++++++++++++++----------- 2 files changed, 75 insertions(+), 26 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 937bb1e3f5..b10ddc881e 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -29,6 +29,25 @@ jobs: set -eux ./mill -ikj1 --disable-ticker __.testLocal + test-examples: + runs-on: ubuntu-latest + strategy: + matrix: + java: [ '11' ] + name: Tests for Java ${{ matrix.Java }} + steps: + - uses: actions/checkout@v3 + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: ${{ matrix.java }} + - name: Run tests + run: | + set -eux + ./mill __.publishLocal + ./mill -ikj1 --disable-ticker testExamples + publish-sonatype: if: github.repository == 'com-lihaoyi/cask' && contains(github.ref, 'refs/tags/') needs: test diff --git a/build.mill b/build.mill index 30e766a3f5..d9b6cf78b3 100644 --- a/build.mill +++ b/build.mill @@ -92,24 +92,11 @@ trait LocalModule extends CrossScalaModule{ -def uploadToGithub() = T.command{ +def zippedExamples = T { val vcsState = VcsVersion.vcsState() - val authKey = T.env.apply("AMMONITE_BOT_AUTH_TOKEN") val releaseTag = vcsState.lastTag.getOrElse("") val label = vcsState.format() - if (releaseTag == label){ - requests.post( - "https://api.github.com/repos/com-lihaoyi/cask/releases", - data = ujson.write( - ujson.Obj( - "tag_name" -> releaseTag, - "name" -> releaseTag - ) - ), - headers = Seq("Authorization" -> s"token $authKey") - ) - } val examples = Seq( build.example.compress.millSourcePath, @@ -139,20 +126,22 @@ def uploadToGithub() = T.command{ build.example.websockets4.millSourcePath, ) - for(example <- examples){ + for (example <- examples) yield { val f = T.ctx().dest val last = example.last + "-" + label os.copy(example, f / last) + os.copy(T.workspace / ".mill-version", f / last / ".mill-version") + os.write.over(f / last / "mill", os.read(T.workspace / "mill")) + os.proc("chmod", "+x", f / last / "mill").call(f / last) + os.move(f / last / "package.mill", f / last / "build.mill") os.write.over( - f / last / "mill", - os.read(os.pwd / "mill") - ) - os.proc("chmod", "+x", f/last/"mill").call(f/last) - os.write.over( - f / last / "build.sc", - os.read(f / last / "build.sc") + f / last / "build.mill", + os.read(f / last / "build.mill") + .replaceAll("package build.*", "package build") + .replaceAll("def moduleDeps =.*", "") + .replaceAll("app =>", "") .replaceFirst( - "trait AppModule extends CrossScalaModule\\s*\\{", + "object app extends.*\ntrait AppModule extends CrossScalaModule\\s*\\{", s"object app extends ScalaModule \\{\n def scalaVersion = \"${scala213}\"") .replaceFirst( "def ivyDeps = Agg\\[Dep\\]\\(", @@ -160,8 +149,49 @@ def uploadToGithub() = T.command{ ) ) - os.remove.all(f / "out.zip") - os.proc("zip", "-r", f / "out.zip", last).call(f) - upload.apply(f / "out.zip", releaseTag, last + ".zip", authKey) + os.zip(f / s"$last.zip", Seq(f / last)) + PathRef(f / s"$last.zip") + } +} + +def testExamples() = T.command{ + for(example <- zippedExamples()){ + println("Testing " + example.path.last) + val base = T.dest / example.path.baseName + os.unzip(example.path, base) + os.perms.set(base / "mill", "rwxrwxrwx") + os.write.over( + base / "build.mill", + os.read(base / "build.mill").replaceAll( + "ivy\"com.lihaoyi::cask:.*\"", + s"""ivy"com.lihaoyi::cask:${VcsVersion.vcsState().format()}"""" + ) + ) + os.proc("./mill", "app.test").call(cwd = base, stdout = os.Inherit) + } +} + +def uploadToGithub() = T.command{ + val vcsState = VcsVersion.vcsState() + + val authKey = T.env.apply("AMMONITE_BOT_AUTH_TOKEN") + val releaseTag = vcsState.lastTag.getOrElse("") + val label = vcsState.format() + if (releaseTag == label) { + requests.post( + "https://api.github.com/repos/com-lihaoyi/cask/releases", + data = ujson.write( + ujson.Obj( + "tag_name" -> releaseTag, + "name" -> releaseTag + ) + ), + headers = Seq("Authorization" -> s"token $authKey") + ) + } + + for(example <- zippedExamples()){ + + upload.apply(example.path, releaseTag, example.path.last, authKey) } } From 7626b3b8c9c8a805abe228499275d4733773bac5 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 22 Oct 2024 11:30:48 +0800 Subject: [PATCH 7/9] wip --- build.mill | 5 +++-- example/staticFiles2/app/src/StaticFiles2.scala | 2 +- example/websockets4/package.mill | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build.mill b/build.mill index d9b6cf78b3..6e7374c27c 100644 --- a/build.mill +++ b/build.mill @@ -141,8 +141,8 @@ def zippedExamples = T { .replaceAll("def moduleDeps =.*", "") .replaceAll("app =>", "") .replaceFirst( - "object app extends.*\ntrait AppModule extends CrossScalaModule\\s*\\{", - s"object app extends ScalaModule \\{\n def scalaVersion = \"${scala213}\"") + "object app extends.*\ntrait AppModule extends CrossScalaModule(.*)\\{", + s"object app extends ScalaModule $$1\\{\n def scalaVersion = \"${scala213}\"") .replaceFirst( "def ivyDeps = Agg\\[Dep\\]\\(", "def ivyDeps = Agg(\n ivy\"com.lihaoyi::cask:" + releaseTag + "\"," @@ -155,6 +155,7 @@ def zippedExamples = T { } def testExamples() = T.command{ + for(example <- zippedExamples()){ println("Testing " + example.path.last) val base = T.dest / example.path.baseName diff --git a/example/staticFiles2/app/src/StaticFiles2.scala b/example/staticFiles2/app/src/StaticFiles2.scala index 7354cdb6c9..430aadccbb 100644 --- a/example/staticFiles2/app/src/StaticFiles2.scala +++ b/example/staticFiles2/app/src/StaticFiles2.scala @@ -6,7 +6,7 @@ object StaticFiles2 extends cask.MainRoutes{ } @cask.staticFiles("/static/file", headers = Seq("Cache-Control" -> "max-age=31536000")) - def staticFileRoutes() = "app/resources/cask" + def staticFileRoutes() = "resources/cask" @cask.decorators.compress @cask.staticResources("/static/resource") diff --git a/example/websockets4/package.mill b/example/websockets4/package.mill index fdd4d4cfdb..d68132a945 100644 --- a/example/websockets4/package.mill +++ b/example/websockets4/package.mill @@ -1,6 +1,7 @@ package build.example.websockets4 import mill._, scalalib._ +object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ def ivyDeps = Agg[Dep]( From 925f14fb7583cdf710c8d9186bb5bd1da0a1a9fa Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 22 Oct 2024 12:04:27 +0800 Subject: [PATCH 8/9] wip --- example/websockets4/package.mill | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/websockets4/package.mill b/example/websockets4/package.mill index d68132a945..bb31416ab4 100644 --- a/example/websockets4/package.mill +++ b/example/websockets4/package.mill @@ -4,6 +4,8 @@ import mill._, scalalib._ object app extends Cross[AppModule](build.scalaVersions) trait AppModule extends CrossScalaModule{ + def moduleDeps = Seq(build.cask(crossScalaVersion)) + def ivyDeps = Agg[Dep]( ) object test extends ScalaTests with TestModule.Utest{ From 3ac16c27e96a737e26b46e21bba8a30ee6966522 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 24 Oct 2024 07:28:59 +0800 Subject: [PATCH 9/9] Update .mill-version --- .mill-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mill-version b/.mill-version index 53cf705c90..ac454c6a1f 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.12.0-RC3-102-b8217f +0.12.0