测试sbt没有正确读取java.library.path

时间:2014-07-03 19:57:36

标签: scala testing sbt

首先,我将列出我正在使用的所有版本。

sbt = 0.13.5
scala = 2.11.1
scalatest = 2.2.0

我的文件中有一个jvmOptions区域,我在那里放了很多JVM的配置。

lazy val jvmOptions = Seq(
  "-server",
  "-Djava.rmi.server.hostname=" + java.net.InetAddress.getLocalHost.getHostName,
  "-Dhttps.port=9001",
  "-Xms256M",
  "-Xmx2G",
  "-XX:NewRatio=1",
  "-Xss1M",
  "-XX:ReservedCodeCacheSize=128M",
  "-XX:MaxPermSize=256M",
  "-XX:+DisableExplicitGC",
  "-XX:+UseConcMarkSweepGC",
  "-XX:+UseParNewGC",
  "-XX:+CMSConcurrentMTEnabled",
  "-XX:+CMSIncrementalMode",
  "-XX:+CMSIncrementalPacing",
  "-XX:CMSIncrementalDutyCycleMin=0",
  "-XX:CMSIncrementalDutyCycle=10",
  "-XX:+CMSClassUnloadingEnabled",
  "-Dcom.sun.management.jmxremote.port=9999",
  "-Dcom.sun.management.jmxremote.authenticate=false",
  "-Dcom.sun.management.jmxremote.ssl=false",
  "-Dlogger.resource=custom-logger-settings.xml",
  "-Djava.library.path=" + System.getProperty("java.library.path")
)

这为commonSettings区域提供了正确的运行和测试分析。

lazy val commonSettings = {
  Project.defaultSettings ++
  ScctPlugin.instrumentSettings ++
  net.virtualvoid.sbt.graph.Plugin.graphSettings ++
  scalariformSettings ++
  customFormatSettings ++
  unidocSettings ++
  Seq(

    version := PROJECT_VERSION,
    organization := "com.gensler",
    scalaVersion := SCALA_VERSION,

    scalacOptions in Compile ++= Seq(
      "-unchecked",
      "-deprecation",
      "-feature"
    ),

    parallelExecution in Test := true,
    fork in Test := true,
    fork in test := true,
    fork in testOnly := true,

    javaOptions in run ++= jvmOptions,
    javaOptions in test ++= jvmOptions,
    javaOptions in testOnly ++= jvmOptions,

    libraryDependencies ++= Seq(
      "org.scalatest" %% "scalatest" % SCALATEST_VERSION % "test" // test framework
    )
  )
}

我遇到的问题是java.library.path。我有一个第三方库,我正在尝试使用它在我的系统的.sbtopts文件中的java.library.path。

-Djava.library.path=/usr/lib/teigha

这就是我的.sbtopts中的所有内容。鉴于所有设置,我收到UnsatisfiedLinkError错误。

14:16:49.619 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices - Exception thrown while attempting to load Teigha libraries: java.lang.UnsatisfiedLinkError: no TeighaJavaDwg in java.library.path
14:16:49.632 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices - Value of LD_LIBRARY_PATH: /home/joshadmin/Workspace/avro-nodejs/avrocpp/lib/
14:16:49.632 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices - Value of java.library.path:
14:16:49.633 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices -      /home/joshadmin/Workspace/avro-nodejs/avrocpp/lib/
14:16:49.633 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices -      /usr/java/packages/lib/amd64
14:16:49.634 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices -      /usr/lib/x86_64-linux-gnu/jni
14:16:49.634 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices -      /lib/x86_64-linux-gnu
14:16:49.635 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices -      /usr/lib/x86_64-linux-gnu
14:16:49.635 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices -      /usr/lib/jni
14:16:49.636 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices -      /lib
14:16:49.636 [pool-1-thread-1] ERROR c.g.t.t.custom.CustomSystemServices -      /usr/lib

我不知道这是不是因为我没有正确设置,或者SBT和Scalatest的新版本正在做我不理解的事情。

1 个答案:

答案 0 :(得分:2)

您应该在javaOptions配置中设置Test而不是test任务。

javaOptions in test ++= jvmOptions

应该是

javaOptions in Test ++= jvmOptions

注意资金T