6

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.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Mark Jayxcela
  • 985
  • 1
  • 7
  • 17
  • 1
    see sample code at https://github.com/NetLogo/NetLogo/blob/master/project/NativeLibs.scala but it's a bit kludgy and the pathname manipulation parts are specific to our project. offering this hoping someone else will respond with something better. – Seth Tisue Dec 30 '13 at 18:49

1 Answers1

7

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.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
jsuereth
  • 5,604
  • 40
  • 40