dmitry
dmitry

Reputation: 5039

SBT: plugins.sbt in subproject is ignored?

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.

I have SBT 0.13.5

Upvotes: 14

Views: 6836

Answers (1)

Eugene Yokota
Eugene Yokota

Reputation: 95624

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/.

classic plugins

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.

auto plugins

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)

Upvotes: 18

Related Questions