use reverse topological order for configurations when resolving internal dependencies

- changes the classpath order for internal dependencies
- fix #8249
This commit is contained in:
Aleksandra Zdrojowa 2025-09-01 16:47:44 +02:00
parent 28e7ef7d2c
commit 622994b40d
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)