harrah/xsbt — Issue #318: No way to reference an external project's plugin project.
Author: Atry
Created: 2011-12-28 07:02:27+00:00
State: open

I have directory layout like:

* root/
* project/
* Build.scala
* foo/
* build.sbt
* project/
* plugin.sbt
* bar/
* build.sbt

I defined three project `root`, `foo`, `bar` in `root/project/Build.scala`:

```scala
import sbt._
import Keys._
object RootBuild extends Build {
lazy val foo = RootProject(file("foo"))
lazy val bar = Project(id = "bar", base = file("bar"))
lazy val root = Project(id = "root", base = file("."))

def addBuildDependency(p1: ProjectReference) =
buildDependencies in p1 <<=
(buildDependencies in p1, thisProjectRef in p1, thisProjectRef in bar) {
(origin, rp1, rp2) =>
origin.addClasspath(rp1, ResolvedClasspathDependency(rp2, None))
}

override def settings = super.settings ++ Seq(

// Inject settings into foo, OK!
addBuildDependency(foo),

// Inject settings into foo's plugin. Need to implement getPluginProject function to let it works.
addBuildDependency(getPluginProject(foo))
)

def getPluginProject(p: ProjectReference): ProjectReference = {
// How to implement a function to get the plugin project reference?
}
}
```

Because `foo` has its plugin.sbt, it is a RootProject. I can inject settings into `foo` using `key in foo := ...` syntax, but I don't know how to inject settings into `foo`'s plugin from `root/project/Build.scala`.

This feature is useful because it allows root project change subprojects's plugin.