diff --git a/main/Defaults.scala b/main/Defaults.scala index ccf1e1c46..da3155018 100644 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -576,8 +576,18 @@ object Defaults extends BuildCommon def transitiveDependencies(base: ProjectRef, structure: LoadedBuild, includeRoot: Boolean, classpath: Boolean = true, aggregate: Boolean = false): Seq[ProjectRef] = { - val full = Dag.topologicalSort(base)(getDependencies(structure, classpath, aggregate)) - if(includeRoot) full else full.dropRight(1) + def tdeps(enabled: Boolean, f: ProjectRef => Seq[ProjectRef]): Seq[ProjectRef] = + { + val full = if(enabled) Dag.topologicalSort(base)(f) else Nil + if(includeRoot) full else full dropRight 1 + } + def fullCp = tdeps(classpath, getDependencies(structure, classpath=true, aggregate=false)) + def fullAgg = tdeps(aggregate, getDependencies(structure, classpath=false, aggregate=true)) + (classpath, aggregate) match { + case (true, true) => (fullCp ++ fullAgg).distinct + case (true, false) => fullCp + case _ => fullAgg + } } def getDependencies(structure: LoadedBuild, classpath: Boolean = true, aggregate: Boolean = false): ProjectRef => Seq[ProjectRef] = ref => Project.getProject(ref, structure).toList flatMap { p => diff --git a/main/Project.scala b/main/Project.scala index eb610d046..c8ff698e5 100644 --- a/main/Project.scala +++ b/main/Project.scala @@ -207,7 +207,7 @@ object Project extends Init[Scope] with ProjectExtra def setCond[T](key: AttributeKey[T], vopt: Option[T], attributes: AttributeMap): AttributeMap = vopt match { case Some(v) => attributes.put(key, v); case None => attributes.remove(key) } def makeSettings(settings: Seq[Setting[_]], delegates: Scope => Seq[Scope], scopeLocal: ScopedKey[_] => Seq[Setting[_]])(implicit display: Show[ScopedKey[_]]) = - translateCyclic( make(settings)(delegates, scopeLocal, display) ) + make(settings)(delegates, scopeLocal, display) def displayFull(scoped: ScopedKey[_]): String = Scope.display(scoped.scope, scoped.key.label) def display(ref: Reference): String = @@ -247,8 +247,6 @@ object Project extends Init[Scope] with ProjectExtra val f = mapScope(g) ss.map(_ mapReferenced f) } - def translateCyclic[T](f: => T): T = - try { f } catch { case c: Dag.Cyclic => throw new MessageOnlyException(c.getMessage) } def delegates(structure: BuildStructure, scope: Scope, key: AttributeKey[_]): Seq[ScopedKey[_]] = structure.delegates(scope).map(d => ScopedKey(d, key)) diff --git a/sbt/src/sbt-test/project/circular/B.scala b/sbt/src/sbt-test/project/circular/B.scala new file mode 100644 index 000000000..10357cf39 --- /dev/null +++ b/sbt/src/sbt-test/project/circular/B.scala @@ -0,0 +1,3 @@ +object B { + val x = 3 +} diff --git a/sbt/src/sbt-test/project/circular/project/P.scala b/sbt/src/sbt-test/project/circular/project/P.scala new file mode 100644 index 000000000..fb653b9ca --- /dev/null +++ b/sbt/src/sbt-test/project/circular/project/P.scala @@ -0,0 +1,17 @@ +import sbt._ +import Keys._ + +object Build extends Build { + + lazy val root: Project = Project( + "root", + file("."), + aggregate = Seq(sub) + ) + + lazy val sub: Project = Project( + "sub", + file("sub"), + dependencies = Seq(root) + ) +} diff --git a/sbt/src/sbt-test/project/circular/sub/A.scala b/sbt/src/sbt-test/project/circular/sub/A.scala new file mode 100644 index 000000000..b4f21fac5 --- /dev/null +++ b/sbt/src/sbt-test/project/circular/sub/A.scala @@ -0,0 +1,3 @@ +object A { + def x = B.x +} diff --git a/sbt/src/sbt-test/project/circular/test b/sbt/src/sbt-test/project/circular/test new file mode 100644 index 000000000..5df2af1f3 --- /dev/null +++ b/sbt/src/sbt-test/project/circular/test @@ -0,0 +1 @@ +> compile diff --git a/util/collection/Dag.scala b/util/collection/Dag.scala index b617070dd..14a418f26 100644 --- a/util/collection/Dag.scala +++ b/util/collection/Dag.scala @@ -60,6 +60,7 @@ object Dag ) { def this(value: Any) = this(value, value :: Nil, false) + override def toString = getMessage def ::(a: Any): Cyclic = if(complete) this