如何在定义依赖项时为 linux 和 osx 加载 ReactiveMongo?

How to load the ReactiveMongo for both linux and osx when defining the dependancies?

我正在尝试为 linux 和 osx 平台设置我的 RractiveMongo 依赖项。

我试过这个:

val mongoShadedNativeLinux = "org.reactivemongo"          % "reactivemongo-shaded-native"   % s"$reactivemongoVersion-linux-x86-64" classifier "linux-x86_64"
  val mongoShadedNative      = "org.reactivemongo"          % "reactivemongo-shaded-native"   % s"$reactivemongoVersion-osx-x86-64" classifier "natives-osx"

但是我得到一个错误:

https://repo1.maven.org/maven2/org/reactivemongo/reactivemongo-shaded-native/0.20.3-osx-x86-64/reactivemongo-shaded-native-0.20.3-osx-x86-64-natives-osx.jar: not found: https://repo1.maven.org/maven2/org/reactivemongo/reactivemongo-shaded-native/0.20.3-osx-x86-64/reactivemongo-shaded-native-0.20.3-osx-x86-64-natives-osx.jar

如何加载正确的库?我是否必须在 linux 服务器上构建项目以构建它以用于生产(使用 linux 用于生产,osx 用于开发)

demo application的构建中可以看到,可以根据OS自定义依赖。

libraryDependencies += {
  val os = sys.props.get("os.name") match {
    case Some(osx) if osx.toLowerCase.startsWith("mac") =>
      "osx"

    case _ =>
      "linux"
  }

  val (playVer, nativeVer) = reactiveMongoVer.split("-").toList match {
    case major :: Nil =>
      s"${major}-play27" -> s"${major}-${os}-x86-64"

    case vs @ _ => {
      val pv = ((vs.init :+ "play27") ++ vs.lastOption.toList)
      val nv = ((vs.init :+ os :+ "x86-64") ++ vs.lastOption.toList)

      pv.mkString("-") -> nv.mkString("-")
    }
  }

  "org.reactivemongo" % "reactivemongo-shaded-native" % nativeVer
}

您可以将 sys.props.get("os.name") 替换为 sys.env.get("FOO"),以在构建时使用环境变量定义目标 OS。