From cd0461e301c1c7fbb75a55e143bd1a9bc3fd533a Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Tue, 4 Jun 2019 21:34:31 -0700 Subject: [PATCH] Improve reload warnings I decided creations/deletions/updates were a bit too technical rather than descriptive. It also wasn't really correct to say Meta build sources because the meta build is the build for the build. Instead, I dropped Meta from the sentence. I also made the instructions when changed sources are detected more active. I left them capitalized since they are instructions rather than warnings. Apply these changes by running `reload`. Automatically reload the build when source changes are detected by setting `Global / onChangedBuildSource := ReloadOnSourceChanges`. Disable this warning by setting `Global / onChangedBuildSource := IgnoreSourceChanges`. Also indentation was wrong for the printed files when multiple files had changed because the mkString middle argument was " \n" rather than "\n ". --- .../sbt/internal/nio/CheckBuildSources.scala | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main/src/main/scala/sbt/internal/nio/CheckBuildSources.scala b/main/src/main/scala/sbt/internal/nio/CheckBuildSources.scala index 7e8f131ad..289a50d17 100644 --- a/main/src/main/scala/sbt/internal/nio/CheckBuildSources.scala +++ b/main/src/main/scala/sbt/internal/nio/CheckBuildSources.scala @@ -25,22 +25,24 @@ private[sbt] object CheckBuildSources { logger.debug("Checking for meta build source updates") (changedInputFiles in checkBuildSources).value match { case Some(cf: ChangedFiles) if !firstTime => - val rawPrefix = s"Meta build source files have changed:\n" + - (if (cf.created.nonEmpty) s"creations: ${cf.created.mkString("\n ", " \n", "\n")}" + val rawPrefix = s"build source files have changed\n" + + (if (cf.created.nonEmpty) s"new files: ${cf.created.mkString("\n ", "\n ", "\n")}" else "") + - (if (cf.deleted.nonEmpty) s"deletions: ${cf.deleted.mkString("\n ", " \n", "\n")}" + (if (cf.deleted.nonEmpty) + s"deleted files: ${cf.deleted.mkString("\n ", "\n ", "\n")}" else "") + - (if (cf.updated.nonEmpty) s"updates: ${cf.updated.mkString("\n ", " \n", "\n")}" + (if (cf.updated.nonEmpty) + s"updated files: ${cf.updated.mkString("\n ", "\n ", "\n")}" else "") val prefix = rawPrefix.linesIterator.filterNot(_.trim.isEmpty).mkString("\n") if (o == ReloadOnSourceChanges) { logger.info(s"$prefix\nReloading sbt...") throw Reload } else { - val tail = "Reload sbt with the 'reload' command to apply these changes. " + - "To automatically reload upon meta build source changed detection, set " + - "`Global / onChangedBuildSource := ReloadOnSourceChanges`. To disable this " + - "warning, set `Global / onChangedBuildSource := IgnoreSourceChanges`" + val tail = "Apply these changes by running `reload`.\nAutomatically reload the " + + "build when source changes are detected by setting " + + "`Global / onChangedBuildSource := ReloadOnSourceChanges`.\nDisable this " + + "warning by setting `Global / onChangedBuildSource := IgnoreSourceChanges`." logger.warn(s"$prefix\n$tail") } case _ => ()