简体   繁体   中英

How to include sigar native libraries in sbt-native-packager Akka build?

I'm just curious if there is some nice way to do that with Akka packaging.

I found some examples here , but it was created for rpm build and I'm using these two plugins in my build.sbt :

.enablePlugins(AkkaAppPackaging)
  .enablePlugins(UniversalPlugin)

Actually I figured out one workaround by copying sigar libraries manually to directory where application starter script is generated.

There is also a need to set -Djava.library.path=./sigar to appropriate directory where sigar libraries are located, this can be set in build.sbt or changed later manually in generated scripts, by changing the JAVA_OPTS .

Here is what I did

  lazy val sigarJavaOpts = "-Djava.library.path=./sigar"

  libraryDependencies ++= Dependencies.sigar

  mappings in Universal ++= MappingsHelper directory getClass.getClassLoader.getResource("sigar").getFile

  bashScriptExtraDefines += s"""addJava "$sigarJavaOpts" """

  javaOptions in run += sigarJavaOpts

Note that I placed sigar files in my resources folder. You might also need to import from the following

import com.typesafe.sbt.SbtNativePackager.Universal
import com.typesafe.sbt.packager.MappingsHelper
import com.typesafe.sbt.packager.Keys.bashScriptExtraDefines 

Also I do have a Dependencies object in which I have

  val sigar = Seq(
    "org.fusesource" % "sigar" % "1.6.4"
  )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM