Why sbt.Extracted remove the previously defined TaskKey while append method?

后端 未结 1 1545
遥遥无期
遥遥无期 2021-01-21 00:31

There is a suitable method in the sbt.Exctracted to add the TaskKey to the current state. Assume I have inState: State:

val key1 = TaskKey[String](\         


        
1条回答
  •  失恋的感觉
    2021-01-21 00:52

    Josh Suereth posted the answer to sbt-dev mail list. Quote:

    The append function is pretty dirty/low-level. This is probably a bug in its implementation (or the lack of documentation), but it blows away any other appended setting when used.

    What you want to do, (I think) is append into the current "Session" so things will stick around and the user can remove what you've done via "sesison clear" command.

    Additonally, the settings you're passing are in "raw" or "fully qualified" form. If you'd for the setting you write to work exactly the same as it would from a build.sbt file, you need to transform it first, so the Scopes match the current project, etc.

    We provide a utility in sbt-server that makes it a bit easier to append settings into the current session:

    https://github.com/sbt/sbt-remote-control/blob/master/server/src/main/scala/sbt/server/SettingUtil.scala#L11-L29

    I have tested the proposed solution and that works like a charm.

    0 讨论(0)
提交回复
热议问题