Reputation: 301
The requirement: an SBT plugin code is in an unmanaged jar, for example in lib/unmanaged-sbt-plugin-0.0.1.jar
.
I was expecting the jar file would be picked up by SBT automatically and the plugin would work out-of-the-box, i.e.: the tasks would be accessible from SBT command line, but that is not the case.
The jar file has the sbt/sbt.autoplugins
file in it and the plugin works if pulled from a remote repo into the local one and imported via addSbtPlugin(...)
. Please note I cannot do that - it's a requirement to get it to load from the lib/unmanaged-sbt-plugin-0.0.1.jar
and not from the local/remote repo.
Putting the following line in the build.sbt
doesn't make the plugin work (there's not error either):
unmanagedJars in Compile += file("lib/unmanaged-sbt-plugin-0.0.1.jar")
The implementation of addSbtPlugin(...)
is simply (according to http://www.scala-sbt.org/0.12.2/docs/Getting-Started/Using-Plugins.html):
def addSbtPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] =
libraryDependencies <+= (sbtBinaryVersion in update, scalaBinaryVersion in update)
{ (sbtV, scalaV) => sbtPluginExtra(dependency, sbtV, scalaV) }
I'm wondering if the above info can be used to resolve my issue?
Thank you in advance!
Upvotes: 7
Views: 2220
Reputation: 5017
Have been struggling to get this to work.
Could not get it to work with proposed solution using from "file://.."
(using sbt 1.0.4).
Got it to work by putting the plugin in project/lib
folder and adding all the plugin dependencies to plugins.sbt
using libraryDependencies ++= Seq(..)
like in build.sbt
. You can find the plugin dependencies by looking at the plugin pom file, usually in .ivy2/local/<org>/<pluginname>/poms
folder.
Upvotes: 2
Reputation: 67280
So you can specify an explicit URL for library dependencies (ModuleID
):
addSbtPlugin("org.my-org" % "unmanaged-sbt-plugin" % "0.0.1"
from "file:///./lib/unmanaged-sbt-plugin-0.0.1.jar")
Upvotes: 8