Skip to content

Commit

Permalink
Add withAddedResolvers to DependencyResolutionInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed Sep 1, 2023
1 parent 689f347 commit cb38ccb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cb38ccb

Please sign in to comment.