在没有插件的情况下从命令行运行SBT任务.sbt
如何从plugins.sbt
中未定义的插件中运行 sbt 使用任务构建?
在Maven中,这很容易: mvn groupID:artifactID:1.2.3:目标
eg mvn org.owasp:depentency-check-maven:7.1.1:
在SBT中检查我得到:
$ sbt net.vonbuchholtz:sbt-dependency-check:4.1.0:check
...
[error] Expected ID character
[error] Not a valid command: net (similar: set, new, inspect)
[error] Expected project ID
[error] Expected configuration
[error] Expected ':'
[error] Expected key
[error] Not a valid key: net (similar: test, name, run)
[error] net.vonbuchholtz:sbt-dependency-check:4.1.0:check
[error] ^
How to run an sbt build with task from a plugin that is not defined in plugins.sbt
?
In maven it's as easy as:mvn groupId:artifactId:1.2.3:goal
e.g. mvn org.owasp:dependency-check-maven:7.1.1:check
In sbt I get:
$ sbt net.vonbuchholtz:sbt-dependency-check:4.1.0:check
...
[error] Expected ID character
[error] Not a valid command: net (similar: set, new, inspect)
[error] Expected project ID
[error] Expected configuration
[error] Expected ':'
[error] Expected key
[error] Not a valid key: net (similar: test, name, run)
[error] net.vonbuchholtz:sbt-dependency-check:4.1.0:check
[error] ^
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将插件添加到SBT中才能调用它。
如果您不想将其添加到项目中,则可以在全球上添加它:
或者,您可以在
.gitignore
中定义一些全球忽略的文件(假设您正在使用git,并且不想偶然地提交东西)。然后,您可以添加所有想要的东西,例如local.sbt - 您将能够向您的回购添加一些临时更改,而不必担心它们会在上游。
还有另一个选项,您可以将这些插件配置放入某些文件中,例如
〜/.extra_plugins.sbt
,并用命令行添加它们:据我所知,我不能在您当您时跳过步骤创建
.sbt
文件。充其量您可以自动生成它并用脚本填充它:You have to have plugin added to sbt to be able to call it.
If you don't want to add it to the project you can add it globally:
Alternatively, you can define some globally ignored file in
.gitignore
(assuming you are using git and don't want to accidentally commit things).Then you can add all you want there e.g.
local.sbt
- you will be able to add some ad hoc changes to you repo and don't worry that they will be commited upstream.As yet another option, you can put these plugin configs into some file e.g.
~/.extra_plugins.sbt
and add them with a command line:As far as I can tell you cannot skip the step when you are creating the
.sbt
file. At best you could auto-generate it and populate it with a script: