Scala 在sbt上测试未正确读取java.library.path

Scala 在sbt上测试未正确读取java.library.path,scala,testing,sbt,Scala,Testing,Sbt,首先,我将列出我正在使用的所有内容的版本 sbt = 0.13.5 scala = 2.11.1 scalatest = 2.2.0 我的文件中有一个JVM选项区域,在这里我放置了很多JVM的配置 lazy val jvmOptions = Seq( "-server", "-Djava.rmi.server.hostname=" + java.net.InetAddress.getLocalHost.getHostName, "-Dhttps.port=9001", "-Xm

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

sbt = 0.13.5
scala = 2.11.1
scalatest = 2.2.0
我的文件中有一个JVM选项区域,在这里我放置了很多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。我尝试使用的第三方库位于系统的java.library.path的.sbtopts文件中

-Djava.library.path=/usr/lib/teigha
这就是我的.sbtopts中的全部内容。考虑到所有设置,我得到了一个不满意的链接错误

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的新版本正在做一些我不理解的事情。

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

javaOptions in test ++= jvmOptions
应该是

javaOptions in Test ++= jvmOptions

注意大写字母
T

谢谢。没有注意到它需要资本化。