jeudi 16 juin 2016

How to add an Ivy SSH repository to SBT resolvers?

I am frustrated trying to add an SSH Ivy repository to the resolvers.

What I have tried based on various threads on StackOverflow :

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 }
    }

The output of 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

The output of 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

Output of inspect:resolvers:

   > 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

Please note that this is a multi project build and the dependency in question is only used by one of the sub projects. Does this mean that I need to move the resolver and somehow associate with that subproject ?

    > inspect common/update:resolvers
    [info] Setting: scala.collection.Seq[sbt.Resolver] = List()
    [info] Description:
    [info]  The user-defined additional resolvers for automatically managed dependencies.
    [info] Provided by:
    [info]  */*:resolvers
    [info] Defined at:
    [info]  (sbt.Classpaths) Defaults.scala:1122
    [info] Delegates:
    [info]  common/update:resolvers
    [info]  common/*:resolvers
    [info]  {.}/update:resolvers
    [info]  {.}/*:resolvers
    [info]  */update:resolvers
    [info]  */*:resolvers
    [info] Related:
    [info]  root/*:resolvers
    [info]  */*:resolvers
    > 

Why isn't my SSH Ivy repository being looked up for dependency resolution ?

Aucun commentaire:

Enregistrer un commentaire