sbt - 在 0.13.x 中默认在子项目的上下文中执行“运行”
问题描述
我曾经能够在我的build.sbt
文件中使用以下内容来允许我run
在我的root
项目中执行命令,但运行命令只会在我的migrations
项目的上下文中运行:
lazy val root = project.dependsOn(rest,migrations).settings(publish := { }).disablePlugins(RevolverPlugin, AssemblyPlugin)
lazy val rest = project.enablePlugins(BuildInfoPlugin)
lazy val migrations = project.dependsOn(rest).settings(mainClass in (Compile, run) := Some("com.myapp.Migrations"), fork in run := true).disablePlugins(RevolverPlugin)
run in Compile <<= (run in Compile in migrations)
然后我会run
像这样执行:
> run up
(psup
是要传递给的参数com.myapp.Migrations
)
但是,当更新到 sbt v0.13.17 时,我现在收到警告:
See http://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html
run in Compile <<= (run in Compile in migrations)
在引用的 url 中,似乎表明我可以替换<<=
with :=
,但是如果我像这样更改它:
run in Compile := (run in Compile in migrations)
然后我输入run up
sbt,我得到错误:
[error] Expected ID character
[error] Not a valid command: run (similar: plugin, new)
[error] Expected project ID
[error] Expected configuration
[error] Expected ':' (if selecting a configuration)
[error] Expected key
[error] Expected '::'
[error] Expected end of input.
[error] run up
[error] ^
有谁知道我如何更新上述行以符合 0.13.x 并且仍然按预期工作?
解决方案
见https://www.scala-sbt.org/0.13/docs/Migrating-from-sbt-012x.html#Migrating+with
使用 InputKey 迁移
当使用 InputKey 而不是:
run <<= docsRunSetting
迁移时不能使用 .value 而是 .evaluated:
run := docsRunSetting.evaluated
在你的情况下尝试run in Compile := (run in Compile in migrations).evaluated
。
推荐阅读
- apache - 如何正确安装 SSL 到我的服务器?
- reactjs - props.history.push() 不重定向
- flask - 如何使用 SQLalchemy 和 Alembic 自动初始化数据库?
- php - 我所有表格行上的PHP“警告:非法字符串偏移”
- spring - 在使用 aws s3 sdk 依赖项时减少 Spring Boot 应用程序的构建大小
- regex - 使用正则表达式验证 Laravel 国家/地区代码
- gitlab - Gitlab CI执行错误但管道成功
- sails.js - 如何修复“使用 `sails-mongo` 时,主键必须有 `columnName: '_id'`”
- java - 如何制作 Java 代理/缓存文件系统 (VFS)
- android - 解决后无法更改配置“:testCompile”的策略