I have a library that I'm building via SBT 0.7.4, against Scala 2.8.0.RC3.
It gets published here:
The associated POM file lists the following repositories:
<repositories>
<repository>
<id>trepo</id>
<name>t_repo</name>
<url>http://tristanhunt.com:8081/content/groups/public/</url>
</repository>
<repository>
<id>ScalaToolsRepository</id>
<name>Scala Tools Repository</name>
<url>http://scala-tools.org/repo-snapshots/</url>
</repository>
<repository>
<id>ScalaToolsMaven2Repository</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases/</url>
</repository>
</repositories>
Those repositories are be sufficient for the artifacts on which the
library depends. Those are:
val jline = "jline" % "jline" % "0.9.94"
val scalatest = "org.scalatest" % "scalatest" %
"1.2-for-scala-2.8.0.RC3-SNAPSHOT"
val wikitext = "org.eclipse.mylyn.wikitext" % "wikitext.textile" %
"0.9.4.I20090220-1600-e3x"
val knockoff = "com.tristanhunt" % "knockoff_2.8.0.RC3" % "0.7.1-12"
Next, I created a test project with the following build file:
import sbt._
class TestProject(info: ProjectInfo) extends DefaultProject(info)
{
val repo = "clapper.org Maven Repository" at "http://maven.clapper.org"
val grizzled = "org.clapper" %% "grizzled-scala" % "0.7.1"
}
The build Scala version is 2.8.0.RC3, and I'm using SBT 0.7.4.
When I run "sbt update", it cannot find two of the artifacts (knockoff and
scalatest). If I'm reading the errors correctly, it isn't even searching
all the repos. I've attached the (long) output.
What am I missing here? It's bound to be something simple and stupid...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scalatest#scalatest;1.2-for-scala-2.8.0.RC3-SNAPSHOT: not found
[warn] :: com.tristanhunt#knockoff_2.8.0.RC3;0.7.1-12: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[info]
[warn] :: problems summary ::
[warn] :::: WARNINGS
[warn] module not found:
org.scalatest#scalatest;1.2-for-scala-2.8.0.RC3-SNAPSHOT
[warn] ==== local: tried
[warn]
/Users/bmc/.ivy2/local/org.scalatest/scalatest/1.2-for-scala-2.8.0.RC3-SNAPSHOT/ivys/ivy.xml
[warn] -- artifact
org.scalatest#scalatest;1.2-for-scala-2.8.0.RC3-SNAPSHOT!scalatest.jar:
[warn]
/Users/bmc/.ivy2/local/org.scalatest/scalatest/1.2-for-scala-2.8.0.RC3-SNAPSHOT/jars/scalatest.jar
[warn] ==== clapper.org Maven Repository: tried
[warn]
http://maven.clapper.org/org/scalatest/scalatest/1.2-for-scala-2.8.0.RC3-SNAPSHOT/scalatest-1.2-for-scala-2.8.0.RC3-SNAPSHOT.pom
[warn] -- artifact
org.scalatest#scalatest;1.2-for-scala-2.8.0.RC3-SNAPSHOT!scalatest.jar:
[warn]
http://maven.clapper.org/org/scalatest/scalatest/1.2-for-scala-2.8.0.RC3-SNAPSHOT/scalatest-1.2-for-scala-2.8.0.RC3-SNAPSHOT.jar
[warn] ==== public: tried
[warn]
http://repo1.maven.org/maven2/org/scalatest/scalatest/1.2-for-scala-2.8.0.RC3-SNAPSHOT/scalatest-1.2-for-scala-2.8.0.RC3-SNAPSHOT.pom
[warn] -- artifact
org.scalatest#scalatest;1.2-for-scala-2.8.0.RC3-SNAPSHOT!scalatest.jar:
[warn]
http://repo1.maven.org/maven2/org/scalatest/scalatest/1.2-for-scala-2.8.0.RC3-SNAPSHOT/scalatest-1.2-for-scala-2.8.0.RC3-SNAPSHOT.jar
[warn] ==== Scala-Tools Maven2 Repository: tried
[warn]
http://scala-tools.org/repo-releases/org/scalatest/scalatest/1.2-for-scala-2.8.0.RC3-SNAPSHOT/scalatest-1.2-for-scala-2.8.0.RC3-SNAPSHOT.pom
[warn] -- artifact
org.scalatest#scalatest;1.2-for-scala-2.8.0.RC3-SNAPSHOT!scalatest.jar:
[warn]
http://scala-tools.org/repo-releases/org/scalatest/scalatest/1.2-for-scala-2.8.0.RC3-SNAPSHOT/scalatest-1.2-for-scala-2.8.0.RC3-SNAPSHOT.jar
[warn] module not found: com.tristanhunt#knockoff_2.8.0.RC3;0.7.1-12
[warn] ==== local: tried
[warn]
/Users/bmc/.ivy2/local/com.tristanhunt/knockoff_2.8.0.RC3/0.7.1-12/ivys/ivy.xml
[warn] -- artifact
com.tristanhunt#knockoff_2.8.0.RC3;0.7.1-12!knockoff_2.8.0.RC3.jar:
[warn]
/Users/bmc/.ivy2/local/com.tristanhunt/knockoff_2.8.0.RC3/0.7.1-12/jars/knockoff_2.8.0.RC3.jar
[warn] ==== clapper.org Maven Repository: tried
[warn]
http://maven.clapper.org/com/tristanhunt/knockoff_2.8.0.RC3/0.7.1-12/knockoff_2.8.0.RC3-0.7.1-12.pom
[warn] -- artifact
com.tristanhunt#knockoff_2.8.0.RC3;0.7.1-12!knockoff_2.8.0.RC3.jar:
[warn]
http://maven.clapper.org/com/tristanhunt/knockoff_2.8.0.RC3/0.7.1-12/knockoff_2.8.0.RC3-0.7.1-12.jar
[warn] ==== public: tried
[warn]
http://repo1.maven.org/maven2/com/tristanhunt/knockoff_2.8.0.RC3/0.7.1-12/knockoff_2.8.0.RC3-0.7.1-12.pom
[warn] -- artifact
com.tristanhunt#knockoff_2.8.0.RC3;0.7.1-12!knockoff_2.8.0.RC3.jar:
[warn]
http://repo1.maven.org/maven2/com/tristanhunt/knockoff_2.8.0.RC3/0.7.1-12/knockoff_2.8.0.RC3-0.7.1-12.jar
[warn] ==== Scala-Tools Maven2 Repository: tried
[warn]
http://scala-tools.org/repo-releases/com/tristanhunt/knockoff_2.8.0.RC3/0.7.1-12/knockoff_2.8.0.RC3-0.7.1-12.pom
[warn] -- artifact
com.tristanhunt#knockoff_2.8.0.RC3;0.7.1-12!knockoff_2.8.0.RC3.jar:
[warn]
http://scala-tools.org/repo-releases/com/tristanhunt/knockoff_2.8.0.RC3/0.7.1-12/knockoff_2.8.0.RC3-0.7.1-12.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scalatest#scalatest;1.2-for-scala-2.8.0.RC3-SNAPSHOT:
not found
[warn] :: com.tristanhunt#knockoff_2.8.0.RC3;0.7.1-12: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[info]
[info] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
[error] sbt.ResolveException: unresolved dependency:
org.scalatest#scalatest;1.2-for-scala-2.8.0.RC3-SNAPSHOT: not found
[error] unresolved dependency: com.tristanhunt#knockoff_2.8.0.RC3;0.7.1-12: not
found
[info] == update ==
[error] Error running update: sbt.ResolveException: unresolved dependency:
org.scalatest#scalatest;1.2-for-scala-2.8.0.RC3-SNAPSHOT: not found
[error] unresolved dependency: com.tristanhunt#knockoff_2.8.0.RC3;0.7.1-12: not
found
[info]
[info] Total time: 12 s, completed Jun 4, 2010 6:06:08 PM
--
-Brian
Brian Clapper, b...@clapper.org
Repositories are added to the pom for maven compatibility. Ivy does not use repositories from poms. You must declare the repositories for all of your dependencies.
-Mark
>> When I run "sbt update", it cannot find two of the artifacts (knockoff and
>> scalatest). If I'm reading the errors correctly, it isn't even searching
>> all the repos. I've attached the (long) output.
>>
>> What am I missing here? It's bound to be something simple and stupid...
>
> Repositories are added to the pom for maven compatibility. Ivy does not
> use repositories from poms. You must declare the repositories for all of
> your dependencies.
If I may rephrase your statement, to be sure I understand it, if I publish
my library to a Maven repository, and my library has other dependencies,
someone else who uses SBT to refer to my library STILL has to specify all
the dependencies my library requires; SBT won't figure them out from the
POM.
Is that correct?
If so, is there any way to publish the library so that SBT users *don't*
have to specify all its dependencies manually?
If this is answered in the wiki, I apologize for missing it.
--
-Brian
Brian Clapper, http://www.clapper.org/bmc/
Heller's Law: The first myth of management is that it exists.
Johnson's Corollary: Nobody really knows what is going on anywhere within the
organization.
Yes.
> If so, is there any way to publish the library so that SBT users *don't*
> have to specify all its dependencies manually?
Not that I know of. I think it is a fundamental design decision in Ivy. I could be wrong, though.
> If this is answered in the wiki, I apologize for missing it.
No problem. It is here:
http://code.google.com/p/simple-build-tool/wiki/LibraryManagement#Maven/Ivy
-Mark
>> If this is answered in the wiki, I apologize for missing it.
>
> No problem. It is here:
> http://code.google.com/p/simple-build-tool/wiki/LibraryManagement#Maven/Ivy
Thanks, Mark.
That's a shame, actually.
Hmm. I wonder... Perhaps it'd be possible to write an SBT plugin that parses a
POM file, extracts the repositories in it, and adds them to the list of
dependencies. With Scala's support for XML, the parsing should be trivial
enough. Do any gotchas leap to mind with such an approach?
--
-Brian
Brian Clapper, http://www.clapper.org/bmc/
Use library functions.
I think it is straightforward enough to pull out the repositories from a particular pom, but I don't see how that helps. You'd have to add the support to Ivy to do this as it resolves dependencies.
-Mark
> I think it is straightforward enough to pull out the repositories from a particular pom, but I don't see how that helps. You'd have to add the support to Ivy to do this as it resolves dependencies.
If I can specify them manually in my project file, isn't there a way I could
add them to the project programmatically? If so, might there be a way to hook
into the dependency handling, so I could intercept the Maven artifacts, parse
the POM, and add the repos to the project, all BEFORE Ivy processes the
dependencies? Or are there too many chicken-and-egg issues?
--
-Brian
Brian Clapper, http://www.clapper.org/bmc/
The meek are contesting the will.
Let's say you declare a dependency A from repository RA and it depends on a dependency B from repository RB. You only declare repository RA. You run 'update'. sbt calls Ivy and Ivy starts doing its thing.
Ivy resolves the metadata for A from RA. It sees A depends on B and proceeds to fetch the metadata for B. You'd need to extract the repositories from A at this point and add them. Ivy will then try to resolve R, but since it doesn't know about RB, it will fail. This is all done in Ivy and you'd have to use whatever hooks Ivy provides. I don't know if it is possible.
-Mark
> Ivy resolves the metadata for A from RA. It sees A depends on B and proceeds to fetch the metadata for B. You'd need to extract the repositories from A at this point and add them. Ivy will then try to resolve R, but since it doesn't know about RB, it will fail. This is all done in Ivy and you'd have to use whatever hooks Ivy provides. I don't know if it is possible.
Fair enough. I was just spitballing. Thanks.
--
-Brian
Brian Clapper, http://www.clapper.org/bmc/
Without ice cream life and fame are meaningless.