Task

mill.define.Task
See theTask companion class
object Task extends TaskBase

Attributes

Companion
class
Source
Task.scala
Graph
Supertypes
class TaskBase
class Object
trait Matchable
class Any
Self type
Task.type

Members list

Type members

Classlikes

class ApplyFactory

Attributes

Source
Task.scala
Supertypes
class Object
trait Matchable
class Any

Attributes

Source
Task.scala
Supertypes
class Object
trait Matchable
class Any
abstract class Ops[+T]

Attributes

Source
Task.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Task[T]
class AnonImpl[T]
trait NamedTask[T]
class Command[T]
trait Target[T]
class InputImpl[T]
class SourceImpl
class SourcesImpl
class TargetImpl[T]
class Worker[T]
Show all
Self type
Task[T]

Value members

Concrete methods

@Scaladoc(value = "/**\n * Creates an anonymous `Task`. These depend on other tasks and\n * be-depended-upon by other tasks, but cannot be run directly from the\n * command line and do not perform any caching. Typically used as helpers to\n * implement `Task{...}` targets.\n */")
inline def Anon[T](inline t: Result[T]): Task[T]

Creates an anonymous Task. These depend on other tasks and be-depended-upon by other tasks, but cannot be run directly from the command line and do not perform any caching. Typically used as helpers to implement Task{...} targets.

Creates an anonymous Task. These depend on other tasks and be-depended-upon by other tasks, but cannot be run directly from the command line and do not perform any caching. Typically used as helpers to implement Task{...} targets.

Attributes

Source
Task.scala
@Scaladoc(value = "/**\n * [[Command]]s are only [[NamedTask]]s defined using\n * `def foo() = Task.Command{...}` and are typically called from the\n * command-line. Unlike other [[NamedTask]]s, [[Command]]s can be defined to\n * take arguments that are automatically converted to command-line\n * arguments, as long as an implicit [[mainargs.TokensReader]] is available.\n */")
inline def Command[T](inline t: Result[T])(implicit inline w: Writer[T], inline ctx: Ctx): Command[T]

Commands are only NamedTasks defined using def foo() = Task.Command{...} and are typically called from the command-line. Unlike other NamedTasks, Commands can be defined to take arguments that are automatically converted to command-line arguments, as long as an implicit mainargs.TokensReader is available.

Commands are only NamedTasks defined using def foo() = Task.Command{...} and are typically called from the command-line. Unlike other NamedTasks, Commands can be defined to take arguments that are automatically converted to command-line arguments, as long as an implicit mainargs.TokensReader is available.

Attributes

Source
Task.scala
@Scaladoc(value = "/**\n * @param exclusive Exclusive commands run serially at the end of an evaluation,\n * without any other tasks running parallel, and without the\n * terminal logging prefixes that are applied to normal tasks.\n * These are normally used for \"top level\" commands which are\n * run directly to perform some action or display some output\n * to the user.\n */")
def Command(t: NamedParameterOnlyDummy, exclusive: Boolean): CommandFactory

Value parameters

exclusive

Exclusive commands run serially at the end of an evaluation, without any other tasks running parallel, and without the terminal logging prefixes that are applied to normal tasks. These are normally used for "top level" commands which are run directly to perform some action or display some output to the user.

Attributes

Source
Task.scala
@Scaladoc(value = "/**\n * [[InputImpl]]s, normally defined using `Task.Input`, are [[NamedTask]]s that\n * re-evaluate every time Mill is run. This is in contrast to [[TargetImpl]]s\n * which only re-evaluate when upstream tasks change.\n *\n * [[InputImpl]]s are useful when you want to capture some input to the Mill\n * build graph that comes from outside: maybe from an environment variable, a\n * JVM system property, the hash returned by `git rev-parse HEAD`. Reading\n * these external mutable variables inside a `Task{...}` [[TargetImpl]] will\n * incorrectly cache them forever. Reading them inside a `Task.Input{...}`\n * will re-compute them every time, and only if the value changes would it\n * continue to invalidate downstream [[TargetImpl]]s\n *\n * The most common case of [[InputImpl]] is [[SourceImpl]] and [[SourcesImpl]],\n * used for detecting changes to source files.\n */")
inline def Input[T](inline value: Result[T])(implicit inline w: Writer[T], inline ctx: Ctx): Target[T]

InputImpls, normally defined using Task.Input, are NamedTasks that re-evaluate every time Mill is run. This is in contrast to TargetImpls which only re-evaluate when upstream tasks change.

InputImpls, normally defined using Task.Input, are NamedTasks that re-evaluate every time Mill is run. This is in contrast to TargetImpls which only re-evaluate when upstream tasks change.

InputImpls are useful when you want to capture some input to the Mill build graph that comes from outside: maybe from an environment variable, a JVM system property, the hash returned by git rev-parse HEAD. Reading these external mutable variables inside a Task{...} TargetImpl will incorrectly cache them forever. Reading them inside a Task.Input{...} will re-compute them every time, and only if the value changes would it continue to invalidate downstream TargetImpls

The most common case of InputImpl is SourceImpl and SourcesImpl, used for detecting changes to source files.

Attributes

Source
Task.scala
@Scaladoc(value = "/**\n * Similar to [[Sources]], but only for a single source file or folder. Defined\n * using `Task.Source`.\n */")
inline def Source(inline value: Result[Path])(implicit inline ctx: Ctx): Target[PathRef]

Similar to Sources, but only for a single source file or folder. Defined using Task.Source.

Similar to Sources, but only for a single source file or folder. Defined using Task.Source.

Attributes

Source
Task.scala
inline def Source(inline value: SubPath)(implicit inline ctx: Ctx): Target[PathRef]

Attributes

Source
Task.scala
@Scaladoc(value = "/**\n * A specialization of [[InputImpl]] defined via `Task.Sources`, [[SourcesImpl]]\n * uses [[PathRef]]s to compute a signature for a set of source files and\n * folders.\n *\n * This is most used when detecting changes in source code: when you edit a\n * file and run `mill compile`, it is the `Task.Sources` that re-computes the\n * signature for you source files/folders and decides whether or not downstream\n * [[TargetImpl]]s need to be invalidated and re-computed.\n */")
inline def Sources(inline values: Result[Path]*)(implicit inline ctx: Ctx): Target[Seq[PathRef]]

A specialization of InputImpl defined via Task.Sources, SourcesImpl uses PathRefs to compute a signature for a set of source files and folders.

A specialization of InputImpl defined via Task.Sources, SourcesImpl uses PathRefs to compute a signature for a set of source files and folders.

This is most used when detecting changes in source code: when you edit a file and run mill compile, it is the Task.Sources that re-computes the signature for you source files/folders and decides whether or not downstream TargetImpls need to be invalidated and re-computed.

Attributes

Source
Task.scala
inline def Sources(inline values: SubPath*)(implicit inline ctx: Ctx, dummy: Boolean): Target[Seq[PathRef]]

Attributes

Source
Task.scala
@Scaladoc(value = "/**\n * [[Worker]] is a [[NamedTask]] that lives entirely in-memory, defined using\n * `Task.Worker{...}`. The value returned by `Task.Worker{...}` is long-lived,\n * persisting as long as the Mill process is kept alive (e.g. via `--watch`,\n * or via its default `MillServerMain` server process). This allows the user to\n * perform in-memory caching that is even more aggressive than the disk-based\n * caching enabled by [[PersistentImpl]]: your [[Worker]] can cache running\n * sub-processes, JVM Classloaders with JITed code, and all sorts of things\n * that do not easily serialize to JSON on disk.\n *\n * Like [[PersistentImpl]], The user defining a [[Worker]] assumes the\n * responsibility of ensuring the implementation is idempotent regardless of\n * what in-memory state the worker may have.\n */")
inline def Worker[T](inline t: Result[T])(implicit inline ctx: Ctx): Worker[T]

Worker is a NamedTask that lives entirely in-memory, defined using Task.Worker{...}. The value returned by Task.Worker{...} is long-lived, persisting as long as the Mill process is kept alive (e.g. via --watch, or via its default MillServerMain server process). This allows the user to perform in-memory caching that is even more aggressive than the disk-based caching enabled by PersistentImpl: your Worker can cache running sub-processes, JVM Classloaders with JITed code, and all sorts of things that do not easily serialize to JSON on disk.

Worker is a NamedTask that lives entirely in-memory, defined using Task.Worker{...}. The value returned by Task.Worker{...} is long-lived, persisting as long as the Mill process is kept alive (e.g. via --watch, or via its default MillServerMain server process). This allows the user to perform in-memory caching that is even more aggressive than the disk-based caching enabled by PersistentImpl: your Worker can cache running sub-processes, JVM Classloaders with JITed code, and all sorts of things that do not easily serialize to JSON on disk.

Like PersistentImpl, The user defining a Worker assumes the responsibility of ensuring the implementation is idempotent regardless of what in-memory state the worker may have.

Attributes

Source
Task.scala
inline def apply[T](inline t: Result[T])(implicit inline rw: ReadWriter[T], inline ctx: Ctx): Target[T]

Attributes

Source
Task.scala
@Scaladoc(value = "/**\n * Persistent tasks are defined using\n * the `Task(persistent = true){...}` syntax. The main difference is that while\n * [[TargetImpl]] deletes the `Task.dest` folder in between runs,\n * [[PersistentImpl]] preserves it. This lets the user make use of files on\n * disk that persistent between runs of the task, e.g. to implement their own\n * fine-grained caching beyond what Mill provides by default.\n *\n * Note that the user defining a `Task(persistent = true)` task is taking on the\n * responsibility of ensuring that their implementation is idempotent, i.e.\n * that it computes the same result whether or not there is data in `Task.dest`.\n * Violating that invariant can result in confusing mis-behaviors\n */")
def apply(t: NamedParameterOnlyDummy, persistent: Boolean): ApplyFactory

Persistent tasks are defined using the Task(persistent = true){...} syntax. The main difference is that while TargetImpl deletes the Task.dest folder in between runs, PersistentImpl preserves it. This lets the user make use of files on disk that persistent between runs of the task, e.g. to implement their own fine-grained caching beyond what Mill provides by default.

Persistent tasks are defined using the Task(persistent = true){...} syntax. The main difference is that while TargetImpl deletes the Task.dest folder in between runs, PersistentImpl preserves it. This lets the user make use of files on disk that persistent between runs of the task, e.g. to implement their own fine-grained caching beyond what Mill provides by default.

Note that the user defining a Task(persistent = true) task is taking on the responsibility of ensuring that their implementation is idempotent, i.e. that it computes the same result whether or not there is data in Task.dest. Violating that invariant can result in confusing mis-behaviors

Attributes

Source
Task.scala

Inherited methods

@Scaladoc(value = "/**\n * Returns the implicit [[mill.api.Ctx.Args.args]] in scope.\n */")
def args(implicit ctx: Args): IndexedSeq[_]

Returns the implicit mill.api.Ctx.Args.args in scope.

Returns the implicit mill.api.Ctx.Args.args in scope.

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * Returns the [[mill.api.Ctx]] that is available within this task\n */")
def ctx()(implicit c: Ctx): Ctx

Returns the mill.api.Ctx that is available within this task

Returns the mill.api.Ctx that is available within this task

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * `Task.dest` is a unique `os.Path` (e.g. `out/classFiles.dest/` or `out/run.dest/`)\n * that is assigned to every Target or Command. It is cleared before your\n * task runs, and you can use it as a scratch space for temporary files or\n * a place to put returned artifacts. This is guaranteed to be unique for\n * every Target or Command, so you can be sure that you will not collide or\n * interfere with anyone else writing to those same paths.\n */")
def dest(implicit ctx: Dest): Path

Task.dest is a unique os.Path (e.g. out/classFiles.dest/ or out/run.dest/) that is assigned to every Target or Command. It is cleared before your task runs, and you can use it as a scratch space for temporary files or a place to put returned artifacts. This is guaranteed to be unique for every Target or Command, so you can be sure that you will not collide or interfere with anyone else writing to those same paths.

Task.dest is a unique os.Path (e.g. out/classFiles.dest/ or out/run.dest/) that is assigned to every Target or Command. It is cleared before your task runs, and you can use it as a scratch space for temporary files or a place to put returned artifacts. This is guaranteed to be unique for every Target or Command, so you can be sure that you will not collide or interfere with anyone else writing to those same paths.

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * `Task.env` is the environment variable map passed to the Mill command when\n * it is run; typically used inside a `Task.Input` to ensure any changes in\n * the env vars are properly detected.\n *\n * Note that you should not use `sys.env`, as Mill\'s long-lived server\n * process means that `sys.env` variables may not be up to date.\n */")
def env(implicit ctx: Env): Map[String, String]

Task.env is the environment variable map passed to the Mill command when it is run; typically used inside a Task.Input to ensure any changes in the env vars are properly detected.

Task.env is the environment variable map passed to the Mill command when it is run; typically used inside a Task.Input to ensure any changes in the env vars are properly detected.

Note that you should not use sys.env, as Mill's long-lived server process means that sys.env variables may not be up to date.

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * Provides the `.fork.async` and `.fork.await` APIs for spawning and joining\n * async futures within your task in a Mill-friendly mannter\n */")
def fork(implicit ctx: Ctx): Api

Provides the .fork.async and .fork.await APIs for spawning and joining async futures within your task in a Mill-friendly mannter

Provides the .fork.async and .fork.await APIs for spawning and joining async futures within your task in a Mill-friendly mannter

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * `Task.log` is the default logger provided for every task. While your task is running,\n * `System.out` and `System.in` are also redirected to this logger. The logs for a\n * task are streamed to standard out/error as you would expect, but each task\'s\n * specific output is also streamed to a log file on disk, e.g. `out/run.log` or\n * `out/classFiles.log` for you to inspect later.\n *\n * Messages logged with `log.debug` appear by default only in the log files.\n * You can use the `--debug` option when running mill to show them on the console too.\n */")
def log(implicit ctx: Log): Logger

Task.log is the default logger provided for every task. While your task is running, System.out and System.in are also redirected to this logger. The logs for a task are streamed to standard out/error as you would expect, but each task's specific output is also streamed to a log file on disk, e.g. out/run.log or out/classFiles.log for you to inspect later.

Task.log is the default logger provided for every task. While your task is running, System.out and System.in are also redirected to this logger. The logs for a task are streamed to standard out/error as you would expect, but each task's specific output is also streamed to a log file on disk, e.g. out/run.log or out/classFiles.log for you to inspect later.

Messages logged with log.debug appear by default only in the log files. You can use the --debug option when running mill to show them on the console too.

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * Report build results to BSP for IDE integration\n */")
def reporter(implicit ctx: Ctx): Int => Option[CompileProblemReporter]

Report build results to BSP for IDE integration

Report build results to BSP for IDE integration

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * Converts a `Seq[Task[T]]` into a `Task[Seq[T]]`\n */")
def sequence[T](source: Seq[Task[T]]): Task[Seq[T]]

Converts a Seq[Task[T]] into a Task[Seq[T]]

Converts a Seq[Task[T]] into a Task[Seq[T]]

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * Report test results to BSP for IDE integration\n */")
def testReporter(implicit ctx: Ctx): TestReporter

Report test results to BSP for IDE integration

Report test results to BSP for IDE integration

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * Converts a `Seq[T]` into a `Task[Seq[V]]` using the given `f: T => Task[V]`\n */")
def traverse[T, V](source: Seq[T])(f: T => Task[V]): Task[Seq[V]]

Converts a Seq[T] into a Task[Seq[V]] using the given f: T => Task[V]

Converts a Seq[T] into a Task[Seq[V]] using the given f: T => Task[V]

Attributes

Inherited from:
TaskBase
Source
Task.scala
@Scaladoc(value = "/**\n * This is the `os.Path` pointing to the project root directory.\n *\n * This is the preferred access to the project directory, and should\n * always be prefered over `os.pwd`* (which might also point to the\n * project directory in classic cli scenarios, but might not in other\n * use cases like BSP or LSP server usage).\n */")
def workspace(implicit ctx: Ctx): Path

This is the os.Path pointing to the project root directory.

This is the os.Path pointing to the project root directory.

This is the preferred access to the project directory, and should always be prefered over os.pwd* (which might also point to the project directory in classic cli scenarios, but might not in other use cases like BSP or LSP server usage).

Attributes

Inherited from:
TaskBase
Source
Task.scala