3
import ScalaBuildKeys._
6
object RemoteDependencies {
7
def buildSettings(externalProjects: Set[URI], localScala: Setting[_]): Seq[Setting[_]] = Seq(
8
commands += Command.command("fix-uri-projects") { (state: State) =>
9
if(state.get(buildFixed) getOrElse false) state
11
// TODO -fix up scalacheck's dependencies!
12
val extracted = Project.extract(state)
14
val scalaVersionString = extracted get version
16
def fix(s: Setting[_]): Setting[_] = s match {
17
case ScopedExternalSetting(p, scalaInstance.key, setting) if externalProjects(p) => localScala mapKey Project.mapScope(_ => s.key.scope)
18
// TODO - Fix Actors dependency...
19
//case ScopedExternalSetting(p, libraryDependencies.key, setting) if externalProjects(p) => fixProjectDeps(s)
22
val transformed = session.mergeSettings map ( s => fix(s) )
23
val scopes = transformed collect { case ScopedExternalSetting(p, _, s) if externalProjects(p) => s.key.scope } toSet
24
// Create some fixers so we don't download scala or rely on it.
25
// Also add dependencies that disappear in 2.10 for now...
26
val fixers = for { scope <- scopes
27
setting <- Seq(autoScalaLibrary := false,
29
scalaVersion := scalaVersionString)
30
} yield setting mapKey Project.mapScope(_ => scope)
31
val newStructure = Load.reapply(transformed ++ fixers, structure)
32
Project.setProject(session, newStructure, state).put(buildFixed, true)
35
onLoad in Global <<= (onLoad in Global) apply (_ andThen { (state: State) =>
36
"fix-uri-projects" :: state
43
/** Matcher to make updated remote project references easier. */
44
object ScopedExternalSetting {
45
def unapply[T](s: Setting[_]): Option[(URI, AttributeKey[_], Setting[_])] =
46
s.key.scope.project match {
47
case Select(p @ ProjectRef(uri, _)) => Some((uri, s.key.key, s))