How do "transitive resolvers" work with SBT?
Asked Answered
L

2

7

I have the following project build:

import sbt._
import Keys._

object ProjectBuild extends Build {

  val buildVersion = "0.1-SNAPSHOT"

  val delvingReleases = "Delving Releases Repository" at "http://development.delving.org:8081/nexus/content/repositories/releases"
  val delvingSnapshots = "Delving Snapshot Repository" at "http://development.delving.org:8081/nexus/content/repositories/snapshots"
  val delvingRepository = if (buildVersion.endsWith("SNAPSHOT")) delvingSnapshots else delvingReleases

  lazy val root = Project(
    id = "basex-scala-client",
    base = file(".")
  ).settings(

    organization := "eu.delving",
    version := buildVersion,

    resolvers += "BaseX Repository" at "http://files.basex.org/maven",

    libraryDependencies += "org.basex"  %     "basex" % "7.2.1",
    libraryDependencies += "org.specs2" %%    "specs2" % "1.7.1" %  "test",

    publishTo := Some(delvingRepository),

    credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"),

    publishMavenStyle := true
  )

}

When I include the resulting library in another project, like so:

    "eu.delving"         %% "basex-scala-client"         % "0.1-SNAPSHOT"

and I try to build that project, I get an error prompting me that the "org.basex % basex % 7.2.1" library referenced by that project cannot be found.

I have to go and add the resolver in the "client" project in order for the library to be found. Is there a way to avoid this?

Lafontaine answered 23/5, 2012 at 20:8 Comment(0)
D
1

There's no transitive resolvers, so the build user needs to know all the resolvers of all the transitive library dependencies. The benefit of this approach is that on the opensource projects, it encourages projects to publish to one of the known repositories connected to the known resolvers.

For corporate usage, you can prevent your traffic from going to unknown places introduced by some dependencies down the graph.

To share resolver settings within the organization, you can create an org-wide plugin.

Depressomotor answered 18/4, 2014 at 16:31 Comment(1)
Just making sure I understand correctly: when I use a library that has dependencies in another resolver, I need to add the resolvers upstream by hand - is that it?Lafontaine
P
0

Has this situation changed in the last 7 years, 10 months? I have a transitive library dependency at a custom repository. For its immediate client, I specify a resolver and the repository is written to the client's pom file when published. The client's client does not seem to use that information to find the transitive library. I have to "add the resolvers upstream by hand".

Psittacosis answered 9/4, 2020 at 1:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.