mirror of https://github.com/sbt/sbt.git
Merge pull request #8257 from azdrojowa123/1.11.x-reverse-topological-sort
This commit is contained in:
commit
c6769e34be
|
|
@ -17,6 +17,15 @@ object Dag {
|
||||||
import scala.collection.{ mutable, JavaConverters }
|
import scala.collection.{ mutable, JavaConverters }
|
||||||
import JavaConverters.asScalaSetConverter
|
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] =
|
def topologicalSort[T](root: T)(dependencies: T => Iterable[T]): List[T] =
|
||||||
topologicalSort(root :: Nil)(dependencies)
|
topologicalSort(root :: Nil)(dependencies)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -406,7 +406,7 @@ private[sbt] object ClasspathImpl {
|
||||||
private def trim(a: Array[String]): List[String] = a.toList.map(_.trim)
|
private def trim(a: Array[String]): List[String] = a.toList.map(_.trim)
|
||||||
|
|
||||||
def allConfigs(conf: Configuration): Seq[Configuration] =
|
def allConfigs(conf: Configuration): Seq[Configuration] =
|
||||||
Dag.topologicalSort(conf)(_.extendsConfigs)
|
Dag.reverseTopologicalSort(conf)(_.extendsConfigs)
|
||||||
|
|
||||||
def getConfigurations(p: ResolvedReference, data: Settings[Scope]): Seq[Configuration] =
|
def getConfigurations(p: ResolvedReference, data: Settings[Scope]): Seq[Configuration] =
|
||||||
(p / ivyConfigurations).get(data).getOrElse(Nil)
|
(p / ivyConfigurations).get(data).getOrElse(Nil)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue