diff --git a/core/src/main/scala/sbt/librarymanagement/DependencyResolution.scala b/core/src/main/scala/sbt/librarymanagement/DependencyResolution.scala index 1f2b37a2..1259a899 100644 --- a/core/src/main/scala/sbt/librarymanagement/DependencyResolution.scala +++ b/core/src/main/scala/sbt/librarymanagement/DependencyResolution.scala @@ -198,6 +198,18 @@ class DependencyResolution private[sbt] (lmEngine: DependencyResolutionInterface } } + /** + * Returns a new copy of DependencyResolutionInterface which contains the added resolvers. + * Useful for when you have resolvers that are outside the context of an sbt scope/project + * (i.e. a standalone setting) + * + * @param resolvers The resolvers to add + * @param log The logger + * @return A copy of DependencyResolutionInterface which contains the added resolvers + */ + def withAddedResolvers(resolvers: Seq[Resolver], log: Logger): DependencyResolutionInterface = + lmEngine.withAddedResolvers(resolvers, log) + protected def directDependenciesNames(module: ModuleDescriptor): String = (module.directDependencies map { case mID: ModuleID => import mID._ diff --git a/core/src/main/scala/sbt/librarymanagement/LibraryManagementInterface.scala b/core/src/main/scala/sbt/librarymanagement/LibraryManagementInterface.scala index cdca4a8d..a4402c05 100644 --- a/core/src/main/scala/sbt/librarymanagement/LibraryManagementInterface.scala +++ b/core/src/main/scala/sbt/librarymanagement/LibraryManagementInterface.scala @@ -32,6 +32,16 @@ trait DependencyResolutionInterface { uwconfig: UnresolvedWarningConfiguration, log: Logger ): Either[UnresolvedWarning, UpdateReport] + + /** + * Returns a new copy of DependencyResolutionInterface which contains the added resolvers. + * Useful for when you have resolvers that are outside the context of an sbt scope/project + * (i.e. a standalone setting) + * @param resolvers The resolvers to add + * @param log The logger + * @return A copy of DependencyResolutionInterface which contains the added resolvers + */ + def withAddedResolvers(resolvers: Seq[Resolver], log: Logger): DependencyResolutionInterface } /** diff --git a/ivy/src/main/scala/sbt/librarymanagement/ivy/IvyDependencyResolution.scala b/ivy/src/main/scala/sbt/librarymanagement/ivy/IvyDependencyResolution.scala index 3f5aedac..129f07ab 100644 --- a/ivy/src/main/scala/sbt/librarymanagement/ivy/IvyDependencyResolution.scala +++ b/ivy/src/main/scala/sbt/librarymanagement/ivy/IvyDependencyResolution.scala @@ -21,6 +21,16 @@ class IvyDependencyResolution private[sbt] (val ivySbt: IvySbt) ): Either[UnresolvedWarning, UpdateReport] = IvyActions.updateEither(toModule(module), configuration, uwconfig, log) + override def withAddedResolvers( + resolvers: Seq[Resolver], + log: Logger + ): IvyDependencyResolution = { + ivySbt.withIvy(log) { ivy => + IvySbt.addResolvers(resolvers, ivy.getSettings, log) + } + new IvyDependencyResolution(ivySbt) + } + private[sbt] def toModule(module: ModuleDescriptor): Module = module match { case m: Module @unchecked => m