Use scalacOptions from project/ for the build definition.

This commit is contained in:
Mark Harrah 2013-10-14 19:59:28 -04:00
parent 1432d633e2
commit 136bb00698
2 changed files with 16 additions and 10 deletions

View File

@ -15,15 +15,18 @@ package sbt
import TaskName._ import TaskName._
final case class EvaluateConfig(cancelable: Boolean, restrictions: Seq[Tags.Rule], checkCycles: Boolean = false, progress: ExecuteProgress[Task] = EvaluateTask.defaultProgress) final case class EvaluateConfig(cancelable: Boolean, restrictions: Seq[Tags.Rule], checkCycles: Boolean = false, progress: ExecuteProgress[Task] = EvaluateTask.defaultProgress)
final case class PluginData(dependencyClasspath: Seq[Attributed[File]], definitionClasspath: Seq[Attributed[File]], resolvers: Option[Seq[Resolver]], report: Option[UpdateReport]) final case class PluginData(dependencyClasspath: Seq[Attributed[File]], definitionClasspath: Seq[Attributed[File]], resolvers: Option[Seq[Resolver]], report: Option[UpdateReport], scalacOptions: Seq[String])
{ {
val classpath: Seq[Attributed[File]] = definitionClasspath ++ dependencyClasspath val classpath: Seq[Attributed[File]] = definitionClasspath ++ dependencyClasspath
} }
object PluginData object PluginData
{ {
@deprecated("Use the alternative that specifies the compiler options and specific classpaths.", "0.13.1")
def apply(dependencyClasspath: Seq[Attributed[File]], definitionClasspath: Seq[Attributed[File]], resolvers: Option[Seq[Resolver]], report: Option[UpdateReport]): PluginData =
PluginData(dependencyClasspath, definitionClasspath, resolvers, report, Nil)
@deprecated("Use the alternative that specifies the specific classpaths.", "0.13.0") @deprecated("Use the alternative that specifies the specific classpaths.", "0.13.0")
def apply(classpath: Seq[Attributed[File]], resolvers: Option[Seq[Resolver]], report: Option[UpdateReport]): PluginData = def apply(classpath: Seq[Attributed[File]], resolvers: Option[Seq[Resolver]], report: Option[UpdateReport]): PluginData =
PluginData(classpath, Nil, resolvers, report) PluginData(classpath, Nil, resolvers, report, Nil)
} }
object EvaluateTask object EvaluateTask

View File

@ -16,7 +16,7 @@ package sbt
import Project.{inScope,makeSettings} import Project.{inScope,makeSettings}
import Def.{ScopedKey, ScopeLocal, Setting} import Def.{ScopedKey, ScopeLocal, Setting}
import Keys.{appConfiguration, baseDirectory, configuration, fullResolvers, fullClasspath, pluginData, streams, thisProject, thisProjectRef, update} import Keys.{appConfiguration, baseDirectory, configuration, fullResolvers, fullClasspath, pluginData, streams, thisProject, thisProjectRef, update}
import Keys.{exportedProducts, isDummy, loadedBuild, resolvedScoped, taskDefinitionKey} import Keys.{exportedProducts, isDummy, loadedBuild, onLoadMessage, resolvedScoped, sbtPlugin, scalacOptions, taskDefinitionKey}
import tools.nsc.reporters.ConsoleReporter import tools.nsc.reporters.ConsoleReporter
import Build.analyzed import Build.analyzed
import Attributed.data import Attributed.data
@ -239,7 +239,7 @@ object Load
lazy val eval = mkEval(unit) lazy val eval = mkEval(unit)
() => eval () => eval
} }
def mkEval(unit: sbt.BuildUnit): Eval = mkEval(unit.definitions, unit.plugins, Nil) def mkEval(unit: sbt.BuildUnit): Eval = mkEval(unit.definitions, unit.plugins, unit.plugins.pluginData.scalacOptions)
def mkEval(defs: sbt.LoadedDefinitions, plugs: sbt.LoadedPlugins, options: Seq[String]): Eval = def mkEval(defs: sbt.LoadedDefinitions, plugs: sbt.LoadedPlugins, options: Seq[String]): Eval =
mkEval(defs.target ++ plugs.classpath, defs.base, options) mkEval(defs.target ++ plugs.classpath, defs.base, options)
def mkEval(classpath: Seq[File], base: File, options: Seq[String]): Eval = def mkEval(classpath: Seq[File], base: File, options: Seq[String]): Eval =
@ -413,7 +413,7 @@ object Load
val defsScala = if(defNames.isEmpty) Nil else loadDefinitions(plugs.loader, defNames) val defsScala = if(defNames.isEmpty) Nil else loadDefinitions(plugs.loader, defNames)
val imports = BuildUtil.getImports(plugs.pluginNames, defNames) val imports = BuildUtil.getImports(plugs.pluginNames, defNames)
lazy val eval = mkEval(plugs.classpath, defDir, Nil) lazy val eval = mkEval(plugs.classpath, defDir, plugs.pluginData.scalacOptions)
val initialProjects = defsScala.flatMap(b => projectsFromBuild(b, normBase)) val initialProjects = defsScala.flatMap(b => projectsFromBuild(b, normBase))
val memoSettings = new mutable.HashMap[File, LoadedSbtFile] val memoSettings = new mutable.HashMap[File, LoadedSbtFile]
@ -519,11 +519,14 @@ object Load
case None => Nil case None => Nil
} }
val autoPluginSettings: Seq[Setting[_]] = inScope(GlobalScope in LocalRootProject)(Seq( val autoPluginSettings: Seq[Setting[_]] = inScope(GlobalScope in LocalRootProject)(Seq(
Keys.sbtPlugin :== true, sbtPlugin :== true,
pluginData <<= (exportedProducts in Configurations.Runtime, fullClasspath in Configurations.Runtime, update, fullResolvers) map ( (prod, cp, rep, rs) => pluginData := {
PluginData(removeEntries(cp, prod), prod, Some(rs), Some(rep)) val prod = (exportedProducts in Configurations.Runtime).value
), val cp = (fullClasspath in Configurations.Runtime).value
Keys.onLoadMessage <<= Keys.baseDirectory("Loading project definition from " + _) val opts = (scalacOptions in Configurations.Compile).value
PluginData(removeEntries(cp, prod), prod, Some(fullResolvers.value), Some(update.value), opts)
},
onLoadMessage := ("Loading project definition from " + baseDirectory.value)
)) ))
private[this] def removeEntries(cp: Seq[Attributed[File]], remove: Seq[Attributed[File]]): Seq[Attributed[File]] = private[this] def removeEntries(cp: Seq[Attributed[File]], remove: Seq[Attributed[File]]): Seq[Attributed[File]] =
{ {