我试图为linux和osx平台设置reactivemongo依赖关系。
我试了一下。
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.orgmaven2orgreactivemongoreactivemongo-shaded-native0.20.3-osx-x86-64reactivemongo-shaded-native-0.20.3-osx-x86-64-natives-osx.jar。未找到。 https:/repo1.maven.orgmaven2orgreactivemongoreactivemongo-shaded-native0.20.3-osx-x86-64reactivemongo-shaded-native-0.20.3-osx-x86-64-natives-osx.jar。
我如何加载正确的库? 我是否必须在linux服务器上建立项目,以便为生产建立项目(使用linux做生产,osx做开发)。
正如你在构建的 演示应用你可以根据操作系统自定义依赖关系。
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")
,在构建时使用环境变量定义目标操作系统。