Search code examples
sbtsbt-plugin

Can an SBT plugin embed tasks from another plugin?


I've created a plugin that generates some web resources that need to be compiled using the sbt-webpack plugin. Ideally my plugin would just have a task bundle that will generate some resources and then it will bundle them with the webpack task from the sbt-webpack plugin.

What is the right way to incorporate tasks from different plugins into the code defining my tasks in my plugin?


Solution

  • Declaring a dependency on another plugin should be enough. You need to add this line to your auto-plugin:

    override def requires = stejskal.sbt.WebpackPlugin
    

    This will ensure that sbt-webpack is enabled whenever your plugins is and its settings will be loaded before the ones you define in your plugin. Plus whatever keys sbt-webpack adds to its autoImport object will be available to the users of your plugin as well.