Skip to content

Commit ec54e63

Browse files
authored
Merge pull request #3376 from dotty-staging/fix-#2806
Publish Dotty baseVersion when generating Documentation
2 parents 0d22181 + 04fb48c commit ec54e63

File tree

2 files changed

+41
-13
lines changed

2 files changed

+41
-13
lines changed

project/Build.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ object ExposedValues extends AutoPlugin {
3636

3737
object Build {
3838

39+
val baseVersion = "0.5.0"
3940
val scalacVersion = "2.12.4"
4041

4142
val dottyOrganization = "ch.epfl.lamp"
4243
val dottyGithubUrl = "https://github.com/lampepfl/dotty"
4344
val dottyVersion = {
44-
val baseVersion = "0.5.0"
4545
val isNightly = sys.env.get("NIGHTLYBUILD") == Some("yes")
4646
val isRelease = sys.env.get("RELEASEBUILD") == Some("yes")
4747
if (isNightly)
@@ -308,6 +308,11 @@ object Build {
308308
parallelExecution in Test := false,
309309

310310
genDocs := Def.taskDyn {
311+
// Make majorVersion available at dotty.epfl.ch/versions/latest-nightly-base
312+
// Used by sbt-dotty to resolve the latest nightly
313+
val majorVersion = baseVersion.take(baseVersion.lastIndexOf('.'))
314+
IO.write(file("./docs/_site/versions/latest-nightly-base"), majorVersion)
315+
311316
val dottyLib = (packageAll in `dotty-compiler`).value("dotty-library")
312317
val dottyInterfaces = (packageAll in `dotty-compiler`).value("dotty-interfaces")
313318
val otherDeps = (dependencyClasspath in Compile).value.map(_.data).mkString(":")
@@ -321,9 +326,9 @@ object Build {
321326
"-project-url", dottyGithubUrl,
322327
"-classpath", s"$dottyLib:$dottyInterfaces:$otherDeps"
323328
)
324-
(runMain in Compile).toTask(
325-
s""" dotty.tools.dottydoc.Main ${args.mkString(" ")} ${sources.mkString(" ")}"""
326-
)
329+
(runMain in Compile).toTask(
330+
s""" dotty.tools.dottydoc.Main ${args.mkString(" ")} ${sources.mkString(" ")}"""
331+
)
327332
}.value,
328333

329334
dottydoc := Def.inputTaskDyn {
@@ -855,7 +860,7 @@ object Build {
855860

856861

857862
sbtPlugin := true,
858-
version := "0.1.6",
863+
version := "0.1.7",
859864
ScriptedPlugin.scriptedSettings,
860865
ScriptedPlugin.sbtTestDirectory := baseDirectory.value / "sbt-test",
861866
ScriptedPlugin.scriptedLaunchOpts += "-Dplugin.version=" + version.value,

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,41 @@ object DottyPlugin extends AutoPlugin {
1212
// - this is a def to support `scalaVersion := dottyLatestNightlyBuild`
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.
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
2131
.getLines()
2232
.collect { case Version(version) => version }
2333
.toSeq
2434
.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
2750
}
2851

2952
implicit class DottyCompatModuleID(moduleID: ModuleID) {

0 commit comments

Comments
 (0)