I'm building a Scala project with sbt and creating a fat jar with the sbt-assembly plugin. I'm able to add unmanaged jars (such as the Sigar jar) by adding the following to build.sbt
.
unmanagedJars in Compile +=
file("lib/hyperic-sigar-1.6.4/sigar-bin/lib/sigar.jar")
However, when I try running this, I get the following error because the *.so
libraries are not included in the jar.
no libsigar-amd64-linux.so in java.library.path
org.hyperic.sigar.SigarException: no libsigar-amd64-linux.so in java.library.path
at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:172)
at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100)
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.hyperic.sigar.ptql.SigarProcessQuery.create(Ljava/lang/String;)V
at org.hyperic.sigar.ptql.SigarProcessQuery.create(Native Method)
at org.hyperic.sigar.ptql.ProcessQueryFactory.getQuery(ProcessQueryFactory.java:66)
at org.hyperic.sigar.ptql.ProcessFinder.findSingleProcess(ProcessFinder.java:44)
The libraries I want to include are in lib/hyperic-sigar-1.6.4/sigar-bin/lib/*.so
and they need to be linked to a directory in the classpath within the jar. The only way I know of to do a mapping like this is:
resourceDirectory in Compile <<=
baseDirectory{ _ / "lib/hyperic-sigar-1.6.4/sigar-bin/lib" }
This causes the *.so
libraries to be added to root of the jar, but not a specific directory. How can I specify a resource map to map from lib/hyperic-sigar-1.6.4/sigar-bin/lib/*.so
to a directory in the classpath in my jar? What is the terminology for what I'm trying to do?
libraryDependencies += "org.fusesource" % "sigar" % "1.6.4"
inbuild.sbt
, and I'm still getting the same error. – Brandon Amos