From c44ba4feaceacc309c37e8cdee372b97a28a4f1e Mon Sep 17 00:00:00 2001 From: Allan Renucci Date: Mon, 16 Apr 2018 19:21:34 +0200 Subject: [PATCH] Exit sbt when Dotty plugin is incompatible with sbt version --- project/Build.scala | 2 +- .../src/dotty/tools/sbtplugin/DottyPlugin.scala | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/project/Build.scala b/project/Build.scala index eaca19bdc07a..52e47bafa423 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -864,7 +864,7 @@ object Build { settings(commonSettings). settings( version := { - val base = "0.2.0" + val base = "0.2.1" if (isRelease) base else base + "-SNAPSHOT" }, diff --git a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala index c069d7e4c500..45768ac0d5a8 100644 --- a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala +++ b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala @@ -141,6 +141,18 @@ object DottyPlugin extends AutoPlugin { incOptions.withExternalHooks(hooks) } + override val globalSettings: Seq[Def.Setting[_]] = Seq( + onLoad in Global := onLoad.in(Global).value.andThen { state => + val sbtV = sbtVersion.value + sbtFullVersion(sbtV) match { + case Some((1, sbtMinor, sbtPatch)) if sbtMinor > 1 || (sbtMinor == 1 && sbtPatch >= 4) => + case _ => + sys.error(s"The sbt-dotty plugin cannot work with this version of sbt ($sbtV), sbt >= 1.1.4 is required.") + } + state + } + ) + override def projectSettings: Seq[Setting[_]] = { Seq( isDotty := scalaVersion.value.startsWith("0."),