mirror of https://github.com/sbt/sbt.git
parent
0a13ac1231
commit
675f70fd85
|
|
@ -468,7 +468,7 @@ object Load {
|
||||||
plugs.detected.builds.values
|
plugs.detected.builds.values
|
||||||
}
|
}
|
||||||
val buildLevelExtraProjects = plugs.detected.autoPlugins flatMap { d =>
|
val buildLevelExtraProjects = plugs.detected.autoPlugins flatMap { d =>
|
||||||
d.value.buildExtras map {_.setProjectOrigin(ProjectOrigin.BuildExtra)}
|
d.value.extraProjects map {_.setProjectOrigin(ProjectOrigin.ExtraProject)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE - because we create an eval here, we need a clean-eval later for this URI.
|
// NOTE - because we create an eval here, we need a clean-eval later for this URI.
|
||||||
|
|
@ -602,7 +602,7 @@ object Load {
|
||||||
}
|
}
|
||||||
val p2 = this.resolveProject(p1, autoPlugins, plugins, injectSettings, memoSettings, log)
|
val p2 = this.resolveProject(p1, autoPlugins, plugins, injectSettings, memoSettings, log)
|
||||||
val projectLevelExtra =
|
val projectLevelExtra =
|
||||||
if (expand) autoPlugins flatMap { _.projectExtras(p2) map {_.setProjectOrigin(ProjectOrigin.ProjectExtra)} }
|
if (expand) autoPlugins flatMap { _.derivedProjects(p2) map {_.setProjectOrigin(ProjectOrigin.DerivedProject)} }
|
||||||
else Nil
|
else Nil
|
||||||
(p2, projectLevelExtra)
|
(p2, projectLevelExtra)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,10 +91,10 @@ abstract class AutoPlugin extends Plugins.Basic with PluginsFunctions {
|
||||||
// TODO?: def commands: Seq[Command]
|
// TODO?: def commands: Seq[Command]
|
||||||
|
|
||||||
/** The [[Project]]s to add to the current build. */
|
/** The [[Project]]s to add to the current build. */
|
||||||
def buildExtras: Seq[Project] = Nil
|
def extraProjects: Seq[Project] = Nil
|
||||||
|
|
||||||
/** The [[Project]]s to add to the current build based on an existing project. */
|
/** The [[Project]]s to add to the current build based on an existing project. */
|
||||||
def projectExtras(proj: ProjectDefinition[_]): Seq[Project] = Nil
|
def derivedProjects(proj: ProjectDefinition[_]): Seq[Project] = Nil
|
||||||
|
|
||||||
private[sbt] def unary_! : Exclude = Exclude(this)
|
private[sbt] def unary_! : Exclude = Exclude(this)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -207,10 +207,10 @@ final case class ClasspathDependency(project: ProjectReference, configuration: O
|
||||||
*/
|
*/
|
||||||
sealed trait ProjectOrigin
|
sealed trait ProjectOrigin
|
||||||
object ProjectOrigin {
|
object ProjectOrigin {
|
||||||
case object Organic extends ProjectOrigin
|
case object Organic extends ProjectOrigin
|
||||||
case object BuildExtra extends ProjectOrigin
|
case object ExtraProject extends ProjectOrigin
|
||||||
case object ProjectExtra extends ProjectOrigin
|
case object DerivedProject extends ProjectOrigin
|
||||||
case object GenericRoot extends ProjectOrigin
|
case object GenericRoot extends ProjectOrigin
|
||||||
}
|
}
|
||||||
|
|
||||||
object Project extends ProjectExtra {
|
object Project extends ProjectExtra {
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,14 @@
|
||||||
### Synthetic subprojects
|
### Synthetic subprojects
|
||||||
|
|
||||||
sbt 0.13.13 adds support for `AutoPlugin`s to generate
|
sbt 0.13.13 adds support for `AutoPlugin`s to generate
|
||||||
synthetic subprojects. To generate subprojects, override `buildExtras`
|
synthetic subprojects. To generate subprojects, override `extraProjects`
|
||||||
method as follows:
|
method as follows:
|
||||||
|
|
||||||
import sbt._
|
import sbt._
|
||||||
import Keys._
|
import Keys._
|
||||||
|
|
||||||
object BuildExtrasPlugin extends AutoPlugin {
|
object ExtraProjectPluginExample extends AutoPlugin {
|
||||||
override def buildExtras: Seq[Project] =
|
override def extraProjects: Seq[Project] =
|
||||||
List("foo", "bar", "baz") map generateProject
|
List("foo", "bar", "baz") map generateProject
|
||||||
|
|
||||||
def generateProject(id: String): Project =
|
def generateProject(id: String): Project =
|
||||||
|
|
@ -20,19 +20,19 @@ method as follows:
|
||||||
}
|
}
|
||||||
|
|
||||||
In addition, subprojects may be derived from an existing subproject
|
In addition, subprojects may be derived from an existing subproject
|
||||||
by overriding `projectExtras`.
|
by overriding `derivedProjects`.
|
||||||
|
|
||||||
import sbt._
|
import sbt._
|
||||||
import Keys._
|
import Keys._
|
||||||
|
|
||||||
object ProjectExtrasPlugin extends AutoPlugin {
|
object ExtraProjectPluginExample2 extends AutoPlugin {
|
||||||
// Enable this plugin by default
|
// Enable this plugin by default
|
||||||
override def requires: Plugins = sbt.plugins.CorePlugin
|
override def requires: Plugins = sbt.plugins.CorePlugin
|
||||||
override def trigger = allRequirements
|
override def trigger = allRequirements
|
||||||
|
|
||||||
override def projectExtras(proj: ProjectDefinition[_]): Seq[Project] =
|
override def derivedProjects(proj: ProjectDefinition[_]): Seq[Project] =
|
||||||
// Make sure to exclude project extras to avoid recursive generation
|
// Make sure to exclude project extras to avoid recursive generation
|
||||||
if (proj.projectOrigin != ProjectOrigin.ProjectExtra) {
|
if (proj.projectOrigin != ProjectOrigin.DerivedProject) {
|
||||||
val id = proj.id + "1"
|
val id = proj.id + "1"
|
||||||
Seq(
|
Seq(
|
||||||
Project(id, file(id)).
|
Project(id, file(id)).
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import sbt._
|
import sbt._
|
||||||
import Keys._
|
import Keys._
|
||||||
|
|
||||||
object BuildExtrasPlugin extends AutoPlugin {
|
object ExtraProjectPluginExample extends AutoPlugin {
|
||||||
override def buildExtras: Seq[Project] =
|
override def extraProjects: Seq[Project] =
|
||||||
List("foo", "bar", "baz") map generateProject
|
List("foo", "bar", "baz") map generateProject
|
||||||
|
|
||||||
def generateProject(id: String): Project =
|
def generateProject(id: String): Project =
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import sbt._
|
import sbt._
|
||||||
import Keys._
|
import Keys._
|
||||||
|
|
||||||
object ProjectExtrasPlugin extends AutoPlugin {
|
object ExtraProjectPluginExample2 extends AutoPlugin {
|
||||||
// Enable this plugin by default
|
// Enable this plugin by default
|
||||||
override def requires: Plugins = sbt.plugins.CorePlugin
|
override def requires: Plugins = sbt.plugins.CorePlugin
|
||||||
override def trigger = allRequirements
|
override def trigger = allRequirements
|
||||||
|
|
||||||
override def projectExtras(proj: ProjectDefinition[_]): Seq[Project] =
|
override def derivedProjects(proj: ProjectDefinition[_]): Seq[Project] =
|
||||||
// Make sure to exclude project extras to avoid recursive generation
|
// Make sure to exclude project extras to avoid recursive generation
|
||||||
if (proj.projectOrigin != ProjectOrigin.ProjectExtra) {
|
if (proj.projectOrigin != ProjectOrigin.DerivedProject) {
|
||||||
val id = proj.id + "1"
|
val id = proj.id + "1"
|
||||||
Seq(
|
Seq(
|
||||||
Project(id, file(id)).
|
Project(id, file(id)).
|
||||||
Loading…
Reference in New Issue