com-lihaoyi / mill

Mill is a fast JVM build tool that supports Java and Scala. 2-3x faster than Gradle and 5-10x faster than Maven for common workflows, Mill aims to make your project’s build process performant, maintainable, and flexible
https://mill-build.org/
MIT License
2.04k stars 331 forks source link

Deprecated `T.command(task)` for removal in Mill 0.13 #3524

Closed lefou closed 3 weeks ago

lefou commented 3 weeks ago

T.command currently has two overloads, one accepting a Result (like most of the other task factories, T, T.input, T.task and so on) and one accepting a Task. Because of the second version, command definitions like the following don't do what the user thinks they do, although they seem to work.

override def publishLocal(localIvyRepo: String): Command[Unit] = T.command {
  super.publishLocal(localIvyRepo)
}

Instead of creating a new command that depends on another command (the super-version) and returns just the result, it returns the super-command as-is.

The correct version is:

override def publishLocal(localIvyRepo: String): Command[Unit] = T.command {
  super.publishLocal(localIvyRepo)()
}
 override def publishLocal(localIvyRepo: String): Command[Unit] = T.command {
-  super.publishLocal(localIvyRepo)
+  super.publishLocal(localIvyRepo)()
 }

This change deprecates all overloads accepting a Task in favor of accepting a Result. Results can be easily acquired from a Task by calling apply() or short ().

This is also the more correct way of re-using or re-defining tasks, since directly re-used tasks may result in an incorrect tasks context, esp. an incorrect source location, which is relevant when debugging misbehaving builds.

See https://github.com/com-lihaoyi/mill/issues/3517