From dfaf906684b3dbe74aff26457b4e900e8be8bb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Raddum=20Berg?= Date: Mon, 12 Apr 2021 03:10:25 +0200 Subject: [PATCH] Support sbt 1.5.x along with 1.4.x (Fixes #290) (#292) --- docs/library-developer.md | 3 +-- docs/plugin.md | 3 +-- release.sc | 4 ++-- .../plugin/ScalablyTypedPluginBase.scala | 16 ++++++++-------- .../react/external/project/build.properties | 2 +- .../sbt-test/react/external/project/plugins.sbt | 4 +--- .../sbt-test/react/japgolly/project/plugins.sbt | 4 +--- .../react/sourcegen/project/build.properties | 2 +- .../sbt-test/react/sourcegen/project/plugins.sbt | 3 +-- 9 files changed, 17 insertions(+), 24 deletions(-) diff --git a/docs/library-developer.md b/docs/library-developer.md index d3310faa49..221ec1d3f2 100644 --- a/docs/library-developer.md +++ b/docs/library-developer.md @@ -16,8 +16,7 @@ Have a look at [mobx-slinky](https://github.com/ScalablyTyped/mobx-slinky) ## Requirements -**This plugin needs sbt 1.4.x**. Not higher or lower. -This is unfortunate, but some more design work is needed to avoid this. +**This plugin needs sbt 1.4.x or 1.5.x**. Since we generate source code, it should work with any combination of Scala 2.12 / 2.13 and Scala.js 1.x. diff --git a/docs/plugin.md b/docs/plugin.md index 8a2cc88bec..a101c357e9 100644 --- a/docs/plugin.md +++ b/docs/plugin.md @@ -27,8 +27,7 @@ If you really want more than one conversion make sure to [shade](conversion-opti ## Requirements -**This plugin needs sbt 1.4.x**. Not higher or lower. -This is unfortunate, but some more design work is needed to avoid this. +**This plugin needs sbt 1.4.x or 1.5.x**. Since we generate source code, it should work with any combination of Scala 2.12 / 2.13 and Scala.js 1.x. diff --git a/release.sc b/release.sc index 424877e1eb..6208b9d52f 100644 --- a/release.sc +++ b/release.sc @@ -16,7 +16,7 @@ case class DemoRepo(repo: String, name: String)(implicit path: os.Path) { val pluginsFile = path / "project" / "plugins.sbt" val newLines = os.read.lines(pluginsFile).flatMap { case line if line.contains(s"""addSbtPlugin("org.scala-js" % "sbt-scalajs" %""") => - Some(s"""addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0")""") + Some(s"""addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1")""") case line if line.contains(s"""addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" %""") => Some(s"""addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0")""") case line if line.contains(s"""addSbtPlugin("org.scalablytyped.converter" % "sbt-converter" %""") => @@ -25,7 +25,7 @@ case class DemoRepo(repo: String, name: String)(implicit path: os.Path) { None case line => Some(line) } - os.write.over(path / "project" / "build.properties", "sbt.version=1.4.9") + os.write.over(path / "project" / "build.properties", "sbt.version=1.5.0") os.write.over(pluginsFile, newLines.mkString("\n")) %.sbt("compile", "dist") %.git("add", "-A") diff --git a/sbt-converter/src/main/scala/org/scalablytyped/converter/plugin/ScalablyTypedPluginBase.scala b/sbt-converter/src/main/scala/org/scalablytyped/converter/plugin/ScalablyTypedPluginBase.scala index 91aae26fcf..86bb50898f 100644 --- a/sbt-converter/src/main/scala/org/scalablytyped/converter/plugin/ScalablyTypedPluginBase.scala +++ b/sbt-converter/src/main/scala/org/scalablytyped/converter/plugin/ScalablyTypedPluginBase.scala @@ -102,14 +102,14 @@ object ScalablyTypedPluginBase extends AutoPlugin { override lazy val globalSettings = Seq( Global / Keys.onLoad := (state => { - val old = (Global / Keys.onLoad).value - val ret = old(state) - val sbtVersion = Keys.sbtVersion.value - val Supported = "1.4" - if (!sbtVersion.startsWith(Supported)) { - val msg = - s"This version of the ScalablyTyped plugin only supports sbt $Supported.x . You're currently using $sbtVersion" - sys.error(msg) + val old = (Global / Keys.onLoad).value + val ret = old(state) + Keys.sbtVersion.value match { + case valid if valid.startsWith("1.4") || valid.startsWith("1.5") => ret + case invalid => + sys.error( + s"This version of the ScalablyTyped plugin only supports sbt 1.4.x or 1.5.x. You're currently using $invalid", + ) } ret }), diff --git a/sbt-converter/src/sbt-test/react/external/project/build.properties b/sbt-converter/src/sbt-test/react/external/project/build.properties index c19c768d69..e67343ae79 100644 --- a/sbt-converter/src/sbt-test/react/external/project/build.properties +++ b/sbt-converter/src/sbt-test/react/external/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.2 +sbt.version=1.5.0 diff --git a/sbt-converter/src/sbt-test/react/external/project/plugins.sbt b/sbt-converter/src/sbt-test/react/external/project/plugins.sbt index b27d92655b..1952881d59 100644 --- a/sbt-converter/src/sbt-test/react/external/project/plugins.sbt +++ b/sbt-converter/src/sbt-test/react/external/project/plugins.sbt @@ -1,5 +1,3 @@ -resolvers += Resolver.bintrayRepo("oyvindberg", "converter") - { val pluginVersion = System.getProperty("plugin.version") if (pluginVersion == null) @@ -7,4 +5,4 @@ resolvers += Resolver.bintrayRepo("oyvindberg", "converter") |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) else addSbtPlugin("org.scalablytyped.converter" % """sbt-converter""" % pluginVersion) } -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") diff --git a/sbt-converter/src/sbt-test/react/japgolly/project/plugins.sbt b/sbt-converter/src/sbt-test/react/japgolly/project/plugins.sbt index a850fae889..f2c51e3acb 100644 --- a/sbt-converter/src/sbt-test/react/japgolly/project/plugins.sbt +++ b/sbt-converter/src/sbt-test/react/japgolly/project/plugins.sbt @@ -1,10 +1,8 @@ -resolvers += Resolver.bintrayRepo("oyvindberg", "converter") - val pluginVersion = System.getProperty("plugin.version") if (pluginVersion == null) throw new RuntimeException("""|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) else addSbtPlugin("org.scalablytyped.converter" % """sbt-converter""" % pluginVersion) -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") diff --git a/sbt-converter/src/sbt-test/react/sourcegen/project/build.properties b/sbt-converter/src/sbt-test/react/sourcegen/project/build.properties index c19c768d69..e67343ae79 100644 --- a/sbt-converter/src/sbt-test/react/sourcegen/project/build.properties +++ b/sbt-converter/src/sbt-test/react/sourcegen/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.2 +sbt.version=1.5.0 diff --git a/sbt-converter/src/sbt-test/react/sourcegen/project/plugins.sbt b/sbt-converter/src/sbt-test/react/sourcegen/project/plugins.sbt index a850fae889..c4d0342f9c 100644 --- a/sbt-converter/src/sbt-test/react/sourcegen/project/plugins.sbt +++ b/sbt-converter/src/sbt-test/react/sourcegen/project/plugins.sbt @@ -1,4 +1,3 @@ -resolvers += Resolver.bintrayRepo("oyvindberg", "converter") val pluginVersion = System.getProperty("plugin.version") if (pluginVersion == null) @@ -6,5 +5,5 @@ if (pluginVersion == null) |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) else addSbtPlugin("org.scalablytyped.converter" % """sbt-converter""" % pluginVersion) -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.3.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0")