For example:
lazy val someProject = project
.settings(
scalaVersion := "2.12.3",
libraryDependencies += "org.jcuda" % "jcuda" % "0.8.0"
)
The above does not resolve:
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] ::::::::::::::::::::::::::::::::::::::::::::::
Note the ${jcuda.os}
appearing in the error message.
I recently surveyed the current state of these three tools and concluded that SBT is better suited than Maven to Scala projects' needs.
Apache Ivy is a transitive package manager. It is a sub-project of the Apache Ant project, with which Ivy works to resolve project dependencies. An external XML file defines project dependencies and lists the resources necessary to build a project.
Transitive Dependencies. Maven avoids the need to discover and specify the libraries that your own dependencies require by including transitive dependencies automatically. This feature is facilitated by reading the project files of your dependencies from the remote repositories specified.
It's like you said; dependencyManagement is used to pull all the dependency information into a common POM file, simplifying the references in the child POM file. It becomes useful when you have multiple attributes that you don't want to retype in under multiple children projects.
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
()
}
)
This splits out the missing Maven properties as sbt setting, and then translates them into sys.props
at the load time of the build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With