@@ -12,18 +12,41 @@ object DottyPlugin extends AutoPlugin {
12
12
// - this is a def to support `scalaVersion := dottyLatestNightlyBuild`
13
13
// - if this was a taskKey, then you couldn't do `scalaVersion := dottyLatestNightlyBuild`
14
14
// - if this was a settingKey, then this would evaluate even if you don't use it.
15
- 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" )
15
+ def dottyLatestNightlyBuild (): Option [String ] = {
16
+ import scala .io .Source
17
+
18
+ println(" Fetching latest Dotty nightly version..." )
19
+
20
+ val nightly = try {
21
+ // get majorVersion from dotty.epfl.ch
22
+ val source0 = Source .fromURL(" http://dotty.epfl.ch/versions/latest-nightly-base" )
23
+ val majorVersion = source0.getLines().toSeq.head
24
+ source0.close()
25
+
26
+ // get latest nightly version from maven
27
+ val source1 =
28
+ Source .fromURL(s " http://repo1.maven.org/maven2/ch/epfl/lamp/dotty_ $majorVersion/maven-metadata.xml " )
29
+ val Version = s " <version>( $majorVersion\\ ..*-bin.*)</version> " .r
30
+ val nightly = source1
21
31
.getLines()
22
32
.collect { case Version (version) => version }
23
33
.toSeq
24
34
.lastOption
25
- println(s " Latest Dotty nightly build version: $latest" )
26
- latest
35
+ source1.close()
36
+ nightly
37
+ } catch {
38
+ case _:java.net.UnknownHostException =>
39
+ None
40
+ }
41
+
42
+ nightly match {
43
+ case Some (version) =>
44
+ println(s " Latest Dotty nightly build version: $version" )
45
+ case None =>
46
+ println(s " Unable to get Dotty latest nightly build version. Make sure you are connected to internet " )
47
+ }
48
+
49
+ nightly
27
50
}
28
51
29
52
implicit class DottyCompatModuleID (moduleID : ModuleID ) {
0 commit comments