Skip to content

Instantly share code, notes, and snippets.

@rossabaker
Created November 3, 2010 19:47
Show Gist options
  • Save rossabaker/661590 to your computer and use it in GitHub Desktop.
Save rossabaker/661590 to your computer and use it in GitHub Desktop.
trait ScalatraTestDependencies extends BasicManagedProject {
def testProjectDependencies = List(scalatest, specs)
abstract override def dependencies = super.dependencies.toList ++ testProjectDependencies
override def deliverProjectDependencies: Iterable[ModuleID] = {
val testDependencyIds = testProjectDependencies.map(_.projectID).toList
super.deliverProjectDependencies.toList -- testDependencyIds ++ (testDependencyIds map { _ % "test" })
}
override def fullClasspath(config: Configuration): PathFinder = Path.lazyPathFinder {
def classpath(projects: Iterable[Project], config: Configuration) = projects flatMap {
case sp: ClasspathProject => sp.projectClasspath(config).get
case _ => Nil
}
val nonTestTopologicalSort = Dag.topologicalSort[Project](this) {
case p: ScalatraTestDependencies => p.dependencies -- testProjectDependencies
case p: Project => p.dependencies
}
val set = new LinkedHashSet[Path]
set ++= classpath(nonTestTopologicalSort, config)
if (config == Configurations.Test) {
set ++= classpath(topologicalSort -- nonTestTopologicalSort, Configurations.Default)
}
set.toList
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment