object Target extends Applyer[Task, Task, Result, api.Ctx]

The mill.define.Target companion object, usually aliased as T, provides most of the helper methods and macros used to build task graphs. methods like T.apply, T.sources, T.command allow you to define the tasks, while methods like T.dest, T.log or T.env provide the core APIs that are provided to a task implementation

Source
Task.scala
Linear Supertypes
Applyer[Task, Task, Result, api.Ctx], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Target
  2. Applyer
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. macro def apply[T](t: Task[T])(implicit rw: upickle.default.ReadWriter[T], ctx: Ctx): Target[T]
  5. implicit macro def apply[T](t: Result[T])(implicit rw: upickle.default.ReadWriter[T], ctx: Ctx): Target[T]
  6. implicit macro def apply[T](t: T)(implicit rw: upickle.default.ReadWriter[T], ctx: Ctx): Target[T]

    A target is the most common Task a user would encounter, commonly defined using the def foo = T{...} syntax.

    A target is the most common Task a user would encounter, commonly defined using the def foo = T{...} syntax. TargetImpls require that their return type is JSON serializable. In return they automatically caches their return value to disk, only re-computing if upstream Tasks change

  7. def args(implicit ctx: api.Ctx.Args): IndexedSeq[_]

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

  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  10. macro def command[T](t: Result[T])(implicit w: upickle.default.Writer[T], ctx: Ctx, cls: EnclosingClass): Command[T]
  11. macro def command[T](t: Task[T])(implicit ctx: Ctx, w: upickle.default.Writer[T], cls: EnclosingClass): Command[T]

    Commands are only NamedTasks defined using def foo() = T.command{...} and are typically called from the command-line.

    Commands are only NamedTasks defined using def foo() = T.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.

  12. def ctx()(implicit c: api.Ctx): api.Ctx
    Definition Classes
    Applyer
  13. def dest(implicit ctx: Dest): Path

    T.dest is a unique os.Path (e.g.

    T.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.

  14. def env(implicit ctx: Env): Map[String, String]

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

    T.env is the environment variable map passed to the Mill command when it is run; typically used inside a T.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.

  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  17. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  18. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  20. def home(implicit ctx: Home): Path

    Returns the implicit mill.api.Ctx.Home.home in scope.

  21. macro def input[T](value: Result[T])(implicit w: upickle.default.Writer[T], ctx: Ctx): Target[T]

    InputImpls, normally defined using T.input, are NamedTasks that re-evaluate every time Mill is run.

    InputImpls, normally defined using T.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 T{...} TargetImpl will incorrectly cache them forever. Reading them inside a T.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.

  22. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  23. def log(implicit ctx: Log): Logger

    T.log is the default logger provided for every task.

    T.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.

  24. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  25. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  26. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  27. macro def persistent[T](t: Result[T])(implicit rw: upickle.default.ReadWriter[T], ctx: Ctx): Target[T]

    PersistentImpl are a flavor of TargetImpl, normally defined using the T.persistent{...} syntax.

    PersistentImpl are a flavor of TargetImpl, normally defined using the T.persistent{...} syntax. The main difference is that while TargetImpl deletes the T.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 T.persistent 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 T.dest. Violating that invariant can result in confusing mis-behaviors

  28. def reporter(implicit ctx: api.Ctx): (Int) => Option[CompileProblemReporter]

    Report build results to BSP for IDE integration

  29. def sequence[T](source: Seq[Task[T]]): Task[Seq[T]]

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

  30. macro def source(value: Result[api.PathRef])(implicit ctx: Ctx): Target[api.PathRef]
  31. macro def source(value: Result[Path])(implicit ctx: Ctx): Target[api.PathRef]

    Similar to Source, but only for a single source file or folder.

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

  32. macro def sources(values: Result[Seq[api.PathRef]])(implicit ctx: Ctx): Target[Seq[api.PathRef]]
  33. macro def sources(values: Result[Path]*)(implicit ctx: Ctx): Target[Seq[api.PathRef]]

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

    A specialization of InputImpl defined via T.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 T.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.

  34. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  35. macro def task[T](t: Result[T]): Task[T]

    Creates an anonymous Task.

    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 T{...} targets.

  36. def testReporter(implicit ctx: api.Ctx): TestReporter

    Report test results to BSP for IDE integration

  37. def toString(): String
    Definition Classes
    AnyRef → Any
  38. 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]

  39. def traverseCtx[I, R](xs: Seq[Task[I]])(f: (IndexedSeq[I], api.Ctx) => Result[R]): Task[R]

    A variant of traverse that also provides the mill.api.Ctx to the function f

    A variant of traverse that also provides the mill.api.Ctx to the function f

    Definition Classes
    TargetApplyer
  40. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  41. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  42. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  43. macro def worker[T](t: Result[T])(implicit ctx: Ctx): Worker[T]
  44. macro def worker[T](t: Task[T])(implicit ctx: Ctx): Worker[T]

    Worker is a NamedTask that lives entirely in-memory, defined using T.worker{...}.

    Worker is a NamedTask that lives entirely in-memory, defined using T.worker{...}. The value returned by T.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.

  45. def workspace(implicit ctx: api.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).

  46. object Internal

Inherited from Applyer[Task, Task, Result, api.Ctx]

Inherited from AnyRef

Inherited from Any

Ungrouped