从cli为子项目运行sb​​t发布任务并不起作用

时间:2017-10-13 12:56:51

标签: sbt sbt-release

我有一个多项目sbt,我使用sbt-release插件。如果我在子项目中运行 发布 ,一切正常

> project reporter
[info] Set current project to reporter (in build file:/source/storage-integ/)
> release
[info] Starting release process off commit: c069698baf8bb6fca611ab4e7e086398aab473c5
[info] Checking remote [origin] ...

但是当我运行" sbt reporter / release "时,这并不起作用。来自cli。其中" sbt reporter / compile "或" sbt记者/汇编 "做的。

$ sbt reporter/release
[warn] Executing in batch mode.
[warn]   For better performance, hit [ENTER] to switch to interactive mode, or
[warn]   consider launching sbt without any commands, or explicitly passing 'shell'
[info] Loading global plugins from /home/vagrant/.sbt/0.13/plugins
[info] Loading project definition from /source/storage-integ/project
[info] Set current project to root (in build file:/source/storage-integ/)
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: release (similar: releaseVcs, rpmRelease, rpm-release)
[error] reporter/release

这与另一个SO post非常相似。我尝试按照建议将releaseSettings添加到build.sbt,但它会抛出错误

build.sbt:62: error: not found: value releaseSettings

我尝试import sbtrelease.Release._但是抛出了

error: object Release is not a member of package sbtrelease

此时我觉得提到的解决方案不再有效。另外,我在sbt-release自述文件中没有看到releaseSettings的任何引用。知道如何让这个工作吗?

sbt.version = 0.13.15&& sbt-release:" 1.0.6"

1 个答案:

答案 0 :(得分:0)

发布设置应仅在您的root项目中。所以,为了得到这个:

首先,您的build.sbt可能是这样的

lazy val root: Project = project.in(file("."))
  .settings(Releases.settings: _*)
  .aggregate(module1, module2)

然后,您的project/Releases.scala喜欢:

object Releases {

 // You need to custom these to reflect your actual procedure
 private val releaseProcess = Def.setting {
   Seq[ReleaseStep](
    checkSnapshotDependencies,
    inquireVersions,          
    runClean,                 
    runTest,                  
    setReleaseVersion,        
    commitReleaseVersion,     
    tagRelease,               
    publishArtifacts,         
    setNextVersion,          
    commitNextVersion,       
    pushChanges          
   )
  }

  val settings = Seq(
    releaseCommitMessage := s"Set version to ${(version in ThisBuild).value}",
    releaseTagName := (version in ThisBuild).value,
    releaseProcess := releaseProcess.value
  )
}

默认情况下,您需要version.sbt当前版本。让我们说:

version in ThisBuild := "1.0.0-SNAPSHOT"

然后只是:

  

sbt release