Merge pull request #8257 from azdrojowa123/1.11.x-reverse-topological-sort

This commit is contained in:
eugene yokota 2025-09-01 12:00:50 -04:00 committed by GitHub
commit c6769e34be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -17,6 +17,15 @@ object Dag {
import scala.collection.{ mutable, JavaConverters }
import JavaConverters.asScalaSetConverter
/**
* Returns a reverse topological ordering of the graph rooted at `root`.
* In this ordering, each node appears before all of its ancestors (i.e., children are listed before their parents).
*
* @see [[https://github.com/sbt/sbt/issues/8249]]
*/
def reverseTopologicalSort[T](root: T)(dependencies: T => Iterable[T]): List[T] =
topologicalSort(root)(dependencies).reverse
def topologicalSort[T](root: T)(dependencies: T => Iterable[T]): List[T] =
topologicalSort(root :: Nil)(dependencies)

View File

@ -406,7 +406,7 @@ private[sbt] object ClasspathImpl {
private def trim(a: Array[String]): List[String] = a.toList.map(_.trim)
def allConfigs(conf: Configuration): Seq[Configuration] =
Dag.topologicalSort(conf)(_.extendsConfigs)
Dag.reverseTopologicalSort(conf)(_.extendsConfigs)
def getConfigurations(p: ResolvedReference, data: Settings[Scope]): Seq[Configuration] =
(p / ivyConfigurations).get(data).getOrElse(Nil)