diff --git a/project/Build.scala b/project/Build.scala index 45405a1cf0d2..0e28abc47f51 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -36,12 +36,12 @@ object ExposedValues extends AutoPlugin { object Build { + val baseVersion = "0.5.0" val scalacVersion = "2.12.4" val dottyOrganization = "ch.epfl.lamp" val dottyGithubUrl = "https://github.com/lampepfl/dotty" val dottyVersion = { - val baseVersion = "0.5.0" val isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes") val isRelease = sys.env.get("RELEASEBUILD") == Some("yes") if (isNightly) @@ -308,6 +308,11 @@ object Build { parallelExecution in Test := false, genDocs := Def.taskDyn { + // Make majorVersion available at dotty.epfl.ch/versions/latest-nightly-base + // Used by sbt-dotty to resolve the latest nightly + val majorVersion = baseVersion.take(baseVersion.lastIndexOf('.')) + IO.write(file("./docs/_site/versions/latest-nightly-base"), majorVersion) + val dottyLib = (packageAll in `dotty-compiler`).value("dotty-library") val dottyInterfaces = (packageAll in `dotty-compiler`).value("dotty-interfaces") val otherDeps = (dependencyClasspath in Compile).value.map(_.data).mkString(":") @@ -321,9 +326,9 @@ object Build { "-project-url", dottyGithubUrl, "-classpath", s"$dottyLib:$dottyInterfaces:$otherDeps" ) - (runMain in Compile).toTask( - s""" dotty.tools.dottydoc.Main ${args.mkString(" ")} ${sources.mkString(" ")}""" - ) + (runMain in Compile).toTask( + s""" dotty.tools.dottydoc.Main ${args.mkString(" ")} ${sources.mkString(" ")}""" + ) }.value, dottydoc := Def.inputTaskDyn { @@ -855,7 +860,7 @@ object Build { sbtPlugin := true, - version := "0.1.6", + version := "0.1.7", ScriptedPlugin.scriptedSettings, ScriptedPlugin.sbtTestDirectory := baseDirectory.value / "sbt-test", ScriptedPlugin.scriptedLaunchOpts += "-Dplugin.version=" + version.value, diff --git a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala index ab424718d773..04b87f8004a4 100644 --- a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala +++ b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala @@ -12,18 +12,41 @@ object DottyPlugin extends AutoPlugin { // - this is a def to support `scalaVersion := dottyLatestNightlyBuild` // - if this was a taskKey, then you couldn't do `scalaVersion := dottyLatestNightlyBuild` // - if this was a settingKey, then this would evaluate even if you don't use it. - def dottyLatestNightlyBuild: Option[String] = { - println("Fetching latest Dotty nightly version (requires an internet connection)...") - val Version = """ (0.5\..*-bin.*)""".r - val latest = scala.io.Source - .fromURL( - "http://repo1.maven.org/maven2/ch/epfl/lamp/dotty_0.5/maven-metadata.xml") + def dottyLatestNightlyBuild(): Option[String] = { + import scala.io.Source + + println("Fetching latest Dotty nightly version...") + + val nightly = try { + // get majorVersion from dotty.epfl.ch + val source0 = Source.fromURL("http://dotty.epfl.ch/versions/latest-nightly-base") + val majorVersion = source0.getLines().toSeq.head + source0.close() + + // get latest nightly version from maven + val source1 = + Source.fromURL(s"http://repo1.maven.org/maven2/ch/epfl/lamp/dotty_$majorVersion/maven-metadata.xml") + val Version = s" ($majorVersion\\..*-bin.*)".r + val nightly = source1 .getLines() .collect { case Version(version) => version } .toSeq .lastOption - println(s"Latest Dotty nightly build version: $latest") - latest + source1.close() + nightly + } catch { + case _:java.net.UnknownHostException => + None + } + + nightly match { + case Some(version) => + println(s"Latest Dotty nightly build version: $version") + case None => + println(s"Unable to get Dotty latest nightly build version. Make sure you are connected to internet") + } + + nightly } implicit class DottyCompatModuleID(moduleID: ModuleID) {