From be3d565284e9364fd0091042ca09e3a9636e25a9 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 30 May 2012 20:02:24 -0400 Subject: [PATCH] global plugin settings. ref #378 --- main/Build.scala | 3 +++ main/Load.scala | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/main/Build.scala b/main/Build.scala index 46a69aacd..4d7cf7033 100644 --- a/main/Build.scala +++ b/main/Build.scala @@ -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 diff --git a/main/Load.scala b/main/Load.scala index 2f3f485f3..d1b21e08b 100755 --- a/main/Load.scala +++ b/main/Load.scala @@ -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[_]] =