SBT:子项目中的 plugins.sbt 被忽略? [英] SBT: plugins.sbt in subproject is ignored?

查看:31
本文介绍了SBT:子项目中的 plugins.sbt 被忽略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多项目 SBT 版本.当我使用所需的 addSbtPlugin 声明将 plugin.sbt 添加到 subproject/project 中时,sbt 不会加载这些插件.是否打算将多项目中的所有插件都添加到 /project/plugins.sbt 而不是子项目中?理想情况下,我只想在特定子项目下有一些插件任务:subproject/somePluginTask.

I have a multiproject SBT build. When I add plugin.sbt into subproject/project with desired addSbtPlugin declarations, sbt does not load those plugins. Is it intended that all plugins in multi-project should be global - added to <root>/project/plugins.sbt rather than into subprojects? Ideally I'd like to have some plugin tasks under particular subproject only: subproject/somePluginTask.

我有 SBT 0.13.5

I have SBT 0.13.5

推荐答案

海龟一路下滑

入门指南中所述,sbt 中的构建是位于 project/ 目录中的构建.由于您有一个表示顶级多项目的构建,因此需要查看的唯一目录是 /project/.

Turtles all the way down

As noted in Getting Started Guide a build in sbt is a root project of a build located in project/ directory at the level. Since you have one build that's expressing the top-level multi project, the only directory that's looked into is <root>/project/.

在 sbt 0.13.5 之前,最佳实践指南 建议插件不要覆盖settings 并提供类似obfuscateSettings 的东西,以便您可以在项目级别选择加入插件.换句话说,插件是在构建级别添加的,但插件设置仅在您愿意时才加载到每个项目中.您使用的插件可能会也可能不会遵循本指南.

Prior to sbt 0.13.5, the best practice guide suggested that plugins do not override settings and provide something like obfuscateSettings so you can opt into the plugin at the project level. In other words, plugins are added at the build level, but the plugin settings are only loaded to each project if you wanted to. The plugins you're using may or may not be following this guide.

在 sbt 0.13.5 中引入的主要功能是 自动插件,这将使您不仅可以更轻松地在每个项目级别启用插件,而且还可以在自动加载插件时禁用它们.

The main feature that was introduced in sbt 0.13.5 is auto plugin, which should make it easier for you to not only enable plugins at each project level but also disable them if they were loaded automatically.

lazy val app = (project in file("app"))
  .enablePlugins(HelloPlugin)

这篇关于SBT:子项目中的 plugins.sbt 被忽略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆