Skip to content

Publish Dotty baseVersion when generating Documentation #3376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(":")
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
39 changes: 31 additions & 8 deletions sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """ <version>(0.5\..*-bin.*)</version>""".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" <version>($majorVersion\\..*-bin.*)</version>".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) {
Expand Down