sbt - sbt 0.13.x 迁移到带有 shell 任务的 1.1.4
问题描述
我的任务是从 git 中为我的 Play Framework 应用程序获取前端:
lazy val frontend = taskKey[Unit]("Downloads frontend")
frontend := {
val s: TaskStreams = streams.value
val shell: Seq[String] = if (sys.props("os.name").contains("Windows")) Seq("cmd", "/c") else Seq("bash", "-c")
val downloadRepo: Seq[String] = shell :+ "git clone git@bitbucket.org:user/frontend.git"
val rmJs: Seq[String] = shell :+ "rm -rf frontend/dist/js && rm -rf public/design && mkdir public/design"
val copy: Seq[String] = shell :+ "mv frontend/dist/* public/design/"
val rmRepo: Seq[String] = shell :+ "rm -rf frontend"
s.log.info("Downloading frontend...")
if((downloadRepo #&& rmJs #&& copy #&& rmRepo !) == 0) {
s.log.success("frontend downloaded successful!")
} else {
throw new IllegalStateException("frontend failed!")
}
}
它适用于 sbt 0.13.x,但我想迁移到最新版本,它给了我一个错误:
error: value #&& is not a member of Seq[String]
if((downloadRepo #&& rmJs #&& copy #&& rmRepo !) == 0) {
我检查了新文档但没有找到答案,我该如何迁移它?
解决方案
我猜你的意思是#&&
操作员来自sys.process
:
#&&
如果前一个命令以退出值 0 结束,则有条件地执行第二个命令。它反映了 shell 的&&
.
sbt 0.13 有一个与 1.0 相似的 API,sys.process
并在 1.0 中sys.process
替换了它。因此,修复只是将其导入以将相关暗示添加到范围:
import scala.sys.process._
推荐阅读
- html - CSS 三角形背景
- cakephp - 在 CakePHP 3 和 belongsToMany 中删除重复的 find() 结果
- javascript - 哎呀。电子邮件地址格式错误 Firebase / Vue
- javascript - 如果两个数组匹配索引并且匹配名称,则仅将类应用于元素
- sql - SQL检查表是否存在并截断
- c# - 如何使用表达式树调用带有 EventHandler 参数的方法?
- javascript - Knockout 扩展器导致 observable 在第一次通过时返回其默认值,无论输入如何
- swift - Swift 中的存储属性覆盖 - 私有与非私有
- javascript - 如何将 ngx-loading-bar 作为预加载器添加到 Angular 项目中
- r - 基于文本和R中记录的值迭代地重命名列名