Mark Jayxcela
Mark Jayxcela

Reputation: 985

How to resolve a non-jar (dll/jnilib) library dependencies in sbt?

In a SBT build.sbt project file, is it possible to retrieve library dependencies which are not bundled as jar?

In my case, I am trying to use QTSampledSP which requires .dll and .jnilib libraries.

Upvotes: 6

Views: 1693

Answers (1)

jsuereth
jsuereth

Reputation: 5624

To download the artifact, you need to make Ivy (and hence sbt) explicitly aware of the DLL artifact. Add the following to build.sbt in your project.

lazy val QtSampledJniLibArt = Artifact("qtsampledsp-osx", "jnilib", "jnilib")

libraryDependencies += "com.tagtraum" % "qtsampledsp-osx" % "0.9.6" artifacts(QtSampledJniLibArt)

resolvers += "beatunes" at "http://www.beatunes.com/repo/maven2"

Then you need to tell sbt to pay attention to these artifacts (again build.sbt):

classpathTypes ++= Set("jnilib", "dll")

By default, sbt will only add a few types into the classpath (and jnilib and dll are not amongst them).

[sbt-0-13-1]> help classpathTypes
Artifact types that are included on the classpath.
[sbt-0-13-1]> show classpathTypes
[info] Set(eclipse-plugin, bundle, hk2-jar, orbit, jar)

Since these DLLs/jnilibs are needed on the classpath to run correctly, the above setting classpathTypes where you add the additional types will correct things as you can see below (don't forget to reload when in sbt console).

[sbt-0-13-1]> show classpathTypes
[info] Set(eclipse-plugin, bundle, hk2-jar, jnilib, orbit, jar, dll)

If you need to look in more detail at these files, check out the update report (from the update task) where you can inspect all configurations/modules/artifacts. Run show update in sbt console and look at the files in target/resolution-cache/reports.

Upvotes: 7

Related Questions