例如:
lazy val someProject = project
.settings(
scalaVersion := "2.12.3",
libraryDependencies += "org.jcuda" % "jcuda" % "0.8.0"
)
以上不解决:
sbt:someProject> update
[info] Updating ...
[info] downloading https://repo1.maven.org/maven2/org/jcuda/jcuda/0.8.0/jcuda-0.8.0.jar ...
[warn] Detected merged artifact: [NOT FOUND ] org.jcuda#jcuda-natives;0.8.0!jcuda-natives.jar (16ms).
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/org/jcuda/jcuda-natives/0.8.0/jcuda-natives-0.8.0-${jcuda.os}-${jcuda.arch}.jar
[info] [SUCCESSFUL ] org.jcuda#jcuda;0.8.0!jcuda.jar (227ms)
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.jcuda#jcuda-natives;0.8.0!jcuda-natives.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
请注意错误消息中出现的${jcuda.os}
。
答案 0 :(得分:7)
作为一种变通方法,您可以设置自定义设置并将Maven属性的值作为JVM属性提供:
lazy val mavenProps = settingKey[Unit]("workaround for Maven properties")
lazy val jcudaOs = settingKey[String]("")
lazy val jcudaArch = settingKey[String]("")
lazy val someProject = project
.settings(
scalaVersion := "2.12.3",
libraryDependencies += "org.jcuda" % "jcuda" % "0.8.0",
jcudaOs := "linux",
jcudaArch := "x86_64",
mavenProps := {
sys.props("jcuda.os") = jcudaOs.value
sys.props("jcuda.arch") = jcudaArch.value
()
}
)
这会将缺少的Maven属性拆分为sbt设置,然后在构建的加载时将它们转换为sys.props
。