diff --git a/main/src/main/scala/sbt/Load.scala b/main/src/main/scala/sbt/Load.scala index e5d8a5113..ecd04cf07 100755 --- a/main/src/main/scala/sbt/Load.scala +++ b/main/src/main/scala/sbt/Load.scala @@ -71,12 +71,19 @@ object Load { if (files.isEmpty || base == globalBase) const(Nil) else buildGlobalSettings(globalBase, files, config) config.copy(injectSettings = config.injectSettings.copy(projectLoaded = compiled)) } + // We are hiding a bug fix on global setting that was not importing auto imports. + // Because fixing this via https://github.com/sbt/sbt/pull/2399 + // breaks the source compatibility: https://github.com/sbt/sbt/issues/2415 + @deprecated("Remove this when we can break source compatibility.", "0.13.10") + private[sbt] def useAutoImportInGlobal = sys.props.get("sbt.global.autoimport") map { _.toLowerCase == "true" } getOrElse false def buildGlobalSettings(base: File, files: Seq[File], config: sbt.LoadBuildConfiguration): ClassLoader => Seq[Setting[_]] = { val eval = mkEval(data(config.globalPluginClasspath), base, defaultEvalOptions) val imports = BuildUtil.baseImports ++ - config.detectedGlobalPlugins.imports + (// when we can beak the source compat, remove this if and use config.detectedGlobalPlugins.imports + if (useAutoImportInGlobal) config.detectedGlobalPlugins.imports + else BuildUtil.importAllRoot(config.globalPluginNames)) loader => { val loaded = EvaluateConfigurations(eval, files, imports)(loader) diff --git a/notes/0.13.10.markdown b/notes/0.13.10.markdown index 572578a7a..eb252674d 100644 --- a/notes/0.13.10.markdown +++ b/notes/0.13.10.markdown @@ -95,6 +95,7 @@ - Fixes update option's `withLatestSnapshots` so it handles modules without an artifact. This flag will be enabled by default. [#1514][1514]/[#1616][1616]/[#2313][2313] by [@eed3si9n][@eed3si9n] - No longer passes `-J` options to the local Java compiler. [#1968][1968]/[#2272][2272] by [@Duhemm][@Duhemm] +- Fixes auto imports for auto plugins in global configuration files. Because this is *not* source compatible with 0.13.x, the fix is enabled only when `sbt.global.autoimport` flag is `true`. [#2120][2120]/[#2399][2399] by [@timcharper][@timcharper] ### Improvements @@ -148,7 +149,6 @@ - Fixes launcher configuration to add `sbt-ivy-snapshots` repository to resolve nightly builds. [@eed3si9n][@eed3si9n] - Fixes performance issues during tree traversal in the incremental compiler. [#2343][2343] by [@adriaanm][@adriaanm] - Fixes the tracking of self types and F-bounded existential types in the incremental compiler. [#2343][2343] by [@adriaanm][@adriaanm] -- Fixes autoImports for AutoPlugins for global configuration files. [#2120][2120]/[#2399][2399] by [@timcharper][@timcharper] ### Configurable Scala compiler bridge diff --git a/sbt/src/sbt-test/project/global-plugin/global/plugins/A.scala b/sbt/src/sbt-test/project/global-plugin/global/plugins/A.scala index bbf9fc243..b75a623b5 100644 --- a/sbt/src/sbt-test/project/global-plugin/global/plugins/A.scala +++ b/sbt/src/sbt-test/project/global-plugin/global/plugins/A.scala @@ -1,15 +1,5 @@ package test -import sbt._ - object Global { val x = 3 } - -object GlobalAutoPlugin extends AutoPlugin { - - object autoImport { - lazy val globalAutoPluginSetting = settingKey[String]("A top level setting declared in a plugin.") - } - -} diff --git a/sbt/src/sbt-test/project/global-settings/global/plugins/A.scala b/sbt/src/sbt-test/project/global-settings/global/plugins/A.scala new file mode 100644 index 000000000..ee7171f10 --- /dev/null +++ b/sbt/src/sbt-test/project/global-settings/global/plugins/A.scala @@ -0,0 +1,11 @@ +package test + +import sbt._ + +object GlobalAutoPlugin extends AutoPlugin { + + object autoImport { + lazy val globalAutoPluginSetting = settingKey[String]("A top level setting declared in a plugin.") + } + +} diff --git a/sbt/src/sbt-test/project/global-plugin/global/plugins/B.scala b/sbt/src/sbt-test/project/global-settings/global/plugins/B.scala similarity index 100% rename from sbt/src/sbt-test/project/global-plugin/global/plugins/B.scala rename to sbt/src/sbt-test/project/global-settings/global/plugins/B.scala diff --git a/sbt/src/sbt-test/project/global-plugin/global/useGlobalAutoPlugin.sbt b/sbt/src/sbt-test/project/global-settings/global/useGlobalAutoPlugin.sbt similarity index 100% rename from sbt/src/sbt-test/project/global-plugin/global/useGlobalAutoPlugin.sbt rename to sbt/src/sbt-test/project/global-settings/global/useGlobalAutoPlugin.sbt diff --git a/sbt/src/sbt-test/project/global-plugin/global/useGlobalLegacyPlugin.sbt b/sbt/src/sbt-test/project/global-settings/global/useGlobalLegacyPlugin.sbt similarity index 100% rename from sbt/src/sbt-test/project/global-plugin/global/useGlobalLegacyPlugin.sbt rename to sbt/src/sbt-test/project/global-settings/global/useGlobalLegacyPlugin.sbt diff --git a/sbt/src/sbt-test/project/global-settings/pending b/sbt/src/sbt-test/project/global-settings/pending new file mode 100644 index 000000000..1b6bd3c6f --- /dev/null +++ b/sbt/src/sbt-test/project/global-settings/pending @@ -0,0 +1,3 @@ +# This test is marked pending because sbt.globalsettingfix flag is off by default +# See https://github.com/sbt/sbt/issues/2415 +> name