bugfix - apply autoImports for global plugins at global configuration stage#2399
bugfix - apply autoImports for global plugins at global configuration stage#2399
Conversation
|
Can one of the admins verify this patch? |
|
I've confirmed that this change resolves issue #2120 as I've experienced it. I'm not deeply familiar with the sbt code base, and am not sure what kind of consequences my change might have. One consequence is that it seems that it will scan for autoPlugins twice; not sure how much more expensive that will be. I don't know what the consequence of not passing an UpdateReport, or Resolvers. None seem to be available at the |
|
Could you add your test in here? See http://eed3si9n.com/testing-sbt-plugins for the explanation on scripted. |
|
Yeah, I'll have to work on that later. I didn't want to try and add tests until at least my approach was validated by somebody who knows what they're doing. |
main/src/main/scala/sbt/Load.scala
Outdated
There was a problem hiding this comment.
Why not cache this in LoadBuildConfiguration as a lazy val?
There was a problem hiding this comment.
I don't think I can, since PluginDiscovery requires a ClassLoader, and I don't think a ClassLoader is available in LoadBuildConfiguration.
There was a problem hiding this comment.
Oh, hey, there is one there! I'll update the patch.
Like I said in the chat room... I don't know what I'm doing and just threw up a patch to get some validation. Please don't expect this to be me saying "here's a finished patch, please merge it right now". :)
|
Plz add release note to https://github.com/sbt/sbt/tree/0.13/notes/0.13.10 |
|
added release note and moved detectedPlugin related code to LoadBuildConfiguration. Tests still remaining. |
|
I've defined an AutoPlugin for the |
|
Here's what I have locally:
|
|
I'm trying that exact same thing and it doesn't seem to work. I'll try again. Are you running the test with |
Yes. |
|
Here's how my final case class LoadBuildConfiguration(
stagingDirectory: File,
classpath: Seq[Attributed[File]],
loader: ClassLoader,
compilers: Compilers,
evalPluginDef: (sbt.BuildStructure, State) => PluginData,
definesClass: DefinesClass,
delegates: sbt.LoadedBuild => Scope => Seq[Scope],
scopeLocal: ScopeLocal,
pluginManagement: PluginManagement,
injectSettings: Load.InjectSettings,
globalPlugin: Option[GlobalPlugin],
extraBuilds: Seq[URI],
log: Logger) {
lazy val (globalPluginClasspath, globalPluginLoader) = Load.pluginDefinitionLoader(this, Load.globalPluginClasspath(globalPlugin))
lazy val globalPluginNames = if (globalPluginClasspath.isEmpty) Nil else Load.getPluginNames(globalPluginClasspath, globalPluginLoader)
private[sbt] lazy val globalPluginDefs = {
val pluginData = globalPlugin match {
case Some(x) => PluginData(x.data.fullClasspath, x.data.internalClasspath, Some(x.data.resolvers), Some(x.data.updateReport), Nil)
case None => PluginData(globalPluginClasspath, Nil, None, None, Nil)
}
val baseDir = globalPlugin match {
case Some(x) => x.base
case _ => stagingDirectory
}
Load.loadPluginDefinition(baseDir, this, pluginData)
}
lazy val detectedGlobalPlugins = globalPluginDefs.detected
} |
main/src/main/scala/sbt/Load.scala
Outdated
b132387 to
ade8962
Compare
|
I've added integration tests to assert that both legacy-plugin-defined-keys and auto-plugin autoImports are available for global configuration files. This patch should be ready to go. Everything works in usage and in the |
notes/0.13.10.markdown
Outdated
… stage Previously, the autoimports for globally defined plugins were not imported for global configuration files, although they were imported for project configuration files. This patch causes an additional plugin discovery phase to happen during global config evaluation, so that auto-plugins can be detected and their imports subsequently included.
|
LGTM pending Travis. |
|
Same 👍 Thanks @timcharper and yeah please pull request this against 1.0.x as well. |
|
Sure! I'll do so once the tests pass and are merged into 0.13. That okay? |
|
Sure. |
|
It seems like the failure in travis-ci is unrelated to my change: https://travis-ci.org/sbt/sbt/jobs/103215626 |
|
Job restarted. |
|
It seems like |
Yes. |
bugfix - apply autoImports for global plugins at global configuration stage
Forward port pull request #2399 to 1.0.x
|
https://gitter.im/sbt/sbt?at=56a3c957586242210adf1d87
Us importing "not doing a wildcard import" is apparently a workaround, but this is a sticky situation because global settings are used across all 0.13 builds. |
No description provided.