Skip to content

Commit d51bda8

Browse files
Hotfix for SBT plugin
SBT plugin attempts to obtain the version of the latest nightly build from the Dotty website. Sometimes, on release, this version is set on the website before the actual nightly publish takes place, which leads to an exception. This commit is a hotfix instructing the plugin to fall back to the latest published version of Dotty.
1 parent a54d6f0 commit d51bda8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,18 @@ object DottyPlugin extends AutoPlugin {
2828
val nightly = try {
2929
// get majorVersion from dotty.epfl.ch
3030
val source0 = Source.fromURL("http://dotty.epfl.ch/versions/latest-nightly-base")
31-
val majorVersion = source0.getLines().toSeq.head
31+
val majorVersionFromWebsite = source0.getLines().toSeq.head
3232
source0.close()
3333

3434
// get latest nightly version from maven
35-
val source1 =
36-
Source.fromURL(s"http://repo1.maven.org/maven2/ch/epfl/lamp/dotty_$majorVersion/maven-metadata.xml")
35+
def fetchSource(version: String): (scala.io.BufferedSource, String) =
36+
try Source.fromURL(s"http://repo1.maven.org/maven2/ch/epfl/lamp/dotty_$version/maven-metadata.xml") -> version
37+
catch { case t: java.io.FileNotFoundException =>
38+
val major :: minor :: Nil = version.split(".").toList
39+
if (minor.toInt <= 0) throw t
40+
else fetchSource(s"$major.${minor.toInt - 1}")
41+
}
42+
val (source1, majorVersion) = fetchSource(majorVersionFromWebsite)
3743
val Version = s" <version>($majorVersion\\..*-bin.*)</version>".r
3844
val nightly = source1
3945
.getLines()

0 commit comments

Comments
 (0)