为什么SBT无法解决我的依赖?

时间:2014-02-26 00:47:05

标签: maven sbt ivy

我需要使用JMS 1.1,由于某种原因,Maven Central已经删除了jar。

我将JBoss存储库添加到我的存储库列表中:

resolvers += "JBoss" at "https://repository.jboss.org/nexus/content/groups/public"

,但是当我尝试使用0.13.1进行构建时,我收到以下错误:

25-Feb-2014 19:22:41    [warn]         [NOT FOUND  ] javax.jms#jms;1.1!jms.jar (0ms)
25-Feb-2014 19:22:41    [warn] ==== public: tried
25-Feb-2014 19:22:41    [warn]   http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar
25-Feb-2014 19:22:41    [warn]         ::::::::::::::::::::::::::::::::::::::::::::::
25-Feb-2014 19:22:41    [warn]         ::              FAILED DOWNLOADS            ::
25-Feb-2014 19:22:41    [warn]         :: ^ see resolution messages for details  ^ ::
25-Feb-2014 19:22:41    [warn]         ::::::::::::::::::::::::::::::::::::::::::::::
25-Feb-2014 19:22:41    [warn]         :: javax.jms#jms;1.1!jms.jar
25-Feb-2014 19:22:41    [warn]         ::::::::::::::::::::::::::::::::::::::::::::::
25-Feb-2014 19:22:41    [info] Wrote /appdata/liquidnet/data/BambooAgent/build-dir/TICKDB-SP-JOB1/src/target/scala-2.10/pretrade-scala_2.10-1.0.pom
25-Feb-2014 19:22:41    sbt.ResolveException: download failed: javax.jms#jms;1.1!jms.jar

我看到有关设置externalResolvers的内容,因此它不使用Maven中心,但我实际上想将Maven中心用于我拥有的所有其他依赖项。

我发出last *:update

时会看到以下内容
[info] Resolving javax.jms#jms;1.1 ...
[debug] sbt-chain: Checking cache for: dependency: javax.jms#jms;1.1 {compile=[default(compile)]}
[debug]                 tried /home/dnugent/.ivy2/local/javax.jms/jms/1.1/ivys/ivy.xml
[debug]         local: no ivy file found for javax.jms#jms;1.1
[debug]                 tried http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom
[debug]         public: found md file for javax.jms#jms;1.1
[debug]                 => http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom (1.1)
[debug] downloading http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom ...
[debug]         public: downloading http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom
[debug]         public: downloading http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom.sha1
[debug] sha1 OK for http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom
[debug]         [SUCCESSFUL ] javax.jms#jms;1.1!jms.pom(pom.original) (121ms)
[debug]                 tried /home/dnugent/.ivy2/local/javax.jms/jms/1.1/jars/jms.jar
[debug]                 tried http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar
[debug] CLIENT ERROR: Not Found url=http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar
[debug]                 tried https://repository.jboss.org/nexus/content/groups/public/javax/jms/jms/1.1/jms-1.1.jar
[debug]         found javax.jms#jms;1.1 in public

JMS 1.1 Jar在JBoss repo中肯定是,所以我真的很困惑这里发生了什么。

2 个答案:

答案 0 :(得分:5)

正如我在the ticket you opened中解释的那样,正在发生的事情是Ivy在特定的解析器中找到pom.xml文件(在这种情况下是maven-central)但是找不到 jar < / em>文件那里。这导致常春藤完全放弃分辨率,而不仅仅是将解析器标记为坏并继续前进。

您需要做的是确保在“坏”解析器之前订购您想要的“好”解析器。您可以通过show fullResolvers命令查看sbt将要使用的resovlers的有序列表。这是一个例子:

> show fullResolvers
[info] ArrayBuffer(Raw(ProjectResolver(inter-project, mapped: )), URLRepository(typesafe-ivy-releases,Patterns(ivyPatterns=List(http://repo.typesafe.com/typesafe/ivy-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(http://repo.typesafe.com/typesafe/ivy-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), URLRepository(sbt-plugin-releases,Patterns(ivyPatterns=List(http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(http://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), FileRepository(local,FileConfiguration(true,None),Patterns(ivyPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), public: http://repo1.maven.org/maven2/)

不幸的是,这个输出现在对人类来说是不可读的。 (请打开export命令的票证以支持fullResolvers,我可以在将来改进调试。但是,我们可以做一些穷人的调试,将其添加到build.sbt

val exportFullResolvers = taskKey[Unit]("debug resolvers")

exportFullResolvers := {
  for {
   (resolver,idx) <- fullResolvers.value.zipWithIndex
  } println(s"${idx}.  ${resolver.name}")
}

现在,你可以在你的sbt构建中运行这个任务来找出/玩具解析器的顺序:

> exportFullResolvers
0.  inter-project
1.  typesafe-ivy-releases
2.  sbt-plugin-releases
3.  local
4.  public
[success] Total time: 0 s, completed Feb 26, 2014 6:10:07 PM

您需要修改解析器,以便项目间首先出现,但“公共”(maven central)在 jboss解析器之后出现。您可以通过以下方式在build.sbt中内联修改resovlers:

fullResolvers := {
  val previous = fullResolvers.value
  previous.sortWith { (lhs, rhs) =>  ??? /* You define something here */ }
}

答案 1 :(得分:0)

有一个参考,您需要覆盖解析器设置而不是附加到此处:SBT won't resolve transitive dependency against any repository except Typesafe's

为我工作。如果SBT团队的任何人看到这一点,那就好像是一个错误。