mirror of https://github.com/sbt/sbt.git
prefix automatic imports with _root_. Fixes #173.
This commit is contained in:
parent
3511b47f07
commit
0283ad2fc8
|
|
@ -69,7 +69,7 @@ object Load
|
|||
def buildGlobalSettings(base: File, files: Seq[File], config: LoadBuildConfiguration): ClassLoader => Seq[Setting[_]] =
|
||||
{
|
||||
val eval = mkEval(data(config.globalPluginClasspath), base, defaultEvalOptions)
|
||||
val imports = baseImports ++ importAll(config.globalPluginNames)
|
||||
val imports = baseImports ++ importAllRoot(config.globalPluginNames)
|
||||
EvaluateConfigurations(eval, files, imports)
|
||||
}
|
||||
def loadGlobal(state: State, base: File, global: File, config: LoadBuildConfiguration): LoadBuildConfiguration =
|
||||
|
|
@ -497,6 +497,7 @@ object Load
|
|||
ModuleUtilities.getObject(pluginName, loader).asInstanceOf[Plugin].settings
|
||||
|
||||
def importAll(values: Seq[String]) = if(values.isEmpty) Nil else values.map( _ + "._" ).mkString("import ", ", ", "") :: Nil
|
||||
def importAllRoot(values: Seq[String]) = importAll(values.map("_root_." + _))
|
||||
|
||||
def findPlugins(analysis: inc.Analysis): Seq[String] = discover(analysis, "sbt.Plugin")
|
||||
def findDefinitions(analysis: inc.Analysis): Seq[String] = discover(analysis, "sbt.Build")
|
||||
|
|
@ -566,7 +567,7 @@ object Load
|
|||
def imports = getImports(unit)
|
||||
override def toString = unit.toString
|
||||
}
|
||||
def getImports(unit: BuildUnit) = baseImports ++ importAll(unit.plugins.pluginNames ++ unit.definitions.buildNames)
|
||||
def getImports(unit: BuildUnit) = baseImports ++ importAllRoot(unit.plugins.pluginNames ++ unit.definitions.buildNames)
|
||||
|
||||
def referenced[PR <: ProjectReference](definitions: Seq[ProjectDefinition[PR]]): Seq[PR] = definitions flatMap { _.referenced }
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
maxErrors := xyz
|
||||
|
||||
name := "Demo"
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package name.example
|
||||
|
||||
import sbt._
|
||||
|
||||
object P extends Plugin {
|
||||
val xyz = 3
|
||||
val checkMaxErrors = TaskKey[Unit]("check-max-errors")
|
||||
val checkName = TaskKey[Unit]("check-name")
|
||||
|
||||
override def settings = Seq[Setting[_]](
|
||||
checkMaxErrors <<= Keys.maxErrors map { me => assert(me == xyz, "Expected maxErrors to be " + xyz + ", but it was " + me ) },
|
||||
checkName <<= Keys.name map { n => assert(n == "Demo", "Expected name to be 'Demo', but it was '" + n + "'" ) }
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
-> check-name
|
||||
-> check-max-errors
|
||||
|
||||
$ copy-file changes/build.sbt build.sbt
|
||||
> reload
|
||||
|
||||
> check-name
|
||||
> check-max-errors
|
||||
Loading…
Reference in New Issue