I want to have a command publish-snapshot
that would run the publish
task with modified version
setting (that setting is to be computed at the time of execution of the command).
I figured out how to get the current value of the version
inside command, and Project.runTask("task", "scope", ...)
seems to be a right call for invoking the publish
task.
The only thing that I'm confused with is how to modify the State
instance with a new version value. All my attempts seem to do nothing to the original version setting.
My last attempt:
val printVers = TaskKey[Unit]("printvers")
val printVersTask = TaskKey[Unit]("printvers") <<= {version map println}
def publishSnapshot = Command.command("publish-snapshot") { state =>
val newState = SessionSettings.reapply(state.get(sessionSettings).get.appendRaw(version := "???"), state)
Project.runTask(printVers in Compile, newState, true)
state
}
lazy val root = Project("main", file("."),
settings =
Defaults.defaultSettings ++
Seq(printVersTask)).settings(commands += publishSnapshot)
Is there some way to fix that behavior?