Reputation: 703
I am building multiple Java projects with sbt 0.13. Project A publishes a library "abc" in $HOME/maven2.artifacts/www/x/y/abc/1.0.1/abc-1.0.1.jar with the default "sbt publish" task. It works, the library is there as expected.
Project B depends on this artifact. It declares a resolver (all code from build.sbt
):
resolvers ++= Seq(
"Developer's repo" at "file://"+Path.userHome.absolutePath+"/maven2.artifacts/www"
)
...and a value for the reference:
val abc_core = "x.y" % "abc" % "1.0.1"
Then, it uses the reference in a project definition:
lazy val def_symbol=project settings(
name:="def-symbol",
libraryDependencies += abc_core
)
This works. However, when I change the value definition to use a dynamic revision id as the sbt documentation suggests by setting it to
val abc_core = "x.y" % "abc" % "1.0.+"
or
val abc_core = "x.y" % "abc" % "1.+"
it does not work any more:
[warn] module not found: x.y#abc;1.+
[warn] ==== local: tried
[warn] /home/dh/.ivy2/local/x.y/abc/[revision]/ivys/ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/x/y/abc/[revision]/abc-[revision].pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: x.y#abc;1.+: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
I see that sbt seems not to have asked my file-based resolver for the dependency. Is that the problem? How can I solve it?
Upvotes: 0
Views: 518
Reputation: 703
Well,
problem solved. I had to declare the resolver extension in the global scope, so that the subprojects also use it:
resolvers in Global ++= Seq(
"Developer's repo" at "file://"+Path.userHome.absolutePath+"/maven2.artifacts/www"
)
Then project def_symbol
also uses "Developer's repo" and everything works exactly as expected with versions like "1.0.+"
or "1.+"
.
Not having the resolver in global scope available but having the library resolving working nevertheless was due to version 1.0.1 being available in Ivy's local cache from another build. From scratch, it would not have worked either.
Sorry for the noise. I should have waited one more day before posting.
Upvotes: 2