sbt:如何解决使用Maven属性的Maven依赖项 [英] sbt: How do I resolve Maven dependencies that uses Maven properties

查看:87
本文介绍了sbt:如何解决使用Maven属性的Maven依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

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}.

Note the ${jcuda.os} appearing in the error message.

推荐答案

作为解决方法,您可以设置自定义设置,并将Maven属性的值提供为JVM属性:

As a workaround you can set up a custom setting and provide the value for the Maven property as a JVM property:

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.

This splits out the missing Maven properties as sbt setting, and then translates them into sys.props at the load time of the build.

这篇关于sbt:如何解决使用Maven属性的Maven依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆