I have the following, minimal, custom sbt plugin, where I'd like to implement (override) the standard clean
command to do the same action as myTask
.
package nigeleke.sbt
import sbt.*
import Keys.*
import scala.sys.process.*
object MyPlugin extends AutoPlugin {
object autoImport {
val myTask = taskKey[Unit]("Do something.")
}
import autoImport._
override def requires = empty
override def trigger = noTrigger
override lazy val projectSettings = Seq(
myTask := {
println(s"project: ${thisProject.value.id} plugins: ${thisProject.value.plugins}")
},
clean := clean.dependsOn(myTask).value
)
}
When I enable this plugin a client project, the myTask
command works as expected. I would also like clean
to invoke the same task, but no output is forthcoming:
> sbt
[info] welcome to sbt 1.8.2 (Eclipse Adoptium Java 17.0.6)
[info] loading global plugins from ... \.sbt\1.0\plugins
[info] loading settings for project sbt-example-client-build from plugins.sbt ...
[info] loading project definition from ... \sbt-example-client\project
[info] loading settings for project root from build.sbt,version.sbt ...
[info] set current project to sbt-example-client (in build file:/ ... /sbt-example-client/)
[info] sbt server started at local:sbt-server-c377c6b81cca5b432adb
[info] started sbt server
sbt:sbt-example-client> myTask
project: client plugins: nigeleke.sbt.MyPlugin
[success] Total time: 0 s, completed 13 Apr 2023, 5:05:18 pm
sbt:sbt-example-client> clean
[success] Total time: 0 s, completed 13 Apr 2023, 5:05:21 pm
sbt:sbt-example-client>
I'm failing to find the correct syntax to invoke it, so any pointers are appreciated.