@@ -124,7 +124,8 @@ object Task extends TaskBase {
124124 inline def Command [T ](inline t : Result [T ])(implicit
125125 inline w : Writer [T ],
126126 inline ctx : ModuleCtx
127- ): Command [T ] = $ { TaskMacros .commandImpl[T ](' t )(' w , ' ctx , exclusive = ' { false }) }
127+ ): Command [T ] =
128+ $ { TaskMacros .commandImpl[T ](' t )(' w , ' ctx , exclusive = ' { false }, persistent = ' { false }) }
128129
129130 /**
130131 * @param exclusive Exclusive commands run serially at the end of an evaluation,
@@ -133,16 +134,20 @@ object Task extends TaskBase {
133134 * These are normally used for "top level" commands which are
134135 * run directly to perform some action or display some output
135136 * to the user.
137+ * @param persistent If true the `Task.dest` directory is not cleaned between
138+ * runs.
136139 */
137140 def Command (
138141 t : NamedParameterOnlyDummy = new NamedParameterOnlyDummy ,
139- exclusive : Boolean = false
140- ): CommandFactory = new CommandFactory (exclusive)
141- class CommandFactory private [mill] (val exclusive : Boolean ) {
142+ exclusive : Boolean = false ,
143+ persistent : Boolean = false
144+ ): CommandFactory = new CommandFactory (exclusive = exclusive, persistent = persistent)
145+ class CommandFactory private [mill] (val exclusive : Boolean , val persistent : Boolean ) {
142146 inline def apply [T ](inline t : Result [T ])(implicit
143147 inline w : Writer [T ],
144148 inline ctx : ModuleCtx
145- ): Command [T ] = $ { TaskMacros .commandImpl[T ](' t )(' w , ' ctx , ' { this .exclusive }) }
149+ ): Command [T ] =
150+ $ { TaskMacros .commandImpl[T ](' t )(' w , ' ctx , ' { this .exclusive }, ' { this .persistent }) }
146151 }
147152
148153 /**
@@ -400,7 +405,8 @@ class Command[+T](
400405 val ctx0 : mill.define.ModuleCtx ,
401406 val writer : Writer [? ],
402407 val isPrivate : Option [Boolean ],
403- val exclusive : Boolean
408+ val exclusive : Boolean ,
409+ override val persistent : Boolean
404410) extends NamedTask [T ] {
405411
406412 override def asCommand : Some [Command [T ]] = Some (this )
@@ -555,12 +561,21 @@ private object TaskMacros {
555561 )(t : Expr [Result [T ]])(
556562 w : Expr [Writer [T ]],
557563 ctx : Expr [mill.define.ModuleCtx ],
558- exclusive : Expr [Boolean ]
564+ exclusive : Expr [Boolean ],
565+ persistent : Expr [Boolean ]
559566 ): Expr [Command [T ]] = {
560567 appImpl[Command , T ](
561568 (in, ev) =>
562569 ' {
563- new Command [T ]($in, $ev, $ctx, $w, $ { taskIsPrivate() }, exclusive = $exclusive)
570+ new Command [T ](
571+ $in,
572+ $ev,
573+ $ctx,
574+ $w,
575+ $ { taskIsPrivate() },
576+ exclusive = $exclusive,
577+ persistent = $persistent
578+ )
564579 },
565580 t
566581 )
0 commit comments