Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT: plugins.sbt in subproject is ignored?

Tags:

scala

sbt

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

like image 552
dmitry Avatar asked Jun 09 '14 14:06

dmitry


People also ask

Where are sbt plugins stored?

Plugins can be installed for all your projects at once by declaring them in $HOME/. sbt/1.0/plugins/ . $HOME/. sbt/1.0/plugins/ is an sbt project whose classpath is exported to all sbt build definition projects.

What are sbt plugins?

A plugin can define a sequence of sbt settings that are automatically added to all projects or that are explicitly declared for selected projects. For example, a plugin might add a proguard task and associated (overridable) settings. Finally, a plugin can define new commands (via the commands setting).

Does Eclipse support sbt?

In a console, cd to the top-level folder of your existing sbt project, and enter sbt eclipse to generate the Eclipse project files for all projects in your build. Start Eclipse and switch to the Workspace you want to use for your Lagom project. From the File menu, select Import. The Select screen opens.

What is project in file in sbt?

A project is defined by declaring a lazy val of type Project. For example, : lazy val util = (project in file("util")) lazy val core = (project in file("core")) The name of the val is used as the subproject's ID, which is used to refer to the subproject at the sbt shell.


1 Answers

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)
like image 69
Eugene Yokota Avatar answered Oct 19 '22 16:10

Eugene Yokota