Search code examples
scalasbtsbt-assemblysbt-plugin

How to add a plugin as a library to a plugin I made?


I have a plugin that I am building, I would like to be able to override the setting of an other plugin, let's say sbt-assembly.

I would like in my AutoPlugin be able to do:

import sbtassembly

[...]

override def projectSettings: Seq[Def.Setting[_]] = {
  Seq(
    assembly := { /* override the task */ }
  )
}

I have tried to add in ./build.sbt :

libraryDependencies += "com.eed3si9n" % "sbt-assembly" % "0.14.9"

But I get

(update) sbt.librarymanagement.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.14.9: not found

I tried to add it in ./project/plugins.sbt but if I understand correctly, that will add it as a build tool to build my plugin not as something accessible within the code of the plugin and it seems that I am right since I cannot access sbtassembly package.

Any tips ?

Thanks !


Solution

  • I found the solution !

    It is to add

    addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
    

    in build.sbt not in project/plugins.sbt.

    I guess sbt-assembly is not a library, it is a plugin. So to add a plugin, you need to use addSbtPlugin.

    And since you want it in the code, not in the compiler, you put it in build.sbt, not in project/plugins.sbt.