mirror of https://github.com/sbt/sbt.git
global plugin settings. ref #378
This commit is contained in:
parent
1581d1b7e1
commit
be3d565284
|
|
@ -33,6 +33,9 @@ trait Plugin
|
|||
|
||||
/** Settings to be appended at the build scope. */
|
||||
def buildSettings: Seq[Project.Setting[_]] = Nil
|
||||
|
||||
/** Settings to be appended at the global scope. */
|
||||
def globalSettings: Seq[Project.Setting[_]] = Nil
|
||||
}
|
||||
|
||||
object Build
|
||||
|
|
|
|||
|
|
@ -188,8 +188,10 @@ object Load
|
|||
|
||||
def isProjectThis(s: Setting[_]) = s.key.scope.project match { case This | Select(ThisProject) => true; case _ => false }
|
||||
def buildConfigurations(loaded: LoadedBuild, rootProject: URI => String, rootEval: () => Eval, injectSettings: InjectSettings): Seq[Setting[_]] =
|
||||
{
|
||||
((loadedBuild in GlobalScope :== loaded) +:
|
||||
transformProjectOnly(loaded.root, rootProject, injectSettings.global)) ++
|
||||
inScope(GlobalScope)( pluginGlobalSettings(loaded) ) ++
|
||||
loaded.units.toSeq.flatMap { case (uri, build) =>
|
||||
val eval = if(uri == loaded.root) rootEval else lazyEval(build.unit)
|
||||
val plugins = build.unit.plugins.plugins
|
||||
|
|
@ -214,6 +216,11 @@ object Load
|
|||
val buildSettings = transformSettings(buildScope, uri, rootProject, pluginNotThis ++ pluginBuildSettings ++ (buildBase +: build.buildSettings))
|
||||
buildSettings ++ projectSettings
|
||||
}
|
||||
}
|
||||
def pluginGlobalSettings(loaded: LoadedBuild): Seq[Setting[_]] =
|
||||
loaded.units.toSeq flatMap { case (_, build) =>
|
||||
build.unit.plugins.plugins flatMap { _.globalSettings }
|
||||
}
|
||||
def extractSettings(plugins: Seq[Plugin]): (Seq[Setting[_]], Seq[Setting[_]], Seq[Setting[_]]) =
|
||||
(plugins.flatMap(_.settings), plugins.flatMap(_.projectSettings), plugins.flatMap(_.buildSettings))
|
||||
def transformProjectOnly(uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] =
|
||||
|
|
|
|||
Loading…
Reference in New Issue