Auto plugin names are imported with or without autoImport. Fixes #1217

This commit is contained in:
Eugene Yokota 2014-03-27 17:36:40 -04:00
parent 9dde1ac46e
commit 5f7e68c7dd
3 changed files with 11 additions and 5 deletions

View File

@ -104,7 +104,8 @@ final class DetectedPlugins(val plugins: DetectedModules[Plugin], val autoPlugin
(autoPlugins flatMap { case DetectedAutoPlugin(name, ap, hasAutoImport) =>
if (hasAutoImport) Some(name + ".autoImport")
else None
}))
})) ++
BuildUtil.importNamesRoot(autoPlugins map { _.name })
/** A function to select the right [[AutoPlugin]]s from [[autoPlugins]] for a [[Project]]. */
lazy val deducePlugins: (Plugins, Logger) => Seq[AutoPlugin] = Plugins.deducer(autoPlugins.toList map {_.value})

View File

@ -80,9 +80,16 @@ object BuildUtil
@deprecated("Use getImports(Seq[String]).", "0.13.2")
def getImports(pluginNames: Seq[String], buildNames: Seq[String]): Seq[String] = getImports(pluginNames ++ buildNames)
/** `import sbt._, Keys._`, and wildcard import `._` for all names. */
def getImports(names: Seq[String]): Seq[String] = baseImports ++ importAllRoot(names)
def importAll(values: Seq[String]): Seq[String] = if(values.isEmpty) Nil else values.map( _ + "._" ).mkString("import ", ", ", "") :: Nil
/** Import just the names. */
def importNames(names: Seq[String]): Seq[String] = if (names.isEmpty) Nil else names.mkString("import ", ", ", "") :: Nil
/** Prepend `_root_` and import just the names. */
def importNamesRoot(names: Seq[String]): Seq[String] = importNames(names map rootedName)
/** Wildcard import `._` for all values. */
def importAll(values: Seq[String]): Seq[String] = importNames(values map { _ + "._" })
def importAllRoot(values: Seq[String]): Seq[String] = importAll(values map rootedName)
def rootedName(s: String): String = if(s contains '.') "_root_." + s else s
@ -98,4 +105,4 @@ object BuildUtil
(ref, agg)
Relation.empty ++ depPairs
}
}
}

View File

@ -1,5 +1,3 @@
import sbttest.{Q, S}
// disablePlugins(Q) will prevent R from being auto-added
lazy val projA = project.addPlugins(A, B).disablePlugins(Q)