How to re-use an existing task in sbt but with different settings

Viewed 53

One of the use cases I have where I want to re-use an existing task is: Publishing a locally built docker image to a custom registry.

It would be nice if I can just re-use: Docker / publishLocal but with other setting values.

Initially I thought something like this is possible:

Docker / publishMyReg := {
  dockerAlias := dockerAlias.value.withRegistryHost(Option("myregistry.foo.bar"))
  (Docker / publishLocal).value
}

I was surprised to see that there is no way to run a Task with different setting values or to have Task specific settings.

Whats the intended way of introducing such custom tasks?

I was looking at Commmand but it doesnt seem to do the job here. For the use case above I would like to be able to execute the following: sbt my-project/docker:publishMyReg which, as far as I know, is not possible with a Command.

0 Answers
Related