1

I am writing an sbt-plugin to abstract away some boilerplate. Let's call it sbt-redux

then there is one more plugin sbt-assembly.

In this quest, my plugin(sbt-redux) needs to know about where the project ( Project which is using sbt-redux ) will create Uber jar using sbt-assembly and what will be the name of jar. I tried adding sbt-assembly in plugins of sbt-redux, but for the obvious reasons it will not add dependencies in my src folder as it has limitations only in build.sbt.

I tried using .dependsOn(assembly) but still no luck.

So, How can I use other plugins into src?

P.S. Please let me know if the question is not clear.

arglee
  • 1,374
  • 4
  • 17
  • 30
  • Hi, facing the same issue as you, but when I try your suggestion, the sbtassembly package is not recognized.:`not found: value sbtassembly override def requires = super.requires && sbtassembly.AssemblyPlugin` – JeanMarc Jan 01 '21 at 11:52
  • Found out what I did wrong, posted a clarification below as an addition to the original answer. The `addSbtPlugin` line needed to be put inside the `.settings()`. – JeanMarc Jan 05 '21 at 06:25

2 Answers2

0

There I found a solution and it is working for me. If you want to read assembly's settings, you have to make sure your plugins depend on it. In your build.sbt file, you can add:

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

And then in your AutoPlugin implementation, you should override requires this way:

override def requires = super.requires && sbtassembly.AssemblyPlugin

After that, you'll have access to assembly settings and tasks.

Thanks to gpoirier.

arglee
  • 1,374
  • 4
  • 17
  • 30
0

To expand on the correct answer from @arglee, when you have a multi-module project, the addSbtPlugin line needs to be part of the .settings entries for the module that needs the dependency, like:

lazy val mod = (project in file("mod"))
  .settings(
    ...,
    addSbtPlugin( ... ),
    libraryDependencies ++= Seq( ... ),
    ...
  )
JeanMarc
  • 306
  • 1
  • 10