我试图在脚本中使用sbt 0.12在现有的sbt项目中设置一个里程碑。
在Apache Maven中,我使用mvn versions:set Version=foo
方法使用versions-maven-plugin创建符合semver的版本。
我很欣赏一些指导?
答案 0 :(得分:1)
使用sbt-release。
的follows the semantic versioning scheme on semver.org插件鉴于the comment您已经询问类似于&#34; mvn版本的内容:set Version = foo&#34;函数我可以从脚本调用。它应该可以轻松使用 no 附加插件 - 它是sbt - settings的内置功能。</ p>
show
显示指定设置的值。在您的情况下,它是version
。
➜ sbt-learning-space sbt "show version"
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/sbt-learning-space/project
[info] Set current project to hello (in build file:/Users/jacek/sandbox/sbt-learning-space/)
[info] 0.1-SNAPSHOT
构建中的当前版本为0.1-SNAPSHOT
。我们将1.0.0
更改为set
,并将给定的设置应用于当前项目。
➜ sbt-learning-space sbt 'set version := "1.0.0"'
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/sbt-learning-space/project
[info] Set current project to hello (in build file:/Users/jacek/sandbox/sbt-learning-space/)
[info] Defining *:version
[info] The new value will be used by *:isSnapshot, *:projectId and 3 others.
[info] Run `last` for details.
[info] Reapplying settings...
[info] Set current project to hello (in build file:/Users/jacek/sandbox/sbt-learning-space/)
它不会自动保留设置。
➜ sbt-learning-space sbt "show version"
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/sbt-learning-space/project
[info] Set current project to hello (in build file:/Users/jacek/sandbox/sbt-learning-space/)
[info] 0.1-SNAPSHOT
您应该运行session save
或session save-all
,通过将会话设置写入.sbt
配置文件来永久保持会话设置。
➜ sbt-learning-space sbt 'set version := "1.0.0"' 'session save'
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/sbt-learning-space/project
[info] Set current project to hello (in build file:/Users/jacek/sandbox/sbt-learning-space/)
[info] Defining *:version
[info] The new value will be used by *:isSnapshot, *:projectId and 3 others.
[info] Run `last` for details.
[info] Reapplying settings...
[info] Set current project to hello (in build file:/Users/jacek/sandbox/sbt-learning-space/)
[info] Reapplying settings...
[info] Set current project to hello (in build file:/Users/jacek/sandbox/sbt-learning-space/)
session save
version
的值已持久保存到build.sbt
个文件。
➜ sbt-learning-space sbt "show version"
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/sbt-learning-space/project
[info] Set current project to hello (in build file:/Users/jacek/sandbox/sbt-learning-space/)
[info] 1.0.0