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

Dan*_*ung 3 ivy maven sbt

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

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

resolvers += "JBoss" at "https://repository.jboss.org/nexus/content/groups/public"
Run Code Online (Sandbox Code Playgroud)

,但是当我尝试使用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
Run Code Online (Sandbox Code Playgroud)

我看到了关于设置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回购中,所以我真的很困惑这里发生了什么.

jsu*_*eth 5

正如我在您打开的故障单中解释的那样,发生的事情是Ivy pom.xml在特定的解析器中找到该文件(在本例中为maven-central),但无法在那里找到jar文件.这导致常春藤完全放弃分辨率,而不仅仅是将解析器标记为坏并继续前进.

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

> 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/)
Run Code Online (Sandbox Code Playgroud)

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

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

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

现在,你可以在你的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
Run Code Online (Sandbox Code Playgroud)

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

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