Skip to content

Commit 43c65cf

Browse files
committed
Update dottyLatestNightlyBuild to use major version from dotty.epfl.ch
1 parent 1897241 commit 43c65cf

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ object Build {
858858

859859

860860
sbtPlugin := true,
861-
version := "0.1.6",
861+
version := "0.1.7",
862862
ScriptedPlugin.scriptedSettings,
863863
ScriptedPlugin.sbtTestDirectory := baseDirectory.value / "sbt-test",
864864
ScriptedPlugin.scriptedLaunchOpts += "-Dplugin.version=" + version.value,

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

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,39 @@ object DottyPlugin extends AutoPlugin {
1313
// - if this was a taskKey, then you couldn't do `scalaVersion := dottyLatestNightlyBuild`
1414
// - if this was a settingKey, then this would evaluate even if you don't use it.
1515
def dottyLatestNightlyBuild: Option[String] = {
16-
println("Fetching latest Dotty nightly version (requires an internet connection)...")
17-
val Version = """ <version>(0.5\..*-bin.*)</version>""".r
18-
val latest = scala.io.Source
19-
.fromURL(
20-
"http://repo1.maven.org/maven2/ch/epfl/lamp/dotty_0.5/maven-metadata.xml")
21-
.getLines()
22-
.collect { case Version(version) => version }
23-
.toSeq
24-
.lastOption
25-
println(s"Latest Dotty nightly build version: $latest")
26-
latest
16+
println("Fetching latest Dotty nightly version...")
17+
18+
val nightly = try {
19+
// get majorVersion from dotty.epfl.ch/versions
20+
val in = new java.net.URL("http://dotty.epfl.ch/versions").openStream()
21+
val versions = new java.util.Properties()
22+
versions.load(in)
23+
in.close()
24+
val baseVersion = versions.getProperty("baseVersion")
25+
val majorVersion = baseVersion.take(baseVersion.lastIndexOf('.'))
26+
27+
// get latest nightly version from maven
28+
val Version = s" <version>($majorVersion\\..*-bin.*)</version>".r
29+
scala.io.Source
30+
.fromURL(
31+
s"http://repo1.maven.org/maven2/ch/epfl/lamp/dotty_$majorVersion/maven-metadata.xml")
32+
.getLines()
33+
.collect { case Version(version) => version }
34+
.toSeq
35+
.lastOption
36+
} catch {
37+
case _: java.io.IOException =>
38+
None
39+
}
40+
41+
nightly match {
42+
case Some(version) =>
43+
println(s"Latest Dotty nightly build version: $version")
44+
case None =>
45+
println(s"Unable to get Dotty latest nightly build version. Make sure you are connected to internet")
46+
}
47+
48+
nightly
2749
}
2850

2951
implicit class DottyCompatModuleID(moduleID: ModuleID) {

0 commit comments

Comments
 (0)