From 6d5f44219dd403877b662472f6c1d5e602f83439 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 6 Feb 2025 09:42:58 +0800 Subject: [PATCH 1/4] . --- build.mill | 4 +- changelog.adoc | 2 +- contrib/playlib/src/mill/playlib/Layout.scala | 4 +- .../src/mill/playlib/RouterModule.scala | 2 +- .../versionfile/VersionFileModule.scala | 2 +- dist/package.mill | 2 +- .../modules/ROOT/pages/comparisons/maven.adoc | 10 ++-- .../ROOT/pages/comparisons/unique.adoc | 4 +- docs/package.mill | 10 ++-- .../extending/jvmcode/1-subprocess/build.mill | 2 +- .../jvmcode/2-classloader/build.mill | 2 +- example/extending/jvmcode/3-worker/build.mill | 2 +- .../python/1-hello-python/build.mill | 4 +- .../python/2-python-modules/build.mill | 4 +- .../python/3-python-module-deps/build.mill | 4 +- .../python/4-python-libs-bundle/build.mill | 4 +- .../typescript/1-hello-typescript/build.mill | 2 +- .../2-typescript-modules/build.mill | 2 +- .../typescript/3-module-deps/build.mill | 2 +- .../typescript/4-npm-deps-bundle/build.mill | 2 +- .../fundamentals/modules/6-modules/build.mill | 6 +-- .../modules/8-diy-java-modules/build.mill | 2 +- .../tasks/1-task-graph/build.mill | 4 +- .../tasks/2-primary-tasks/build.mill | 4 +- .../tasks/3-anonymous-tasks/build.mill | 2 +- .../tasks/5-persistent-tasks/build.mill | 2 +- .../fundamentals/tasks/6-workers/build.mill | 2 +- example/javalib/module/15-jni/build.mill | 2 +- example/javalib/module/7-resources/build.mill | 2 +- .../javalib/publishing/3-revapi/build.mill | 2 +- .../module/1-common-config/build.mill | 2 +- .../module/5-resources/build.mill | 2 +- example/kotlinlib/module/15-jni/build.mill | 2 +- .../kotlinlib/module/7-resources/build.mill | 2 +- example/pythonlib/basic/1-simple/build.mill | 2 +- .../basic/2-custom-build-logic/build.mill | 2 +- .../pythonlib/basic/3-multi-module/build.mill | 4 +- .../module/1-common-config/build.mill | 2 +- .../module/2-custom-tasks/build.mill | 2 +- .../4-compilation-execution-flags/build.mill | 2 +- .../pythonlib/module/5-resources/build.mill | 4 +- .../pythonlib/module/6-pex-config/build.mill | 2 +- .../2-publish-module-advanced/build.mill | 2 +- .../pythonlib/testing/1-test-suite/build.mill | 6 +-- .../pythonlib/testing/2-test-deps/build.mill | 4 +- .../testing/3-integration-suite/build.mill | 2 +- .../pythonlib/web/1-hello-flask/build.mill | 2 +- example/pythonlib/web/2-todo-flask/build.mill | 2 +- .../pythonlib/web/3-hello-django/build.mill | 2 +- .../pythonlib/web/4-todo-django/build.mill | 2 +- .../scalalib/module/7-resources/build.mill | 2 +- example/thirdparty/acyclic/build.mill | 2 +- example/thirdparty/arrow/build.mill | 6 +-- example/thirdparty/mockito/build.mill | 2 +- example/thirdparty/netty/build.mill | 14 ++--- .../gen-idea/resources/extended/build.mill | 2 +- .../src/MultiLevelBuildTests.scala | 2 +- .../selective-execution/resources/build.mill | 4 +- .../watch-source-input/resources/build.mill | 4 +- .../mill/javascriptlib/PublishModule.scala | 2 +- .../javascriptlib/ReactScriptsModule.scala | 6 +-- .../javascriptlib/RsWithServeModule.scala | 2 +- .../mill/javascriptlib/TypeScriptModule.scala | 2 +- .../mill/kotlinlib/js/KotlinJsModule.scala | 4 +- .../src/mill/kotlinlib/HelloWorldTests.scala | 2 +- .../mill/kotlinlib/MixedHelloWorldTests.scala | 2 +- .../contrib/kover/KoverModuleTests.scala | 2 +- .../contrib/ktfmt/KtfmtModuleTests.scala | 12 ++--- .../kotlinlib/js/KotlinJsCompileTests.scala | 6 +-- main/define/src/mill/define/Task.scala | 52 +++++++++++++++++++ .../src/mill/eval/JavaCompileJarTests.scala | 9 ++-- .../maven/src/mill/main/maven/Modeler.scala | 2 +- .../src/mill/pythonlib/PythonModule.scala | 8 +-- pythonlib/src/mill/pythonlib/RuffModule.scala | 2 +- .../src/mill/pythonlib/HelloWorldTests.scala | 2 +- .../mill/pythonlib/RunBackgroundTests.scala | 4 +- .../javalib/android/AndroidAppModule.scala | 4 +- .../javalib/android/AndroidSdkModule.scala | 4 +- scalalib/src/mill/scalalib/JavaModule.scala | 8 +-- .../PalantirFormatModuleTest.scala | 2 +- .../javalib/revapi/RevapiModuleTests.scala | 2 +- .../mill/scalalib/TestRunnerTestUtils.scala | 2 +- testkit/package.mill | 2 +- .../example-test-example-project/build.mill | 2 +- .../build.mill | 2 +- .../src/mill/testkit/UnitTesterTests.scala | 2 +- 86 files changed, 193 insertions(+), 142 deletions(-) diff --git a/build.mill b/build.mill index 713fba82c96..821f7dc3260 100644 --- a/build.mill +++ b/build.mill @@ -148,7 +148,7 @@ object Deps { val junitInterface = ivy"com.github.sbt:junit-interface:0.13.3" val commonsIo = ivy"commons-io:commons-io:2.18.0" val log4j2Core = ivy"org.apache.logging.log4j:log4j-core:2.24.3" - val osLib = ivy"com.lihaoyi::os-lib:0.11.4-M5" + val osLib = ivy"com.lihaoyi::os-lib:0.11.4-M6" val pprint = ivy"com.lihaoyi::pprint:0.9.0" val mainargs = ivy"com.lihaoyi::mainargs:0.7.6" val millModuledefsVersion = "0.11.2" @@ -381,7 +381,7 @@ trait MillJavaModule extends JavaModule { def writeLocalTestOverrides = Task.Anon { for ((k, v) <- testTransitiveDeps()) { - os.write(Task.dest / "mill" / "local-test-overrides" / k, v, createFolders = true) + os.write(Task.dest / "mill/local-test-overrides" / k, v, createFolders = true) } Seq(PathRef(Task.dest)) } diff --git a/changelog.adoc b/changelog.adoc index c125470dc62..5bacb513050 100644 --- a/changelog.adoc +++ b/changelog.adoc @@ -450,7 +450,7 @@ or `;exclude=org:*` or `;exclude=*:name` {link-pr}/3492[#3492] * Update to https://github.com/com-lihaoyi/os-lib?tab=readme-ov-file#0-10-7[OS-Lib 0.10.7] to allow concise multi-segment sub-paths; you can now write `os.pwd / "foo/bar/qux"` rather than -`os.pwd / "foo" / "bar" / "qux"` +`os.pwd / "foo/bar/qux"` * Add `JavaModule.mandatoryJavacOptions`. Those are not propagated to the inner test traits intentionally, since those options are typically configured by other means, diff --git a/contrib/playlib/src/mill/playlib/Layout.scala b/contrib/playlib/src/mill/playlib/Layout.scala index d5492e33160..46f77d61e32 100644 --- a/contrib/playlib/src/mill/playlib/Layout.scala +++ b/contrib/playlib/src/mill/playlib/Layout.scala @@ -5,8 +5,8 @@ import mill.scalalib._ private[playlib] trait Layout extends JavaModule { - def conf = Task.Sources { millSourcePath / "conf" } - def app = Task.Sources { millSourcePath / "app" } + def conf = Task.Sources { "conf" } + def app = Task.Sources { "app" } override def sources = Task { app() } override def resources = Task { conf() } diff --git a/contrib/playlib/src/mill/playlib/RouterModule.scala b/contrib/playlib/src/mill/playlib/RouterModule.scala index a5f8c62af70..ec17570d8d3 100644 --- a/contrib/playlib/src/mill/playlib/RouterModule.scala +++ b/contrib/playlib/src/mill/playlib/RouterModule.scala @@ -9,7 +9,7 @@ import mill.{Agg, T, Task} trait RouterModule extends ScalaModule with Version { - def routes: T[Seq[PathRef]] = Task.Sources { millSourcePath / "routes" } + def routes: T[Seq[PathRef]] = Task.Sources { "routes" } def routeFiles = Task { val paths = routes().flatMap(file => os.walk(file.path)) diff --git a/contrib/versionfile/src/mill/contrib/versionfile/VersionFileModule.scala b/contrib/versionfile/src/mill/contrib/versionfile/VersionFileModule.scala index c113b2e21a9..724631cd3a7 100644 --- a/contrib/versionfile/src/mill/contrib/versionfile/VersionFileModule.scala +++ b/contrib/versionfile/src/mill/contrib/versionfile/VersionFileModule.scala @@ -5,7 +5,7 @@ import mill._ trait VersionFileModule extends Module { /** The file containing the current version. */ - def versionFile: T[PathRef] = Task.Source(millSourcePath / "version") + def versionFile: T[PathRef] = Task.Source("version") /** The current version. */ def currentVersion: T[Version] = Task { Version.of(os.read(versionFile().path).trim) } diff --git a/dist/package.mill b/dist/package.mill index f226bfe7999..c7929ddc68d 100644 --- a/dist/package.mill +++ b/dist/package.mill @@ -41,7 +41,7 @@ trait InstallModule extends build.MillPublishJavaModule { def installLocalCache() = Task.Command { val path = installLocalTask( Task.Anon( - (os.home / ".cache" / "mill" / "download" / (build.millVersion() + batExt)).toString() + (os.home / ".cache/mill/download" / (build.millVersion() + batExt)).toString() ) )() Task.log.outputStream.println(path.toString()) diff --git a/docs/modules/ROOT/pages/comparisons/maven.adoc b/docs/modules/ROOT/pages/comparisons/maven.adoc index 7b96c8a4eec..090380e2c6d 100644 --- a/docs/modules/ROOT/pages/comparisons/maven.adoc +++ b/docs/modules/ROOT/pages/comparisons/maven.adoc @@ -391,7 +391,7 @@ import $ivy.`ant:ant-optional:1.5.3-1` object common extends NettyModule{ ... - def script = Task.Source(millSourcePath / "src" / "main" / "script") + def script = Task.Source("src/main/script") def generatedSources0 = Task { val shell = new groovy.lang.GroovyShell() val context = new java.util.HashMap[String, Object] @@ -520,8 +520,8 @@ with the `make` command essentially being a bash script wrapped in layers of XML In contrast, the Mill configuration for this logic is as follows: ```scala -def makefile = Task.Source(millSourcePath / "Makefile") -def cSources = Task.Source(millSourcePath / "src" / "main" / "c") +def makefile = Task.Source("Makefile") +def cSources = Task.Source("src/main/c") def cHeaders = Task { for(p <- os.walk(cSources().path) if p.ext == "h"){ os.copy(p, Task.dest / p.relativeTo(cSources().path), createFolders = true) @@ -531,14 +531,14 @@ def cHeaders = Task { def make = Task { os.copy(makefile().path, Task.dest / "Makefile") - os.copy(cSources().path, Task.dest / "src" / "main" / "c", createFolders = true) + os.copy(cSources().path, Task.dest / "src/main/c", createFolders = true) val Seq(sourceJar) = resolveDeps( deps = Task.Anon(Agg(ivy"io.netty:netty-jni-util:0.0.9.Final").map(bindDependency())), sources = true )().toSeq - os.proc("jar", "xf", sourceJar.path).call(cwd = Task.dest / "src" / "main" / "c") + os.proc("jar", "xf", sourceJar.path).call(cwd = Task.dest / "src/main/c") os.proc("make").call( cwd = Task.dest, diff --git a/docs/modules/ROOT/pages/comparisons/unique.adoc b/docs/modules/ROOT/pages/comparisons/unique.adoc index 8fe5879ed9c..6f712eec5f7 100644 --- a/docs/modules/ROOT/pages/comparisons/unique.adoc +++ b/docs/modules/ROOT/pages/comparisons/unique.adoc @@ -176,8 +176,8 @@ them into classfiles, and then the `jar` executable to package them together int ```scala def mainClass: T[Option[String]] = Some("foo.Foo") -def sources = Task.Source(millSourcePath / "src") -def resources = Task.Source(millSourcePath / "resources") +def sources = Task.Source("src") +def resources = Task.Source("resources") def compile = Task { val allSources = os.walk(sources().path) diff --git a/docs/package.mill b/docs/package.mill index 272092bba2e..baec2a1585e 100644 --- a/docs/package.mill +++ b/docs/package.mill @@ -61,7 +61,7 @@ object `package` extends RootModule { envArgs = Map("CI" -> "true"), workingDir = workDir ) - PathRef(workDir / "build" / "site") + PathRef(workDir / "build/site") } def source0 = Task.Source(millSourcePath) @@ -69,8 +69,8 @@ object `package` extends RootModule { def source = Task { os.copy(source0().path, Task.dest, mergeFolders = true) - val pagesWd = Task.dest / "modules" / "ROOT" / "pages" - val partialsWd = Task.dest / "modules" / "ROOT" / "partials" + val pagesWd = Task.dest / "modules/ROOT/pages" + val partialsWd = Task.dest / "modules/ROOT/partials" os.copy(projectChangelog().path, partialsWd / "project-changelog.adoc", createFolders = true) @@ -284,7 +284,7 @@ object `package` extends RootModule { val checkout = Task.dest / displayVersion os.proc("git", "clone", Task.workspace / ".git", checkout).call(stdout = os.Inherit) os.proc("git", "checkout", millLastTag).call(cwd = checkout, stdout = os.Inherit) - val outputFolder = checkout / "out" / "docs" / "source.dest" + val outputFolder = checkout / "out/docs/source.dest" os.proc("./mill", "-i", "docs.source").call(cwd = checkout, stdout = os.Inherit) expandDiagramsInDirectoryAdocFile( outputFolder, @@ -360,7 +360,7 @@ object `package` extends RootModule { // only copy the "api" sub-dir; api docs contains a top-level index.html with we don't want val unidocSrc = if (authorMode) site.unidocLocal().path else site.unidocSite().path Task.log.errorStream.println(s"Copying API docs from ${unidocSrc} ...") - os.copy(unidocSrc, siteDir / "api" / "latest", createFolders = true) + os.copy(unidocSrc, siteDir / "api/latest", createFolders = true) PathRef(siteDir) } diff --git a/example/extending/jvmcode/1-subprocess/build.mill b/example/extending/jvmcode/1-subprocess/build.mill index f84e7dad5cb..82034149fa9 100644 --- a/example/extending/jvmcode/1-subprocess/build.mill +++ b/example/extending/jvmcode/1-subprocess/build.mill @@ -22,7 +22,7 @@ object foo extends JavaModule { defaultResolver().resolveDeps(Agg(ivy"org.codehaus.groovy:groovy:3.0.9")) } - def groovyScript = Task.Source(millSourcePath / "generate.groovy") + def groovyScript = Task.Source("generate.groovy") def groovyGeneratedResources = Task { Jvm.runSubprocess( diff --git a/example/extending/jvmcode/2-classloader/build.mill b/example/extending/jvmcode/2-classloader/build.mill index fb18c8643ff..7c38a3faec4 100644 --- a/example/extending/jvmcode/2-classloader/build.mill +++ b/example/extending/jvmcode/2-classloader/build.mill @@ -14,7 +14,7 @@ object foo extends JavaModule { defaultResolver().resolveDeps(Agg(ivy"org.codehaus.groovy:groovy:3.0.9")) } - def groovyScript = Task.Source(millSourcePath / "generate.groovy") + def groovyScript = Task.Source("generate.groovy") def groovyGeneratedResources = Task { Jvm.runClassloader(classPath = groovyClasspath().map(_.path)) { classLoader => diff --git a/example/extending/jvmcode/3-worker/build.mill b/example/extending/jvmcode/3-worker/build.mill index 4de2b2214bd..fdf667119aa 100644 --- a/example/extending/jvmcode/3-worker/build.mill +++ b/example/extending/jvmcode/3-worker/build.mill @@ -24,7 +24,7 @@ def groovyWorker: Worker[java.net.URLClassLoader] = Task.Worker { } trait GroovyGenerateJavaModule extends JavaModule { - def groovyScript = Task.Source(millSourcePath / "generate.groovy") + def groovyScript = Task.Source("generate.groovy") def groovyGeneratedResources = Task { mill.api.ClassLoader.withContextClassLoader(groovyWorker()) { diff --git a/example/extending/python/1-hello-python/build.mill b/example/extending/python/1-hello-python/build.mill index ec96d797839..57b0baa7f48 100644 --- a/example/extending/python/1-hello-python/build.mill +++ b/example/extending/python/1-hello-python/build.mill @@ -9,7 +9,7 @@ import mill._ def pythonExe: T[PathRef] = Task { os.call(("python3", "-m", "venv", Task.dest / "venv")) - val python = Task.dest / "venv" / "bin" / "python3" + val python = Task.dest / "venv/bin/python3" os.call((python, "-m", "pip", "install", "mypy==1.13.0")) PathRef(python) @@ -19,7 +19,7 @@ def pythonExe: T[PathRef] = Task { // The `sources` task specifies the directory for Python source files (`src` folder). -def sources: T[PathRef] = Task.Source(millSourcePath / "src") +def sources: T[PathRef] = Task.Source("src") // === Type Checking diff --git a/example/extending/python/2-python-modules/build.mill b/example/extending/python/2-python-modules/build.mill index 46e8ed1f28b..0372b3aac33 100644 --- a/example/extending/python/2-python-modules/build.mill +++ b/example/extending/python/2-python-modules/build.mill @@ -8,13 +8,13 @@ import mill._ trait PythonModule extends Module { - def sources: T[PathRef] = Task.Source(millSourcePath / "src") + def sources: T[PathRef] = Task.Source("src") def mainFileName: T[String] = Task { "main.py" } def pythonExe: T[PathRef] = Task { os.call(("python3", "-m", "venv", Task.dest / "venv")) - val python = Task.dest / "venv" / "bin" / "python3" + val python = Task.dest / "venv/bin/python3" os.call((python, "-m", "pip", "install", "mypy==1.13.0")) PathRef(python) diff --git a/example/extending/python/3-python-module-deps/build.mill b/example/extending/python/3-python-module-deps/build.mill index 09f1416ac31..d52b9c8f01b 100644 --- a/example/extending/python/3-python-module-deps/build.mill +++ b/example/extending/python/3-python-module-deps/build.mill @@ -13,13 +13,13 @@ trait PythonModule extends Module { // List of module dependencies required by this module. def moduleDeps: Seq[PythonModule] = Nil - def sources: T[PathRef] = Task.Source(millSourcePath / "src") + def sources: T[PathRef] = Task.Source("src") def mainFileName: T[String] = Task { "main.py" } def pythonExe: T[PathRef] = Task { os.call(("python3", "-m", "venv", Task.dest / "venv")) - val python = Task.dest / "venv" / "bin" / "python3" + val python = Task.dest / "venv/bin/python3" os.call((python, "-m", "pip", "install", "mypy==1.13.0")) PathRef(python) diff --git a/example/extending/python/4-python-libs-bundle/build.mill b/example/extending/python/4-python-libs-bundle/build.mill index 3d3b466609b..072ea6201e2 100644 --- a/example/extending/python/4-python-libs-bundle/build.mill +++ b/example/extending/python/4-python-libs-bundle/build.mill @@ -11,7 +11,7 @@ import mill._ trait PythonModule extends Module { def moduleDeps: Seq[PythonModule] = Nil def mainFileName: T[String] = Task { "main.py" } - def sources: T[PathRef] = Task.Source(millSourcePath / "src") + def sources: T[PathRef] = Task.Source("src") def pythonDeps: T[Seq[String]] = Task { Seq.empty[String] } @@ -22,7 +22,7 @@ trait PythonModule extends Module { def pythonExe: T[PathRef] = Task { os.call(("python3", "-m", "venv", Task.dest / "venv")) - val python = Task.dest / "venv" / "bin" / "python3" + val python = Task.dest / "venv/bin/python3" os.call((python, "-m", "pip", "install", "mypy==1.13.0", "pex==2.24.1", transitivePythonDeps())) PathRef(python) diff --git a/example/extending/typescript/1-hello-typescript/build.mill b/example/extending/typescript/1-hello-typescript/build.mill index 51e7fae7ae4..81c7cf5da32 100644 --- a/example/extending/typescript/1-hello-typescript/build.mill +++ b/example/extending/typescript/1-hello-typescript/build.mill @@ -39,7 +39,7 @@ def npmInstall = Task { // e.g. someone can later easily override `allSources` to add additional filtering // on exactly which files within the source root they wish to pick up. -def sources = Task.Source(millSourcePath / "src") +def sources = Task.Source("src") def allSources = Task { os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } diff --git a/example/extending/typescript/2-typescript-modules/build.mill b/example/extending/typescript/2-typescript-modules/build.mill index aae72e2627f..c254acba0be 100644 --- a/example/extending/typescript/2-typescript-modules/build.mill +++ b/example/extending/typescript/2-typescript-modules/build.mill @@ -13,7 +13,7 @@ trait TypeScriptModule extends Module { PathRef(Task.dest) } - def sources = Task.Source(millSourcePath / "src") + def sources = Task.Source("src") def allSources = Task { os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } diff --git a/example/extending/typescript/3-module-deps/build.mill b/example/extending/typescript/3-module-deps/build.mill index 5d8bdb56bd3..9680713d7a2 100644 --- a/example/extending/typescript/3-module-deps/build.mill +++ b/example/extending/typescript/3-module-deps/build.mill @@ -22,7 +22,7 @@ trait TypeScriptModule extends Module { PathRef(Task.dest) } - def sources = Task.Source(millSourcePath / "src") + def sources = Task.Source("src") def allSources = Task { os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } def compile: T[(PathRef, PathRef)] = Task { diff --git a/example/extending/typescript/4-npm-deps-bundle/build.mill b/example/extending/typescript/4-npm-deps-bundle/build.mill index 1fa764480b8..5a4e1bfb58e 100644 --- a/example/extending/typescript/4-npm-deps-bundle/build.mill +++ b/example/extending/typescript/4-npm-deps-bundle/build.mill @@ -39,7 +39,7 @@ trait TypeScriptModule extends Module { PathRef(Task.dest) } - def sources = Task.Source(millSourcePath / "src") + def sources = Task.Source("src") def allSources = Task { os.walk(sources().path).filter(_.ext == "ts").map(PathRef(_)) } def compile: T[(PathRef, PathRef)] = Task { diff --git a/example/fundamentals/modules/6-modules/build.mill b/example/fundamentals/modules/6-modules/build.mill index fa8fa794e17..2e5c47ca508 100644 --- a/example/fundamentals/modules/6-modules/build.mill +++ b/example/fundamentals/modules/6-modules/build.mill @@ -133,7 +133,7 @@ object foo2 extends FooModule { // module expects its input files to be on disk. trait MyModule extends Module { - def sources = Task.Source(millSourcePath / "sources") + def sources = Task.Source("sources") def task = Task { "hello " + os.list(sources().path).map(os.read(_)).mkString(" ") } } @@ -238,7 +238,7 @@ object outer2 extends MyModule { // trait Foo extends Module { - def sourceRoots = Task.Sources(millSourcePath / "src") + def sourceRoots = Task.Sources("src") def sourceContents = Task { sourceRoots() .flatMap(pref => os.walk(pref.path)) @@ -249,7 +249,7 @@ trait Foo extends Module { } trait Bar extends Foo { - def additionalSources = Task.Sources(millSourcePath / "src2") + def additionalSources = Task.Sources("src2") def sourceRoots = Task { super.sourceRoots() ++ additionalSources() } } diff --git a/example/fundamentals/modules/8-diy-java-modules/build.mill b/example/fundamentals/modules/8-diy-java-modules/build.mill index cbab4c36e63..92ebe8d40c4 100644 --- a/example/fundamentals/modules/8-diy-java-modules/build.mill +++ b/example/fundamentals/modules/8-diy-java-modules/build.mill @@ -9,7 +9,7 @@ trait DiyJavaModule extends Module { def mainClass: T[Option[String]] = None def upstream: T[Seq[PathRef]] = Task { Task.traverse(moduleDeps)(_.classPath)().flatten } - def sources = Task.Source(millSourcePath / "src") + def sources = Task.Source("src") def compile = Task { val allSources = os.walk(sources().path) diff --git a/example/fundamentals/tasks/1-task-graph/build.mill b/example/fundamentals/tasks/1-task-graph/build.mill index 5d991e25924..fa26d93121e 100644 --- a/example/fundamentals/tasks/1-task-graph/build.mill +++ b/example/fundamentals/tasks/1-task-graph/build.mill @@ -6,8 +6,8 @@ import mill._ def mainClass: T[Option[String]] = Some("foo.Foo") -def sources = Task.Source(millSourcePath / "src") -def resources = Task.Source(millSourcePath / "resources") +def sources = Task.Source("src") +def resources = Task.Source("resources") def compile = Task { val allSources = os.walk(sources().path) diff --git a/example/fundamentals/tasks/2-primary-tasks/build.mill b/example/fundamentals/tasks/2-primary-tasks/build.mill index 0cd36d99a8f..5f16e8bb768 100644 --- a/example/fundamentals/tasks/2-primary-tasks/build.mill +++ b/example/fundamentals/tasks/2-primary-tasks/build.mill @@ -9,8 +9,8 @@ package build import mill.{Module, T, _} -def sources = Task.Source { millSourcePath / "src" } -def resources = Task.Source { millSourcePath / "resources" } +def sources = Task.Source { "src" } +def resources = Task.Source { "resources" } // ``Source``s are defined using `Task.Source{...}` taking one `os.Path`, or `Task.Sources{...}`, // taking multiple ``os.Path``s as arguments. A ``Source``'s: diff --git a/example/fundamentals/tasks/3-anonymous-tasks/build.mill b/example/fundamentals/tasks/3-anonymous-tasks/build.mill index 810af932a43..2bac20ece41 100644 --- a/example/fundamentals/tasks/3-anonymous-tasks/build.mill +++ b/example/fundamentals/tasks/3-anonymous-tasks/build.mill @@ -5,7 +5,7 @@ package build import mill._, define.Task -def data = Task.Source(millSourcePath / "data") +def data = Task.Source("data") def anonTask(fileName: String): Task[String] = Task.Anon { os.read(data().path / fileName) diff --git a/example/fundamentals/tasks/5-persistent-tasks/build.mill b/example/fundamentals/tasks/5-persistent-tasks/build.mill index fdbd5d2fed0..aec2614e7a0 100644 --- a/example/fundamentals/tasks/5-persistent-tasks/build.mill +++ b/example/fundamentals/tasks/5-persistent-tasks/build.mill @@ -17,7 +17,7 @@ import java.util.Arrays import java.io.ByteArrayOutputStream import java.util.zip.GZIPOutputStream -def data = Task.Source(millSourcePath / "data") +def data = Task.Source("data") def compressedData = Task(persistent = true) { println("Evaluating compressedData") diff --git a/example/fundamentals/tasks/6-workers/build.mill b/example/fundamentals/tasks/6-workers/build.mill index f19b8a7d0df..2336e4aa75c 100644 --- a/example/fundamentals/tasks/6-workers/build.mill +++ b/example/fundamentals/tasks/6-workers/build.mill @@ -25,7 +25,7 @@ import java.util.Arrays import java.io.ByteArrayOutputStream import java.util.zip.GZIPOutputStream -def data = Task.Source(millSourcePath / "data") +def data = Task.Source("data") def compressWorker = Task.Worker { new CompressWorker(Task.dest) } diff --git a/example/javalib/module/15-jni/build.mill b/example/javalib/module/15-jni/build.mill index f9fb34a1028..61e243fd964 100644 --- a/example/javalib/module/15-jni/build.mill +++ b/example/javalib/module/15-jni/build.mill @@ -6,7 +6,7 @@ import mill._, javalib._, util.Jvm object `package` extends RootModule with JavaModule { // Additional source folder to put C sources - def nativeSources = Task.Sources(millSourcePath / "native-src") + def nativeSources = Task.Sources("native-src") // Auto-generate JNI `.h` files from Java classes using Javac def nativeHeaders = Task { diff --git a/example/javalib/module/7-resources/build.mill b/example/javalib/module/7-resources/build.mill index fc3870c5c9c..301606779b0 100644 --- a/example/javalib/module/7-resources/build.mill +++ b/example/javalib/module/7-resources/build.mill @@ -4,7 +4,7 @@ import mill._, javalib._ object foo extends JavaModule { object test extends JavaTests with TestModule.Junit4 { - def otherFiles = Task.Source(millSourcePath / "other-files") + def otherFiles = Task.Source("other-files") def forkEnv = super.forkEnv() ++ Map( "OTHER_FILES_DIR" -> otherFiles().path.toString diff --git a/example/javalib/publishing/3-revapi/build.mill b/example/javalib/publishing/3-revapi/build.mill index 7da8a9b5986..cc88e69c1e4 100644 --- a/example/javalib/publishing/3-revapi/build.mill +++ b/example/javalib/publishing/3-revapi/build.mill @@ -16,7 +16,7 @@ object bar extends JavaModule with RevapiModule { override def revapiConfigFiles: T[Seq[PathRef]] = // add Revapi config JSON file(s) - Task.Sources(millSourcePath / "conf/revapi.json") + Task.Sources("conf/revapi.json") override def revapiClasspath: T[Agg[PathRef]] = Task { // add folder containing logback.xml diff --git a/example/javascriptlib/module/1-common-config/build.mill b/example/javascriptlib/module/1-common-config/build.mill index 0ba16f29df8..610e349b885 100644 --- a/example/javascriptlib/module/1-common-config/build.mill +++ b/example/javascriptlib/module/1-common-config/build.mill @@ -6,7 +6,7 @@ import mill.javascriptlib._ object foo extends TypeScriptModule { def customSource = Task { - Seq(PathRef(millSourcePath / "custom-src" / "foo2.ts")) + Seq(PathRef(millSourcePath / "custom-src/foo2.ts")) } def allSources = super.allSources() ++ customSource() diff --git a/example/javascriptlib/module/5-resources/build.mill b/example/javascriptlib/module/5-resources/build.mill index 684a3dbe4d4..6769bd40cf9 100644 --- a/example/javascriptlib/module/5-resources/build.mill +++ b/example/javascriptlib/module/5-resources/build.mill @@ -5,7 +5,7 @@ import ujson._ object foo extends TypeScriptModule { object test extends TypeScriptTests with TestModule.Jest { - def otherFiles = Task.Source(millSourcePath / "other-files") + def otherFiles = Task.Source("other-files") def forkEnv = super.forkEnv() + ("OTHER_FILES_DIR" -> otherFiles().path.toString) } diff --git a/example/kotlinlib/module/15-jni/build.mill b/example/kotlinlib/module/15-jni/build.mill index 1ddadd00b0a..dac4985c1f0 100644 --- a/example/kotlinlib/module/15-jni/build.mill +++ b/example/kotlinlib/module/15-jni/build.mill @@ -8,7 +8,7 @@ object `package` extends RootModule with KotlinModule { def kotlinVersion = "1.9.24" // Additional source folder to put C sources - def nativeSources = Task.Sources(millSourcePath / "native-src") + def nativeSources = Task.Sources("native-src") // Compile C def nativeCompiled = Task { diff --git a/example/kotlinlib/module/7-resources/build.mill b/example/kotlinlib/module/7-resources/build.mill index ed509bedecd..25e2e06801a 100644 --- a/example/kotlinlib/module/7-resources/build.mill +++ b/example/kotlinlib/module/7-resources/build.mill @@ -7,7 +7,7 @@ object foo extends KotlinModule { def kotlinVersion = "1.9.24" object test extends KotlinTests with TestModule.Junit5 { - def otherFiles = Task.Source(millSourcePath / "other-files") + def otherFiles = Task.Source("other-files") def forkEnv = super.forkEnv() ++ Map( "OTHER_FILES_DIR" -> otherFiles().path.toString diff --git a/example/pythonlib/basic/1-simple/build.mill b/example/pythonlib/basic/1-simple/build.mill index 4492515b6c6..b1a250e74e9 100644 --- a/example/pythonlib/basic/1-simple/build.mill +++ b/example/pythonlib/basic/1-simple/build.mill @@ -3,7 +3,7 @@ import mill._, pythonlib._ object foo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src" / "foo.py" } + def mainScript = Task.Source { "src/foo.py" } def pythonDeps = Seq("Jinja2==3.1.4") diff --git a/example/pythonlib/basic/2-custom-build-logic/build.mill b/example/pythonlib/basic/2-custom-build-logic/build.mill index 9d298926e56..dbbbde1f9f7 100644 --- a/example/pythonlib/basic/2-custom-build-logic/build.mill +++ b/example/pythonlib/basic/2-custom-build-logic/build.mill @@ -7,7 +7,7 @@ import mill._, pythonlib._ object foo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src" / "foo.py" } + def mainScript = Task.Source { "src/foo.py" } /** All Python source files in this module, recursively from the source directories.*/ def allSourceFiles: T[Seq[PathRef]] = Task { diff --git a/example/pythonlib/basic/3-multi-module/build.mill b/example/pythonlib/basic/3-multi-module/build.mill index 2d5002805b3..3ac3b10d9c7 100644 --- a/example/pythonlib/basic/3-multi-module/build.mill +++ b/example/pythonlib/basic/3-multi-module/build.mill @@ -8,11 +8,11 @@ trait MyModule extends PythonModule { object foo extends MyModule { def moduleDeps = Seq(bar) - def mainScript = Task.Source { millSourcePath / "src" / "foo.py" } + def mainScript = Task.Source { "src/foo.py" } } object bar extends MyModule { - def mainScript = Task.Source { millSourcePath / "src" / "bar.py" } + def mainScript = Task.Source { "src/bar.py" } def pythonDeps = Seq("Jinja2==3.1.4") } diff --git a/example/pythonlib/module/1-common-config/build.mill b/example/pythonlib/module/1-common-config/build.mill index 87e1001963c..e457e814cb8 100644 --- a/example/pythonlib/module/1-common-config/build.mill +++ b/example/pythonlib/module/1-common-config/build.mill @@ -12,7 +12,7 @@ object foo extends PythonModule { def pythonDeps = Seq("MarkupSafe==3.0.2", "Jinja2==3.1.4") // choose a main Script to run if there are multiple present - def mainScript = Task.Source { millSourcePath / "custom-src" / "foo2.py" } + def mainScript = Task.Source { "custom-src/foo2.py" } // Add (or replace) source folders for the module to use def sources = Task.Sources { diff --git a/example/pythonlib/module/2-custom-tasks/build.mill b/example/pythonlib/module/2-custom-tasks/build.mill index 9a4a73e6883..4731ac56153 100644 --- a/example/pythonlib/module/2-custom-tasks/build.mill +++ b/example/pythonlib/module/2-custom-tasks/build.mill @@ -15,7 +15,7 @@ object foo extends PythonModule { def pythonDeps = Seq("argparse==1.4.0", "jinja2==3.1.4") - def mainScript = Task.Source { millSourcePath / "src" / "foo.py" } + def mainScript = Task.Source { "src/foo.py" } def generatedSources: T[Seq[PathRef]] = Task { val destPath = Task.dest / "generatedSources" diff --git a/example/pythonlib/module/4-compilation-execution-flags/build.mill b/example/pythonlib/module/4-compilation-execution-flags/build.mill index e72e192271f..6387ac7425a 100644 --- a/example/pythonlib/module/4-compilation-execution-flags/build.mill +++ b/example/pythonlib/module/4-compilation-execution-flags/build.mill @@ -2,7 +2,7 @@ package build import mill._, pythonlib._ object `package` extends RootModule with PythonModule { - def mainScript = Task.Source { millSourcePath / "src" / "foo.py" } + def mainScript = Task.Source { "src/foo.py" } def pythonOptions = Seq("-Wall", "-Xdev") def forkEnv = Map("MY_ENV_VAR" -> "HELLO MILL!") } diff --git a/example/pythonlib/module/5-resources/build.mill b/example/pythonlib/module/5-resources/build.mill index 9bf431557f0..2d279a35dab 100644 --- a/example/pythonlib/module/5-resources/build.mill +++ b/example/pythonlib/module/5-resources/build.mill @@ -2,13 +2,13 @@ package build import mill._, pythonlib._ object foo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src" / "foo.py" } + def mainScript = Task.Source { "src/foo.py" } def resources = Task.Sources { super.resources() ++ Seq(PathRef(millSourcePath / "custom")) } object test extends PythonTests with TestModule.Unittest { - def otherFiles = Task.Source(millSourcePath / "other-files") + def otherFiles = Task.Source("other-files") def forkEnv: T[Map[String, String]] = super.forkEnv() ++ Map("OTHER_FILES_DIR" -> otherFiles().path.toString) diff --git a/example/pythonlib/module/6-pex-config/build.mill b/example/pythonlib/module/6-pex-config/build.mill index c9a094a0e23..f219fffc584 100644 --- a/example/pythonlib/module/6-pex-config/build.mill +++ b/example/pythonlib/module/6-pex-config/build.mill @@ -7,7 +7,7 @@ import mill._, pythonlib._ object foo extends PythonModule { // This Script will be the entry point for the bundle - def mainScript = Task.Source { millSourcePath / "src" / "foo.py" } + def mainScript = Task.Source { "src/foo.py" } // These Dependencies will be used in the bundle def pythonDeps = Seq("pyfiglet==1.0.2", "termcolor==2.5.0") diff --git a/example/pythonlib/publishing/2-publish-module-advanced/build.mill b/example/pythonlib/publishing/2-publish-module-advanced/build.mill index beb0354f58c..530ef71f1f5 100644 --- a/example/pythonlib/publishing/2-publish-module-advanced/build.mill +++ b/example/pythonlib/publishing/2-publish-module-advanced/build.mill @@ -39,7 +39,7 @@ object `package` extends RootModule with PythonModule with PublishModule { def publishVersion = "0.0.3" // you could also reference an existing setup.py file directly, e.g. - // `def setup = Task.Source { millSourcePath / "setup.py" }` + // `def setup = Task.Source { "setup.py" }` def setup = Task { val str = s"""#from setuptools import setup diff --git a/example/pythonlib/testing/1-test-suite/build.mill b/example/pythonlib/testing/1-test-suite/build.mill index d440ffc1454..9bed86884c6 100644 --- a/example/pythonlib/testing/1-test-suite/build.mill +++ b/example/pythonlib/testing/1-test-suite/build.mill @@ -2,9 +2,9 @@ package build import mill._, pythonlib._ object foo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src/foo.py" } + def mainScript = Task.Source { "src/foo.py" } object test extends PythonTests with TestModule.Unittest { - def mainScript = Task.Source { millSourcePath / "src/test_foo.py" } + def mainScript = Task.Source { "src/test_foo.py" } } } @@ -51,7 +51,7 @@ OK // details on how to use each one from the command line. object bar extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src/bar.py" } + def mainScript = Task.Source { "src/bar.py" } object test extends PythonTests with TestModule.Pytest } diff --git a/example/pythonlib/testing/2-test-deps/build.mill b/example/pythonlib/testing/2-test-deps/build.mill index f78cdcd6b20..561de57a3e3 100644 --- a/example/pythonlib/testing/2-test-deps/build.mill +++ b/example/pythonlib/testing/2-test-deps/build.mill @@ -6,7 +6,7 @@ import mill._, pythonlib._ object foo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src/foo.py" } + def mainScript = Task.Source { "src/foo.py" } def moduleDeps = Seq(bar) @@ -23,7 +23,7 @@ object foo extends PythonModule { object bar extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src/bar.py" } + def mainScript = Task.Source { "src/bar.py" } object test extends PythonTests with TestModule.Unittest diff --git a/example/pythonlib/testing/3-integration-suite/build.mill b/example/pythonlib/testing/3-integration-suite/build.mill index b0fbfa5e764..f6f6118a97e 100644 --- a/example/pythonlib/testing/3-integration-suite/build.mill +++ b/example/pythonlib/testing/3-integration-suite/build.mill @@ -7,7 +7,7 @@ import mill._, pythonlib._ object foo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src/foo.py" } + def mainScript = Task.Source { "src/foo.py" } object test extends PythonTests with TestModule.Unittest diff --git a/example/pythonlib/web/1-hello-flask/build.mill b/example/pythonlib/web/1-hello-flask/build.mill index 661c36a9b70..2cf31d9324c 100644 --- a/example/pythonlib/web/1-hello-flask/build.mill +++ b/example/pythonlib/web/1-hello-flask/build.mill @@ -6,7 +6,7 @@ import mill._, pythonlib._ object foo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src/foo.py" } + def mainScript = Task.Source { "src/foo.py" } def pythonDeps = Seq("flask==3.1.0") diff --git a/example/pythonlib/web/2-todo-flask/build.mill b/example/pythonlib/web/2-todo-flask/build.mill index ac903686234..ccd697a8219 100644 --- a/example/pythonlib/web/2-todo-flask/build.mill +++ b/example/pythonlib/web/2-todo-flask/build.mill @@ -7,7 +7,7 @@ import mill._, pythonlib._ object todo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src/app.py" } + def mainScript = Task.Source { "src/app.py" } def pythonDeps = Seq("flask==3.1.0", "Flask-SQLAlchemy==3.1.1", "Flask-WTF==1.2.2") diff --git a/example/pythonlib/web/3-hello-django/build.mill b/example/pythonlib/web/3-hello-django/build.mill index cd85cfc7afa..4c323cb96f7 100644 --- a/example/pythonlib/web/3-hello-django/build.mill +++ b/example/pythonlib/web/3-hello-django/build.mill @@ -6,7 +6,7 @@ import mill._, pythonlib._ object foo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src/manage.py" } + def mainScript = Task.Source { "src/manage.py" } def pythonDeps = Seq("django==5.1.4") diff --git a/example/pythonlib/web/4-todo-django/build.mill b/example/pythonlib/web/4-todo-django/build.mill index b992704855f..2f0cc218267 100644 --- a/example/pythonlib/web/4-todo-django/build.mill +++ b/example/pythonlib/web/4-todo-django/build.mill @@ -6,7 +6,7 @@ import mill._, pythonlib._ object todo extends PythonModule { - def mainScript = Task.Source { millSourcePath / "src/manage.py" } + def mainScript = Task.Source { "src/manage.py" } def pythonDeps = Seq("django==5.1.4") diff --git a/example/scalalib/module/7-resources/build.mill b/example/scalalib/module/7-resources/build.mill index 62d82a99035..03c8243b4fc 100644 --- a/example/scalalib/module/7-resources/build.mill +++ b/example/scalalib/module/7-resources/build.mill @@ -12,7 +12,7 @@ object foo extends ScalaModule { def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.8.5") def testFramework = "utest.runner.Framework" - def otherFiles = Task.Source(millSourcePath / "other-files") + def otherFiles = Task.Source("other-files") def forkEnv = super.forkEnv() ++ Map( "OTHER_FILES_DIR" -> otherFiles().path.toString diff --git a/example/thirdparty/acyclic/build.mill b/example/thirdparty/acyclic/build.mill index cabfc027b20..b6867c9857d 100644 --- a/example/thirdparty/acyclic/build.mill +++ b/example/thirdparty/acyclic/build.mill @@ -39,7 +39,7 @@ trait AcyclicModule extends CrossScalaModule with PublishModule { def compileIvyDeps = Agg(Deps.scalaCompiler(crossScalaVersion)) object test extends ScalaTests with TestModule.Utest { - def sources = Task.Sources(millSourcePath / "src", millSourcePath / "resources") + def sources = Task.Sources("src", "resources") def ivyDeps = Agg(Deps.utest, Deps.scalaCompiler(crossScalaVersion)) } } diff --git a/example/thirdparty/arrow/build.mill b/example/thirdparty/arrow/build.mill index 7fb0b31bb37..cc9475a71e2 100644 --- a/example/thirdparty/arrow/build.mill +++ b/example/thirdparty/arrow/build.mill @@ -135,10 +135,10 @@ object `package` extends RootModule { override def sources: T[Seq[PathRef]] = Task.Sources { val sourcesRootPath = millSourcePath / "src" var sources = Seq("common", platformCrossSuffix) - .map(platform => PathRef(sourcesRootPath / s"${platform}Main" / "kotlin")) + .map(platform => PathRef(sourcesRootPath / s"${platform}Main/kotlin")) .filter(p => os.exists(p.path)) if (platformCrossSuffix != "jvm") { - val nonJvmSourcesPath = sourcesRootPath / "nonJvmMain" / "kotlin" + val nonJvmSourcesPath = sourcesRootPath / "nonJvmMain/kotlin" if (os.exists(nonJvmSourcesPath)) { sources ++= Seq(PathRef(nonJvmSourcesPath)) } @@ -163,7 +163,7 @@ object `package` extends RootModule { override def sources: T[Seq[PathRef]] = Task.Sources { val sourcesRootPath = outer.millSourcePath / "src" Seq("common", outer.platformCrossSuffix) - .map(platform => PathRef(sourcesRootPath / s"${platform}Test" / "kotlin")) + .map(platform => PathRef(sourcesRootPath / s"${platform}Test/kotlin")) .filter(p => os.exists(p.path)) } } diff --git a/example/thirdparty/mockito/build.mill b/example/thirdparty/mockito/build.mill index e1adef2960d..6e1dd2eec1f 100644 --- a/example/thirdparty/mockito/build.mill +++ b/example/thirdparty/mockito/build.mill @@ -228,7 +228,7 @@ object `package` extends RootModule with MockitoModule { // trait BundleModule extends MockitoModule{ // def bundleName: String = millModuleSegments.last.value // override def millSourcePath = `osgi-test`.millSourcePath -// def sources = Task.Sources(millSourcePath / "src" / bundleName / "java") +// def sources = Task.Sources("src" / bundleName / "java") // // def manifest = super.manifest().add( // "Bundle-Name" -> bundleName, diff --git a/example/thirdparty/netty/build.mill b/example/thirdparty/netty/build.mill index 8e4551032e4..5079d147252 100644 --- a/example/thirdparty/netty/build.mill +++ b/example/thirdparty/netty/build.mill @@ -85,7 +85,7 @@ trait NettyModule extends NettyBaseModule { trait NettyJniModule extends NettyModule { def jniLibraryName: T[String] - def cSources = Task.Source(millSourcePath / "src/main/c") + def cSources = Task.Source("src/main/c") def resources = Task { os.copy(clang().path, Task.dest / "META-INF/native" / jniLibraryName(), createFolders = true) Seq(PathRef(Task.dest)) @@ -245,7 +245,7 @@ object common extends NettyModule { ivy"org.jctools:jctools-core:4.0.5" ) - def script = Task.Source(millSourcePath / "src/main/script") + def script = Task.Source("src/main/script") def generatedSources0 = Task { val shell = new groovy.lang.GroovyShell() @@ -456,7 +456,7 @@ object `testsuite-native` extends NettyTestSuiteModule { `transport-native-epoll` ) def testModuleDeps = Seq(`resolver-dns-classes-macos`) - override def sources = Task.Sources(millSourcePath / "src/test/java") + override def sources = Task.Sources("src/test/java") } object `testsuite-native-image` extends NettyTestSuiteModule { @@ -493,7 +493,7 @@ object `testsuite-osgi` extends NettyTestSuiteModule { `transport-udt` ) - override def sources = Task.Sources(millSourcePath / "src/test/java") + override def sources = Task.Sources("src/test/java") def ivyDeps = super.ivyDeps() ++ Agg( ivy"org.apache.felix:org.apache.felix.configadmin:1.9.14", @@ -506,7 +506,7 @@ object `testsuite-osgi` extends NettyTestSuiteModule { object `testsuite-shading` extends NettyTestSuiteModule { def moduleDeps = Seq(common) - override def sources = Task.Sources(millSourcePath / "src/test/java") + override def sources = Task.Sources("src/test/java") } object transport extends NettyModule { @@ -556,8 +556,8 @@ object `transport-native-unix-common` extends NettyModule { def moduleDeps = Seq(common, buffer, transport) def ivyDeps = Agg(ivy"org.junit.jupiter:junit-jupiter-api:5.9.0") - def makefile = Task.Source(millSourcePath / "Makefile") - def cSources = Task.Source(millSourcePath / "src/main/c") + def makefile = Task.Source("Makefile") + def cSources = Task.Source("src/main/c") def cHeaders = Task { for (p <- os.walk(cSources().path) if p.ext == "h") { os.copy(p, Task.dest / p.relativeTo(cSources().path), createFolders = true) diff --git a/integration/ide/gen-idea/resources/extended/build.mill b/integration/ide/gen-idea/resources/extended/build.mill index 3a6d98db685..2bcc972d3e9 100644 --- a/integration/ide/gen-idea/resources/extended/build.mill +++ b/integration/ide/gen-idea/resources/extended/build.mill @@ -52,7 +52,7 @@ trait HelloWorldModule extends scalalib.ScalaModule { Seq( // whole file IdeaConfigFile( - os.sub / "runConfigurations" / "testrun.xml", + os.sub / "runConfigurations/testrun.xml", None, Seq(Element("test")) ), diff --git a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala index d44eed2bb88..60b28b4e96f 100644 --- a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala +++ b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala @@ -110,7 +110,7 @@ trait MultiLevelBuildTests extends UtestIntegrationTestSuite { // restarts behave as expected: if (clientServerMode) { // Only one server should be running at any point in time - val Seq(serverFolder) = os.list(tester.workspacePath / "out" / "mill-server") + val Seq(serverFolder) = os.list(tester.workspacePath / "out/mill-server") // client-server mode should never restart in these tests and preserve the same process, val currentServerId = os.read(serverFolder / "serverId") diff --git a/integration/invalidation/selective-execution/resources/build.mill b/integration/invalidation/selective-execution/resources/build.mill index 4b0bf9d6068..fed58b7238b 100644 --- a/integration/invalidation/selective-execution/resources/build.mill +++ b/integration/invalidation/selective-execution/resources/build.mill @@ -1,7 +1,7 @@ import mill._ object foo extends Module { - def fooTask = Task.Source(millSourcePath / "foo.txt") + def fooTask = Task.Source("foo.txt") def fooHelper(p: os.Path) = { "fooHelper " + os.read(p) @@ -15,7 +15,7 @@ object foo extends Module { object bar extends mill.define.TaskModule { // make sure it works with private tasks as well - private def barTask = Task.Source(millSourcePath / "bar.txt") + private def barTask = Task.Source("bar.txt") def barHelper(p: os.Path) = { "barHelper " + os.read(p) diff --git a/integration/invalidation/watch-source-input/resources/build.mill b/integration/invalidation/watch-source-input/resources/build.mill index 5d6b57c4248..662cbfe87ac 100644 --- a/integration/invalidation/watch-source-input/resources/build.mill +++ b/integration/invalidation/watch-source-input/resources/build.mill @@ -3,8 +3,8 @@ import mill._ println("Setting up build.mill") -def foo = Task.Sources(millSourcePath / "foo1.txt", millSourcePath / "foo2.txt") -def bar = Task.Source(millSourcePath / "bar.txt") +def foo = Task.Sources("foo1.txt", "foo2.txt") +def bar = Task.Source("bar.txt") def qux = Task { val fooMsg = "Running qux foo contents " + foo().map(p => os.read(p.path)).mkString(" ") diff --git a/javascriptlib/src/mill/javascriptlib/PublishModule.scala b/javascriptlib/src/mill/javascriptlib/PublishModule.scala index b035c6bd183..b8b8756295e 100644 --- a/javascriptlib/src/mill/javascriptlib/PublishModule.scala +++ b/javascriptlib/src/mill/javascriptlib/PublishModule.scala @@ -131,7 +131,7 @@ trait PublishModule extends TypeScriptModule { private def pubGenSources: T[Unit] = Task { val allGeneratedSources = pubBaseModeGenSources() ++ pubModDepsGenSources() allGeneratedSources.foreach { target => - val destination = publishDir().path / "typescript" / "generatedSources" / target.path.last + val destination = publishDir().path / "typescript/generatedSources" / target.path.last os.makeDir.all(destination / os.up) os.copy.over( target.path, diff --git a/javascriptlib/src/mill/javascriptlib/ReactScriptsModule.scala b/javascriptlib/src/mill/javascriptlib/ReactScriptsModule.scala index e569a24e873..14268b7a6fe 100644 --- a/javascriptlib/src/mill/javascriptlib/ReactScriptsModule.scala +++ b/javascriptlib/src/mill/javascriptlib/ReactScriptsModule.scala @@ -71,7 +71,7 @@ trait ReactScriptsModule extends TypeScriptModule { val npm = npmInstall().path val combinedPaths = compilerOptionsPaths() ++ Seq( "*" -> npm / "node_modules", - "typescript" -> npm / "node_modules" / "typescript" + "typescript" -> npm / "node_modules/typescript" ) val combinedCompilerOptions: Map[String, ujson.Value] = compilerOptions() ++ Map( @@ -108,7 +108,7 @@ trait ReactScriptsModule extends TypeScriptModule { override def bundle: Target[PathRef] = Task { val compiled = compile()._1.path os.call( - ("node", compiled / "node_modules" / "react-scripts" / "bin" / "react-scripts.js", "build"), + ("node", compiled / "node_modules/react-scripts/bin/react-scripts.js", "build"), cwd = compiled, stdout = os.Inherit, env = forkEnv() @@ -142,7 +142,7 @@ trait ReactScriptsModule extends TypeScriptModule { os.call( ( "node", - (compiled / "node_modules" / "react-scripts" / "bin" / "react-scripts.js").toString, + (compiled / "node_modules/react-scripts/bin/react-scripts.js").toString, "test", "--watchAll=false" ), diff --git a/javascriptlib/src/mill/javascriptlib/RsWithServeModule.scala b/javascriptlib/src/mill/javascriptlib/RsWithServeModule.scala index fa7aa8cf972..61fc110ce2c 100644 --- a/javascriptlib/src/mill/javascriptlib/RsWithServeModule.scala +++ b/javascriptlib/src/mill/javascriptlib/RsWithServeModule.scala @@ -15,7 +15,7 @@ trait RsWithServeModule extends ReactScriptsModule { val env = forkEnv() os.call( ( - (compiled / "node_modules" / "serve" / "bin" / "serve.js").toString, + (compiled / "node_modules/serve/bin/serve.js").toString, "-s", build, "-l", diff --git a/javascriptlib/src/mill/javascriptlib/TypeScriptModule.scala b/javascriptlib/src/mill/javascriptlib/TypeScriptModule.scala index 01830c0fcd5..f75b5e65202 100644 --- a/javascriptlib/src/mill/javascriptlib/TypeScriptModule.scala +++ b/javascriptlib/src/mill/javascriptlib/TypeScriptModule.scala @@ -50,7 +50,7 @@ trait TypeScriptModule extends Module { outer => PathRef(Task.dest) } - def sources: T[PathRef] = Task.Source(millSourcePath / "src") + def sources: T[PathRef] = Task.Source("src") def resources: T[Seq[PathRef]] = Task { Seq(PathRef(millSourcePath / "resources")) } diff --git a/kotlinlib/src/mill/kotlinlib/js/KotlinJsModule.scala b/kotlinlib/src/mill/kotlinlib/js/KotlinJsModule.scala index 71cbdda4c84..3e1c5473e7d 100644 --- a/kotlinlib/src/mill/kotlinlib/js/KotlinJsModule.scala +++ b/kotlinlib/src/mill/kotlinlib/js/KotlinJsModule.scala @@ -486,11 +486,11 @@ trait KotlinJsModule extends KotlinModule { outer => // otherwise with random versions there is a possibility to have conflict // between the versions of the shared transitive deps private def mochaModule = Task { - PathRef(nodeModulesDir().path / "node_modules" / "mocha" / "bin" / "mocha.js") + PathRef(nodeModulesDir().path / "node_modules/mocha/bin/mocha.js") } private def sourceMapSupportModule = Task { - PathRef(nodeModulesDir().path / "node_modules" / "source-map-support" / "register.js") + PathRef(nodeModulesDir().path / "node_modules/source-map-support/register.js") } // endregion diff --git a/kotlinlib/test/src/mill/kotlinlib/HelloWorldTests.scala b/kotlinlib/test/src/mill/kotlinlib/HelloWorldTests.scala index b169e96bfcd..86b636cad37 100644 --- a/kotlinlib/test/src/mill/kotlinlib/HelloWorldTests.scala +++ b/kotlinlib/test/src/mill/kotlinlib/HelloWorldTests.scala @@ -89,7 +89,7 @@ object HelloWorldTests extends TestSuite { test("failures") { val eval = testEval() - val mainJava = HelloWorldKotlin.millSourcePath / "main" / "src" / "Hello.kt" + val mainJava = HelloWorldKotlin.millSourcePath / "main/src/Hello.kt" HelloWorldKotlin.main.crossModules.foreach(m => { diff --git a/kotlinlib/test/src/mill/kotlinlib/MixedHelloWorldTests.scala b/kotlinlib/test/src/mill/kotlinlib/MixedHelloWorldTests.scala index 77c58237fff..b0c3c6970fa 100644 --- a/kotlinlib/test/src/mill/kotlinlib/MixedHelloWorldTests.scala +++ b/kotlinlib/test/src/mill/kotlinlib/MixedHelloWorldTests.scala @@ -76,7 +76,7 @@ object MixedHelloWorldTests extends TestSuite { MixedHelloWorldKotlin.main.crossModules.foreach(m => { val mainJava = - MixedHelloWorldKotlin.millSourcePath / "main" / "src" / "hello" / "KotlinHello.kt" + MixedHelloWorldKotlin.millSourcePath / "main/src/hello/KotlinHello.kt" val Right(_) = eval.apply(m.compile) diff --git a/kotlinlib/test/src/mill/kotlinlib/contrib/kover/KoverModuleTests.scala b/kotlinlib/test/src/mill/kotlinlib/contrib/kover/KoverModuleTests.scala index eee518be48c..842a36429a9 100644 --- a/kotlinlib/test/src/mill/kotlinlib/contrib/kover/KoverModuleTests.scala +++ b/kotlinlib/test/src/mill/kotlinlib/contrib/kover/KoverModuleTests.scala @@ -13,7 +13,7 @@ object KoverModuleTests extends TestSuite { val kotlinVersion = "1.9.24" - val resourcePath = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "contrib" / "kover" + val resourcePath = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "contrib/kover" object module extends TestBaseModule { diff --git a/kotlinlib/test/src/mill/kotlinlib/contrib/ktfmt/KtfmtModuleTests.scala b/kotlinlib/test/src/mill/kotlinlib/contrib/ktfmt/KtfmtModuleTests.scala index b1a8afe2c62..4f29b90f409 100644 --- a/kotlinlib/test/src/mill/kotlinlib/contrib/ktfmt/KtfmtModuleTests.scala +++ b/kotlinlib/test/src/mill/kotlinlib/contrib/ktfmt/KtfmtModuleTests.scala @@ -17,7 +17,7 @@ object KtfmtModuleTests extends TestSuite { def tests: Tests = Tests { val (before, after) = { - val root = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "contrib" / "ktfmt" + val root = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "contrib/ktfmt" (root / "before", root / "after") } @@ -25,7 +25,7 @@ object KtfmtModuleTests extends TestSuite { assert( checkState( afterFormat(before, style = "kotlin"), - after / "style" / "kotlin" + after / "style/kotlin" ) ) } @@ -34,7 +34,7 @@ object KtfmtModuleTests extends TestSuite { assert( checkState( afterFormat(before, style = "google"), - after / "style" / "google" + after / "style/google" ) ) } @@ -43,7 +43,7 @@ object KtfmtModuleTests extends TestSuite { assert( checkState( afterFormat(before, style = "meta"), - after / "style" / "meta" + after / "style/meta" ) ) } @@ -65,7 +65,7 @@ object KtfmtModuleTests extends TestSuite { test("ktfmt - explicit files") { checkState( afterFormat(before, sources = Seq(module.sources)), - after / "style" / "kotlin" + after / "style/kotlin" ) } @@ -74,7 +74,7 @@ object KtfmtModuleTests extends TestSuite { assert( checkState( afterFormatAll(before), - after / "style" / "kotlin" + after / "style/kotlin" ) ) } diff --git a/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsCompileTests.scala b/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsCompileTests.scala index aa992797679..ad5cf303e76 100644 --- a/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsCompileTests.scala +++ b/kotlinlib/test/src/mill/kotlinlib/js/KotlinJsCompileTests.scala @@ -34,8 +34,8 @@ object KotlinJsCompileTests extends TestSuite { val irDir = result.value.classes.path assert( os.isDir(irDir), - os.exists(irDir / "default" / "manifest"), - os.exists(irDir / "default" / "linkdata" / "package_foo"), + os.exists(irDir / "default/manifest"), + os.exists(irDir / "default/linkdata/package_foo"), !os.walk(irDir).exists(_.ext == "klib") ) } @@ -43,7 +43,7 @@ object KotlinJsCompileTests extends TestSuite { test("failures") { val eval = testEval() - val compilationUnit = module.foo.millSourcePath / "src" / "foo" / "Hello.kt" + val compilationUnit = module.foo.millSourcePath / "src/foo/Hello.kt" val Right(_) = eval.apply(module.foo.compile) diff --git a/main/define/src/mill/define/Task.scala b/main/define/src/mill/define/Task.scala index be7857fde6c..ab0a4e7b250 100644 --- a/main/define/src/mill/define/Task.scala +++ b/main/define/src/mill/define/Task.scala @@ -65,6 +65,9 @@ object Task extends TaskBase { def Sources(values: Result[Seq[PathRef]])(implicit ctx: mill.define.Ctx): Target[Seq[PathRef]] = macro Target.Internal.sourcesImpl2 + def Sources(values: os.SubPath*)(implicit ctx: mill.define.Ctx): Target[Seq[PathRef]] = + macro Target.Internal.sourcesImpl3 + /** * Similar to [[Source]], but only for a single source file or folder. Defined * using `Task.Source`. @@ -75,6 +78,10 @@ object Task extends TaskBase { def Source(value: Result[PathRef])(implicit ctx: mill.define.Ctx): Target[PathRef] = macro Target.Internal.sourceImpl2 + + def Source(value: os.SubPath)(implicit ctx: mill.define.Ctx): Target[PathRef] = + macro Target.Internal.sourceImpl3 + /** * [[InputImpl]]s, normally defined using `Task.Input`, are [[NamedTask]]s that * re-evaluate every time Mill is run. This is in contrast to [[TargetImpl]]s @@ -476,6 +483,29 @@ object Target extends TaskBase { ) } + def sourcesImpl3(c: Context)(values: c.Expr[os.SubPath]*)(ctx: c.Expr[mill.define.Ctx]) + : c.Expr[Target[Seq[PathRef]]] = { + import c.universe._ + val wrapped = + for (value <- values.toList) + yield Applicative.impl0[Task, PathRef, mill.api.Ctx](c)( + reify(Result.Success(PathRef(ctx.splice.millSourcePath / value.splice))).tree + ).tree + + val taskIsPrivate = isPrivateTargetOption(c) + + mill.define.Cacher.impl0[SourcesImpl](c)( + reify( + new SourcesImpl( + Target.sequence(c.Expr[List[Task[PathRef]]](q"_root_.scala.List(..$wrapped)").splice), + ctx.splice, + taskIsPrivate.splice + ) + ) + ) + } + + def sourceImpl1(c: Context)(value: c.Expr[Result[os.Path]])(ctx: c.Expr[mill.define.Ctx]) : c.Expr[Target[PathRef]] = { import c.universe._ @@ -515,6 +545,28 @@ object Target extends TaskBase { ) } + def sourceImpl3(c: Context)(value: c.Expr[os.SubPath])(ctx: c.Expr[mill.define.Ctx]) + : c.Expr[Target[PathRef]] = { + import c.universe._ + + val wrapped = + Applicative.impl0[Task, PathRef, mill.api.Ctx](c)( + reify(Result.Success(PathRef(ctx.splice.millSourcePath / value.splice))).tree + ) + + val taskIsPrivate = isPrivateTargetOption(c) + + mill.define.Cacher.impl0[Target[PathRef]](c)( + reify( + new SourceImpl( + wrapped.splice, + ctx.splice, + taskIsPrivate.splice + ) + ) + ) + } + def inputImpl[T: c.WeakTypeTag](c: Context)(value: c.Expr[T])( w: c.Expr[upickle.default.Writer[T]], ctx: c.Expr[mill.define.Ctx] diff --git a/main/eval/test/src/mill/eval/JavaCompileJarTests.scala b/main/eval/test/src/mill/eval/JavaCompileJarTests.scala index 7f3322fa1e9..6b563014aab 100644 --- a/main/eval/test/src/mill/eval/JavaCompileJarTests.scala +++ b/main/eval/test/src/mill/eval/JavaCompileJarTests.scala @@ -22,12 +22,11 @@ object JavaCompileJarTests extends TestSuite { val javacSrcPath = resourceFolder / "examples/javac" val tests = Tests { - test("javac") { object Build extends TestBaseModule { - def sourceRootPath = millSourcePath / "src" - def readmePath = millSourcePath / "readme.md" - def resourceRootPath = millSourcePath / "resources" + def sourceRootPath: os.SubPath = "src" + def readmePath: os.SubPath = "readme.md" + def resourceRootPath: os.SubPath = "resources" // sourceRoot -> allSources -> classFiles // | @@ -68,7 +67,7 @@ object JavaCompileJarTests extends TestSuite { def eval[T](t: Task[T]) = evaluator.apply(t) def check(targets: Agg[Task[_]], expected: Agg[Task[_]]) = evaluator.check(targets, expected) - def append(path: os.Path, txt: String) = os.write.append(path, txt) + def append(path: os.SubPath, txt: String) = os.write.append(millSourcePath / path, txt) check( targets = Agg(jar), diff --git a/main/init/maven/src/mill/main/maven/Modeler.scala b/main/init/maven/src/mill/main/maven/Modeler.scala index 7446b439f03..57c779ac5a3 100644 --- a/main/init/maven/src/mill/main/maven/Modeler.scala +++ b/main/init/maven/src/mill/main/maven/Modeler.scala @@ -64,7 +64,7 @@ object Modeler { } def defaultLocalRepository: LocalRepository = - new LocalRepository((os.home / ".m2" / "repository").toIO) + new LocalRepository((os.home / ".m2/repository").toIO) def defaultRemoteRepositories: Seq[RemoteRepository] = Seq( diff --git a/pythonlib/src/mill/pythonlib/PythonModule.scala b/pythonlib/src/mill/pythonlib/PythonModule.scala index 94182a138fe..b7a3dfe414c 100644 --- a/pythonlib/src/mill/pythonlib/PythonModule.scala +++ b/pythonlib/src/mill/pythonlib/PythonModule.scala @@ -43,7 +43,7 @@ trait PythonModule extends PipModule with TaskModule { outer => */ def pythonExe: T[PathRef] = Task { os.call((hostPythonCommand(), "-m", "venv", Task.dest / "venv")) - val python = Task.dest / "venv" / "bin" / "python3" + val python = Task.dest / "venv/bin/python3" os.call((python, "-m", "pip", "install", pipInstallArgs().args), stdout = os.Inherit) PathRef(python) } @@ -53,17 +53,17 @@ trait PythonModule extends PipModule with TaskModule { outer => * * Python modules will be defined relative to these directories. */ - def sources: T[Seq[PathRef]] = Task.Sources { millSourcePath / "src" } + def sources: T[Seq[PathRef]] = Task.Sources { "src" } /** * The folders where the resource files for this module live. */ - def resources: T[Seq[PathRef]] = Task.Sources { millSourcePath / "resources" } + def resources: T[Seq[PathRef]] = Task.Sources { "resources" } /** * The python script to run. This file may not exist if this module is only a library. */ - def mainScript: T[PathRef] = Task.Source { millSourcePath / "src" / "main.py" } + def mainScript: T[PathRef] = Task.Source { "src/main.py" } override def pythonToolDeps: T[Seq[String]] = Task { super.pythonToolDeps() ++ Seq("mypy==1.13.0", "pex==2.24.1") diff --git a/pythonlib/src/mill/pythonlib/RuffModule.scala b/pythonlib/src/mill/pythonlib/RuffModule.scala index 79ea6b15cd0..bfa3d8e799d 100644 --- a/pythonlib/src/mill/pythonlib/RuffModule.scala +++ b/pythonlib/src/mill/pythonlib/RuffModule.scala @@ -17,7 +17,7 @@ trait RuffModule extends PythonModule { * Configuration file to use when running ruff. If this file does not exist, * ruff will use the default settings. */ - def ruffConfigFile: T[PathRef] = Task.Source(millSourcePath / "ruff.toml") + def ruffConfigFile: T[PathRef] = Task.Source("ruff.toml") /** * Global command line options to pass to ruff. These are passed in before any diff --git a/pythonlib/test/src/mill/pythonlib/HelloWorldTests.scala b/pythonlib/test/src/mill/pythonlib/HelloWorldTests.scala index a15882bd5f3..c14d371c996 100644 --- a/pythonlib/test/src/mill/pythonlib/HelloWorldTests.scala +++ b/pythonlib/test/src/mill/pythonlib/HelloWorldTests.scala @@ -16,7 +16,7 @@ object HelloWorldTests extends TestSuite { object qux extends PythonModule { override def moduleDeps: Seq[PythonModule] = Seq(foo) - override def mainScript = Task.Source(millSourcePath / "src" / "qux.py") + override def mainScript = Task.Source("src/qux.py") object test extends PythonTests with TestModule.Unittest } } diff --git a/pythonlib/test/src/mill/pythonlib/RunBackgroundTests.scala b/pythonlib/test/src/mill/pythonlib/RunBackgroundTests.scala index cd020cfda6c..dc045339fd4 100644 --- a/pythonlib/test/src/mill/pythonlib/RunBackgroundTests.scala +++ b/pythonlib/test/src/mill/pythonlib/RunBackgroundTests.scala @@ -8,7 +8,7 @@ object RunBackgroundTests extends TestSuite { object HelloWorldPython extends TestBaseModule { object foo extends PythonModule { - override def mainScript = Task.Source(millSourcePath / "src" / "foo.py") + override def mainScript = Task.Source("src/foo.py") } } @@ -32,7 +32,7 @@ object RunBackgroundTests extends TestSuite { while (lock.probe()) sleepIfTimeAvailable("File never locked by python subprocess") - os.remove.all(eval.outPath / "foo" / "runBackground.dest") + os.remove.all(eval.outPath / "foo/runBackground.dest") while (!lock.probe()) { sleepIfTimeAvailable("File never unlocked after runBackground.dest removed") diff --git a/scalalib/src/mill/javalib/android/AndroidAppModule.scala b/scalalib/src/mill/javalib/android/AndroidAppModule.scala index 5b853e92b5f..c77f08699ca 100644 --- a/scalalib/src/mill/javalib/android/AndroidAppModule.scala +++ b/scalalib/src/mill/javalib/android/AndroidAppModule.scala @@ -89,7 +89,7 @@ trait AndroidAppModule extends JavaModule { super.repositoriesTask() :+ AndroidSdkModule.mavenGoogle } - override def sources: T[Seq[PathRef]] = Task.Sources(millSourcePath / "src/main/java") + override def sources: T[Seq[PathRef]] = Task.Sources("src/main/java") /** * Provides access to the Android SDK configuration. @@ -99,7 +99,7 @@ trait AndroidAppModule extends JavaModule { /** * Provides os.Path to an XML file containing configuration and metadata about your android application. */ - def androidManifest: Task[PathRef] = Task.Source(millSourcePath / "src/main/AndroidManifest.xml") + def androidManifest: Task[PathRef] = Task.Source("src/main/AndroidManifest.xml") /** * Name of the release keystore file. Default is not set. diff --git a/scalalib/src/mill/javalib/android/AndroidSdkModule.scala b/scalalib/src/mill/javalib/android/AndroidSdkModule.scala index 9f082cddd47..4882c331663 100644 --- a/scalalib/src/mill/javalib/android/AndroidSdkModule.scala +++ b/scalalib/src/mill/javalib/android/AndroidSdkModule.scala @@ -86,7 +86,7 @@ trait AndroidSdkModule extends Module { */ def lintToolPath: T[PathRef] = Task { installAndroidSdkComponents() - PathRef(sdkPath().path / "cmdline-tools" / "latest" / "bin" / "lint") + PathRef(sdkPath().path / "cmdline-tools/latest/bin/lint") } /** @@ -290,7 +290,7 @@ trait AndroidSdkModule extends Module { case _ => false }) .maxBy(_._2.head.toInt)._1 - sdkManagerPath = latestCmdlineToolsPath / "bin" / "sdkmanager" + sdkManagerPath = latestCmdlineToolsPath / "bin/sdkmanager" } } Some(sdkManagerPath).filter(os.exists) diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index 8a166bef3e4..39f70348241 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -825,20 +825,20 @@ trait JavaModule /** * The folders where the source files for this module live */ - def sources: T[Seq[PathRef]] = Task.Sources { millSourcePath / "src" } + def sources: T[Seq[PathRef]] = Task.Sources { "src" } /** * The folders where the resource files for this module live. * If you need resources to be seen by the compiler, use [[compileResources]]. */ - def resources: T[Seq[PathRef]] = Task.Sources { millSourcePath / "resources" } + def resources: T[Seq[PathRef]] = Task.Sources { "resources" } /** * The folders where the compile time resource files for this module live. * If your resources files do not necessarily need to be seen by the compiler, * you should use [[resources]] instead. */ - def compileResources: T[Seq[PathRef]] = Task.Sources { millSourcePath / "compile-resources" } + def compileResources: T[Seq[PathRef]] = Task.Sources { "compile-resources" } /** * Folders containing source files that are generated rather than @@ -1106,7 +1106,7 @@ trait JavaModule * on the doc tool that is actually used. * @see [[docSources]] */ - def docResources: T[Seq[PathRef]] = Task.Sources(millSourcePath / "docs") + def docResources: T[Seq[PathRef]] = Task.Sources("docs") /** * Control whether `docJar`-target should use a file to pass command line arguments to the javadoc tool. diff --git a/scalalib/test/src/mill/javalib/palantirformat/PalantirFormatModuleTest.scala b/scalalib/test/src/mill/javalib/palantirformat/PalantirFormatModuleTest.scala index 9068459c23e..9be06859e48 100644 --- a/scalalib/test/src/mill/javalib/palantirformat/PalantirFormatModuleTest.scala +++ b/scalalib/test/src/mill/javalib/palantirformat/PalantirFormatModuleTest.scala @@ -11,7 +11,7 @@ object PalantirFormatModuleTest extends TestSuite { def tests: Tests = Tests { val (before, after) = { - val root = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "javalib" / "palantirformat" + val root = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "javalib/palantirformat" (root / "before", root / "after") } diff --git a/scalalib/test/src/mill/javalib/revapi/RevapiModuleTests.scala b/scalalib/test/src/mill/javalib/revapi/RevapiModuleTests.scala index f59127b8cdc..ec5332791a5 100644 --- a/scalalib/test/src/mill/javalib/revapi/RevapiModuleTests.scala +++ b/scalalib/test/src/mill/javalib/revapi/RevapiModuleTests.scala @@ -11,7 +11,7 @@ object RevapiModuleTests extends TestSuite { def tests: Tests = Tests { - val root = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "javalib" / "revapi" + val root = os.Path(sys.env("MILL_TEST_RESOURCE_DIR")) / "javalib/revapi" val conf = root / "conf" val textReport = "report.txt" diff --git a/scalalib/test/src/mill/scalalib/TestRunnerTestUtils.scala b/scalalib/test/src/mill/scalalib/TestRunnerTestUtils.scala index 06a6eca9f19..d36037751eb 100644 --- a/scalalib/test/src/mill/scalalib/TestRunnerTestUtils.scala +++ b/scalalib/test/src/mill/scalalib/TestRunnerTestUtils.scala @@ -107,7 +107,7 @@ object TestRunnerTestUtils { moduleName: String, action: String = "test" ): JUnitReportMatch = { - val reportPath: Path = outPath / moduleName / s"$action.dest" / "test-report.xml" + val reportPath: Path = outPath / moduleName / s"$action.dest/test-report.xml" val reportXML = XML.loadFile(reportPath.toIO) new JUnitReportMatch { override def shouldHave(statuses: (Int, Status)*): Unit = { diff --git a/testkit/package.mill b/testkit/package.mill index e25bd3311dc..c1e4fda9711 100644 --- a/testkit/package.mill +++ b/testkit/package.mill @@ -8,7 +8,7 @@ object `package` extends RootModule with build.MillPublishScalaModule { def sources = super.sources() ++ - Seq(PathRef(build.millSourcePath / "mill-build" / "src")) + Seq(PathRef(build.millSourcePath / "mill-build/src")) def forkEnv = super.forkEnv() ++ Map("MILL_EXECUTABLE_PATH" -> build.dist.launcher().path.toString()) diff --git a/testkit/test/resources/example-test-example-project/build.mill b/testkit/test/resources/example-test-example-project/build.mill index 4a30be3ff78..e75ff8a6d11 100644 --- a/testkit/test/resources/example-test-example-project/build.mill +++ b/testkit/test/resources/example-test-example-project/build.mill @@ -1,7 +1,7 @@ package build import mill._ -def testSource = Task.Source(millSourcePath / "source-file.txt") +def testSource = Task.Source("source-file.txt") def testTask = Task { os.read(testSource().path).toUpperCase() } /** Usage diff --git a/testkit/test/resources/integration-test-example-project/build.mill b/testkit/test/resources/integration-test-example-project/build.mill index 896b7ac6fe7..fa1e358efc0 100644 --- a/testkit/test/resources/integration-test-example-project/build.mill +++ b/testkit/test/resources/integration-test-example-project/build.mill @@ -1,5 +1,5 @@ package build import mill._ -def testSource = Task.Source(millSourcePath / "source-file.txt") +def testSource = Task.Source("source-file.txt") def testTask = Task { os.read(testSource().path).toUpperCase() } diff --git a/testkit/test/src/mill/testkit/UnitTesterTests.scala b/testkit/test/src/mill/testkit/UnitTesterTests.scala index 96aeb9c66c5..975dc3e2a86 100644 --- a/testkit/test/src/mill/testkit/UnitTesterTests.scala +++ b/testkit/test/src/mill/testkit/UnitTesterTests.scala @@ -20,7 +20,7 @@ object UnitTesterTests extends TestSuite { test("sources") { object build extends TestBaseModule { - def testSource = Task.Source(millSourcePath / "source-file.txt") + def testSource = Task.Source("source-file.txt") def testTask = Task { os.read(testSource().path).toUpperCase() } } From f15d3ab0ca0043dfd0d88191b5bc6c57dccc31db Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 6 Feb 2025 10:50:44 +0800 Subject: [PATCH 2/4] . --- example/pythonlib/testing/2-test-deps/build.mill | 6 ++++-- example/thirdparty/arrow/build.mill | 4 ++-- scalalib/test/src/mill/scalalib/TestRunnerTestUtils.scala | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/example/pythonlib/testing/2-test-deps/build.mill b/example/pythonlib/testing/2-test-deps/build.mill index 561de57a3e3..1d5123f4854 100644 --- a/example/pythonlib/testing/2-test-deps/build.mill +++ b/example/pythonlib/testing/2-test-deps/build.mill @@ -49,13 +49,15 @@ object bar extends PythonModule { > ./mill foo.test ...Using BarTestUtils.bar_assert_equals... -...test_equal_string (test.TestScript...)...ok... +...test_equal_string (test.TestScript...)... + ...ok... ...Ran 1 test... ...OK... > ./mill bar.test ...Using BarTestUtils.bar_assert_equals... -...test_mean (test.TestScript...)...ok... +...test_mean (test.TestScript...)... + ...ok... ...Ran 1 test... ...OK... diff --git a/example/thirdparty/arrow/build.mill b/example/thirdparty/arrow/build.mill index cc9475a71e2..4da424f68a1 100644 --- a/example/thirdparty/arrow/build.mill +++ b/example/thirdparty/arrow/build.mill @@ -135,7 +135,7 @@ object `package` extends RootModule { override def sources: T[Seq[PathRef]] = Task.Sources { val sourcesRootPath = millSourcePath / "src" var sources = Seq("common", platformCrossSuffix) - .map(platform => PathRef(sourcesRootPath / s"${platform}Main/kotlin")) + .map(platform => PathRef(sourcesRootPath / s"${platform}Main" / "kotlin")) .filter(p => os.exists(p.path)) if (platformCrossSuffix != "jvm") { val nonJvmSourcesPath = sourcesRootPath / "nonJvmMain/kotlin" @@ -163,7 +163,7 @@ object `package` extends RootModule { override def sources: T[Seq[PathRef]] = Task.Sources { val sourcesRootPath = outer.millSourcePath / "src" Seq("common", outer.platformCrossSuffix) - .map(platform => PathRef(sourcesRootPath / s"${platform}Test/kotlin")) + .map(platform => PathRef(sourcesRootPath / s"${platform}Test" / "kotlin")) .filter(p => os.exists(p.path)) } } diff --git a/scalalib/test/src/mill/scalalib/TestRunnerTestUtils.scala b/scalalib/test/src/mill/scalalib/TestRunnerTestUtils.scala index d36037751eb..06a6eca9f19 100644 --- a/scalalib/test/src/mill/scalalib/TestRunnerTestUtils.scala +++ b/scalalib/test/src/mill/scalalib/TestRunnerTestUtils.scala @@ -107,7 +107,7 @@ object TestRunnerTestUtils { moduleName: String, action: String = "test" ): JUnitReportMatch = { - val reportPath: Path = outPath / moduleName / s"$action.dest/test-report.xml" + val reportPath: Path = outPath / moduleName / s"$action.dest" / "test-report.xml" val reportXML = XML.loadFile(reportPath.toIO) new JUnitReportMatch { override def shouldHave(statuses: (Int, Status)*): Unit = { From 846521a334f701192cb203785277eb592cd2b6f7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 6 Feb 2025 10:57:38 +0800 Subject: [PATCH 3/4] . --- main/define/src/mill/define/Task.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/main/define/src/mill/define/Task.scala b/main/define/src/mill/define/Task.scala index ab0a4e7b250..10f0ef6ad77 100644 --- a/main/define/src/mill/define/Task.scala +++ b/main/define/src/mill/define/Task.scala @@ -78,7 +78,6 @@ object Task extends TaskBase { def Source(value: Result[PathRef])(implicit ctx: mill.define.Ctx): Target[PathRef] = macro Target.Internal.sourceImpl2 - def Source(value: os.SubPath)(implicit ctx: mill.define.Ctx): Target[PathRef] = macro Target.Internal.sourceImpl3 @@ -484,7 +483,7 @@ object Target extends TaskBase { } def sourcesImpl3(c: Context)(values: c.Expr[os.SubPath]*)(ctx: c.Expr[mill.define.Ctx]) - : c.Expr[Target[Seq[PathRef]]] = { + : c.Expr[Target[Seq[PathRef]]] = { import c.universe._ val wrapped = for (value <- values.toList) @@ -505,7 +504,6 @@ object Target extends TaskBase { ) } - def sourceImpl1(c: Context)(value: c.Expr[Result[os.Path]])(ctx: c.Expr[mill.define.Ctx]) : c.Expr[Target[PathRef]] = { import c.universe._ @@ -546,7 +544,7 @@ object Target extends TaskBase { } def sourceImpl3(c: Context)(value: c.Expr[os.SubPath])(ctx: c.Expr[mill.define.Ctx]) - : c.Expr[Target[PathRef]] = { + : c.Expr[Target[PathRef]] = { import c.universe._ val wrapped = From ea93872e8793967e50d03cdf8c90cf960cb1a1ce Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 6 Feb 2025 14:26:07 +0800 Subject: [PATCH 4/4] Update build.mill --- example/pythonlib/testing/2-test-deps/build.mill | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/pythonlib/testing/2-test-deps/build.mill b/example/pythonlib/testing/2-test-deps/build.mill index 1d5123f4854..4e0b46bbccf 100644 --- a/example/pythonlib/testing/2-test-deps/build.mill +++ b/example/pythonlib/testing/2-test-deps/build.mill @@ -50,14 +50,14 @@ object bar extends PythonModule { > ./mill foo.test ...Using BarTestUtils.bar_assert_equals... ...test_equal_string (test.TestScript...)... - ...ok... +...ok... ...Ran 1 test... ...OK... > ./mill bar.test ...Using BarTestUtils.bar_assert_equals... ...test_mean (test.TestScript...)... - ...ok... +...ok... ...Ran 1 test... ...OK...