Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

@mdedetrich mdedetrich Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InlineIvyConfiguration also has a otherResolvers field where the resolvers can be added, not sure what the intended difference is meant to be and whether it should be used instead.

}
new IvyDependencyResolution(new IvySbt(newConfiguration))
}

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