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 11, 2023
1 parent 689f347 commit a8ce9fa
Show file tree
Hide file tree
Showing 3 changed files with 35 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,19 @@ 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 = {
val newConfiguration = ivySbt.configuration match {
case configuration: ExternalIvyConfiguration =>
configuration.withExtraResolvers(configuration.extraResolvers ++ resolvers)
case configuration: InlineIvyConfiguration =>
configuration.withResolvers(configuration.resolvers ++ resolvers)
}
new IvyDependencyResolution(new IvySbt(newConfiguration))
}

private[sbt] def toModule(module: ModuleDescriptor): Module =
module match {
case m: Module @unchecked => m
Expand Down

0 comments on commit a8ce9fa

Please sign in to comment.