如何将常春藤SSH存储库添加到SBT解析器?

时间:2016-06-15 15:12:28

标签: scala sbt ivy

我很沮丧尝试将SSH Ivy存储库添加到解析器中。

我根据StackOverflow上的各种线程尝试了什么:

pref_auto_mode

Relevant part of buid.sbt

val intResolver = Seq[Resolver]( { import java.io.File val privateKeyFile: File = new File(sys.env("HOME") + "/.ssh/id_rsa") val userName = sys.env("SCN_USER_NAME") Resolver.ssh("int-scn-snapshot-repository", "scn.int.com")(Patterns( "/export/repository/maven2/snapshot/[organisation]/[module]/[revision]/[artifact].[ext]", "/export/repository/maven2/snapshot/[organisation]/[module]/[revision]/[artifact]-[type].[ext]" ) ) as(userName, privateKeyFile) withPermissions("0644") } ) resolvers ++= intResolver val exportFullResolvers = taskKey[Unit]("debug resolvers") exportFullResolvers := { for { (resolver,idx) <- fullResolvers.value.zipWithIndex } println(s"${idx}. ${resolver.name}") } fullResolvers := { val previous = fullResolvers.value previous.sortWith { (lhs, rhs) => if (lhs.name.contains("int-scn")) true else false } } 的输出:

exportFullResolvers
  

> exportFullResolvers 0. int-scn-snapshot-repository 1. inter-project 2. local 3. public [success] Total time: 0 s, completed Jun 15, 2016 8:57:42 AM 的输出:

update

检查输出:解析器:

    [info] Updating {file:/home/mozart/eng/IVAAPBackendRD/}root...
    [info] Resolving org.scala-lang#scala-compiler;2.10.6 ...
    [info] Updating {file:/home/mozart/eng/IVAAPBackendRD/}common...
    [info] Resolving org.fusesource.jansi#jansi;1.4 ...
    [info] Done updating.
    [info] Resolving com.interactive.ivaap#IVAAPWitsmlDataSource;SNAPSHOT ...
    [warn]  module not found: com.interactive.ivaap#IVAAPWitsmlDataSource;SNAPSHOT
    [warn] ==== local: tried
    [warn]   /home/mozart/.ivy2/local/com.interactive.ivaap/IVAAPWitsmlDataSource/SNAPSHOT/ivys/ivy.xml
    [warn] ==== public: tried
    [warn]   https://repo1.maven.org/maven2/com/interactive/ivaap/IVAAPWitsmlDataSource/SNAPSHOT/IVAAPWitsmlDataSource-SNAPSHOT.pom
    [info] Resolving com.interactive.ivaap#IVAAPCommonObjects;1 ...
    [warn]  module not found: com.interactive.ivaap#IVAAPCommonObjects;1
    [warn] ==== local: tried
    [warn]   /home/mozart/.ivy2/local/com.interactive.ivaap/IVAAPCommonObjects/1/ivys/ivy.xml
    [warn] ==== public: tried
    [warn]   https://repo1.maven.org/maven2/com/interactive/ivaap/IVAAPCommonObjects/1/IVAAPCommonObjects-1.pom
    [info] Resolving jline#jline;2.12.1 ...
    [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
    [warn]  ::          UNRESOLVED DEPENDENCIES         ::
    [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
    [warn]  :: com.interactive.ivaap#IVAAPWitsmlDataSource;SNAPSHOT: not found
    [warn]  :: com.interactive.ivaap#IVAAPCommonObjects;1: not found
    [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
    [warn] 
    [warn]  Note: Unresolved dependencies path:
    [warn]          com.interactive.ivaap:IVAAPWitsmlDataSource:SNAPSHOT (/home/mozart/eng/IVAAPBackendRD/build.sbt#L68)
    [warn]            +- com.acme:ivaap-common_2.11:0.11
    [warn]          com.interactive.ivaap:IVAAPCommonObjects:1 (/home/mozart/eng/IVAAPBackendRD/build.sbt#L68)
    [warn]            +- com.acme:ivaap-common_2.11:0.11
    [trace] Stack trace suppressed: run last common/*:update for the full output.
    [error] (common/*:update) sbt.ResolveException: unresolved dependency: com.interactive.ivaap#IVAAPWitsmlDataSource;SNAPSHOT: not found

请注意,这是一个多项目构建,所涉及的依赖项仅供其中一个子项目使用。这是否意味着我需要移动解析器并以某种方式与该子项目相关联?

   > inspect compile:resolvers
    [info] Setting: scala.collection.Seq[sbt.Resolver] = List(SshRepository(int-scn-snapshot-repository,SshConnection(Some(KeyFileAuthentication(mozart.brocchini,/home/mozart/.ssh/id_rsa,None)),Some(scn.int.com),None),Patterns(ivyPatterns=WrappedArray(/export/repository/maven2/snapshot/[organisation]/[module]/[revision]/[artifact].[ext], /export/repository/maven2/snapshot/[organisation]/[module]/[revision]/[artifact]-[type].[ext]), artifactPatterns=WrappedArray(/export/repository/maven2/snapshot/[organisation]/[module]/[revision]/[artifact].[ext], /export/repository/maven2/snapshot/[organisation]/[module]/[revision]/[artifact]-[type].[ext]), isMavenCompatible=true, descriptorOptional=false, skipConsistencyCheck=false),Some(0644)))
    [info] Description:
    [info]  The user-defined additional resolvers for automatically managed dependencies.
    [info] Provided by:
    [info]  {file:/home/mozart/eng/IVAAPBackendRD/}root/*:resolvers
    [info] Defined at:
    [info]  /home/mozart/eng/IVAAPBackendRD/build.sbt:17
    [info] Delegates:
    [info]  root/compile:resolvers
    [info]  root/*:resolvers
    [info]  {.}/compile:resolvers
    [info]  {.}/*:resolvers
    [info]  */compile:resolvers
    [info]  */*:resolvers
    [info] Related:
    [info]  root/*:resolvers
    [info]  */*:resolvers

为什么不查找我的SSH Ivy存储库以进行依赖项解析?

1 个答案:

答案 0 :(得分:1)

很难从你的问题中准确地说出来,但看起来你将解析器添加到与编译不同的范围内的解析器。 有几个方面需要检查:

  1. 您是否正在将解析程序添加到project / plugins.sbt中的解析程序?
  2. 在sbt控制台中检查您正在尝试编译的项目中的解析器的详细信息。使用inspect resolvers命令
  3. 详细了解Scopes,了解您要添加解析器的范围以及正在运行更新的范围。
  4. 尝试使用resolvers in ThisBuild代替resolvers
  5. 如果只需要在多项目的通用模块中解析器。你可以使用这样的东西:

    Project(id = "common", base = ...)
      .settings(
        resolvers ++= intResolver
      )