diff --git a/.drone.yml b/.drone.yml
index aa248459bcb1..3ee1d1692643 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -40,7 +40,7 @@ matrix:
CI_PUBLISH: true
- CI_TEST: legacyTests
CI_PUBLISH: false
- - CI_TEST: test
+ - CI_TEST: ;test;sbt-dotty/scripted
CI_PUBLISH: false
- CI_TEST: ;dotty-sbt-bridge/publishLocal ;dotty-bootstrapped/test
CI_PUBLISH: false
diff --git a/.drone.yml.sig b/.drone.yml.sig
index 0f138bd1b38d..7326e3c23fb2 100644
--- a/.drone.yml.sig
+++ b/.drone.yml.sig
@@ -1 +1 @@
-eyJhbGciOiJIUzI1NiJ9.IyBBZnRlciB1cGRhdGluZyB0aGlzIGZpbGUsIHlvdSBuZWVkIHRvIHJlLXNpZ24gaXQ6CiMKIyAtIEluc3RhbGwgW2Ryb25lLWNsaV0oaHR0cDovL3JlYWRtZS5kcm9uZS5pby91c2FnZS9nZXR0aW5nLXN0YXJ0ZWQtY2xpLykKIyAtIENvcHkgeW91ciB0b2tlbiBmcm9tICBodHRwOi8vZG90dHktY2kuZXBmbC5jaC9hY2NvdW50IChDbGljayBTSE9XIFRPS0VOKQojIC0gKGV4cG9ydCBEUk9ORV9UT0tFTj15b3VyLXRva2VuOyBleHBvcnQgRFJPTkVfU0VSVkVSPWh0dHA6Ly9kb3R0eS1jaS5lcGZsLmNoOyBkcm9uZSBzaWduIGxhbXBlcGZsL2RvdHR5KQojCiMgUGxlYXNlIG5vdGUgdGhhdCB0aGUgc2lnbmluZyBjYW4gb25seSBiZSBkb25lIGJ5IGNvbGxhYm9yYXRvcnMuCgpwaXBlbGluZToKICB0ZXN0OgogICAgaW1hZ2U6IGxhbXBlcGZsL2RvdHR5OjI0LTA0LTIwMTcKICAgIHB1bGw6IHRydWUKICAgIGNvbW1hbmRzOgogICAgICAtIGxuIC1zIC92YXIvY2FjaGUvZHJvbmUvc2NhbGEtc2NhbGEgc2NhbGEtc2NhbGEKICAgICAgLSBsbiAtcyA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gICAgIGV4Y2x1ZGU6IGdoLXBhZ2VzCgogIGRvY3VtZW50YXRpb246CiAgICBpbWFnZTogbGFtcGVwZmwvZG90dHk6MjQtMDQtMjAxNwogICAgcHVsbDogdHJ1ZQogICAgY29tbWFuZHM6CiAgICAgIC0gLi9wcm9qZWN0L3NjcmlwdHMvZ2VuRG9jcyAiJHtDSV9QVUJMSVNIfSIgJEJPVF9QQVNTCiAgICB3aGVuOgogICAgICBicmFuY2g6IG1hc3RlcgoKICBzbGFjazoKICAgIGltYWdlOiBwbHVnaW5zL3NsYWNrCiAgICBjaGFubmVsOiBkb3R0eQogICAgd2hlbjoKICAgICAgYnJhbmNoOiBtYXN0ZXIKICAgICAgc3RhdHVzOiBjaGFuZ2VkCgptYXRyaXg6CiAgaW5jbHVkZToKICAgIC0gQ0lfVEVTVDogZG90dHktYmluLXRlc3RzL3Rlc3QKICAgICAgQ0lfUFVCTElTSDogdHJ1ZQogICAgLSBDSV9URVNUOiBsZWdhY3lUZXN0cwogICAgICBDSV9QVUJMSVNIOiBmYWxzZQogICAgLSBDSV9URVNUOiA7dGVzdDtzYnQtZG90dHkvc2NyaXB0ZWQKICAgICAgQ0lfUFVCTElTSDogZmFsc2UKICAgIC0gQ0lfVEVTVDogO2RvdHR5LXNidC1icmlkZ2UvcHVibGlzaExvY2FsIDtkb3R0eS1ib290c3RyYXBwZWQvdGVzdAogICAgICBDSV9QVUJMSVNIOiBmYWxzZQo.g6eg6JBtlJFjOb9oCS6kzRJ3E1Df5gV8LVksXBmFDq8
\ No newline at end of file
diff --git a/build.sbt b/build.sbt
index dfe0ea4ac965..cb8c4fe8df41 100644
--- a/build.sbt
+++ b/build.sbt
@@ -19,4 +19,6 @@ val `scala-compiler` = Build.`scala-compiler`
val `scala-reflect` = Build.`scala-reflect`
val scalap = Build.scalap
+val `sbt-dotty` = Build.`sbt-dotty`
+
inThisBuild(Build.thisBuildSettings)
diff --git a/docs/_includes/getting-started.html b/docs/_includes/getting-started.html
index 00b7c869cef1..c6493d40e9e2 100644
--- a/docs/_includes/getting-started.html
+++ b/docs/_includes/getting-started.html
@@ -2,29 +2,7 @@
Getting Started
- Using Dotty to compile your project is now pretty simple. Create the
- following structure:
-
-
-.
-├── build.sbt
-├── project
-│ ├── build.properties
-│ └── plugins.sbt
-└── src
-
build.sbt
-
name := "application"
-version := "0.1"
-enablePlugins(DottyPlugin)
-
build.properties
-
sbt.version=0.13.11
-
plugins.sbt
-
addSbtPlugin("com.felixmulder" % "sbt-dotty" % "0.1.7")
-
- This plugin is based on the
-
- dotty-example-project
- , but let’s you skip building dotty from scratch.
+ See the example project.
diff --git a/docs/docs/usage/sbt-projects.md b/docs/docs/usage/sbt-projects.md
index 2f27492a7b93..d00f18290207 100644
--- a/docs/docs/usage/sbt-projects.md
+++ b/docs/docs/usage/sbt-projects.md
@@ -3,10 +3,4 @@ layout: doc-page
title: "Using Dotty with sbt"
---
-It is now possible to use Dotty with sbt thanks to the dotty-bridge project.
-There are two alternatives in how to create an sbt project that uses dotty:
-
-* [dotty-example-project](https://github.com/smarter/dotty-example-project)
- for a simple sbt project that compiles code with Dotty
-* [sbt-dotty](https://github.com/felixmulder/sbt-dotty) an sbt plugin that
- takes care of all dependencies and settings needed to get a Dotty sbt project
+See the [example project](https://github.com/lampepfl/dotty-example-project).
diff --git a/project/Build.scala b/project/Build.scala
index 5da8d8549581..9943f8395a84 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -844,6 +844,20 @@ object DottyInjectedPlugin extends AutoPlugin {
libraryDependencies := Seq("org.scala-lang" % "scalap" % scalacVersion)
)
+
+ // sbt plugin to use Dotty in your own build, see
+ // https://github.com/lampepfl/dotty-example-project for usage.
+ lazy val `sbt-dotty` = project.in(file("sbt-dotty")).
+ settings(commonSettings).
+ settings(
+ sbtPlugin := true,
+ version := "0.1.0-RC4",
+ ScriptedPlugin.scriptedSettings,
+ ScriptedPlugin.sbtTestDirectory := baseDirectory.value / "sbt-test",
+ ScriptedPlugin.scriptedBufferLog := false,
+ ScriptedPlugin.scriptedLaunchOpts += "-Dplugin.version=" + version.value
+ )
+
lazy val publishSettings = Seq(
publishMavenStyle := true,
isSnapshot := version.value.contains("SNAPSHOT"),
diff --git a/sbt-dotty/sbt-test/sbt-dotty/example-project/build.sbt b/sbt-dotty/sbt-test/sbt-dotty/example-project/build.sbt
new file mode 100644
index 000000000000..8e59ff23cb87
--- /dev/null
+++ b/sbt-dotty/sbt-test/sbt-dotty/example-project/build.sbt
@@ -0,0 +1,3 @@
+scalaVersion := dottyLatestNightlyBuild.get
+
+libraryDependencies += ("org.scala-lang.modules" %% "scala-xml" % "1.0.1").withDottyCompat()
diff --git a/sbt-dotty/sbt-test/sbt-dotty/example-project/project/build.properties b/sbt-dotty/sbt-test/sbt-dotty/example-project/project/build.properties
new file mode 100644
index 000000000000..64317fdae59f
--- /dev/null
+++ b/sbt-dotty/sbt-test/sbt-dotty/example-project/project/build.properties
@@ -0,0 +1 @@
+sbt.version=0.13.15
diff --git a/sbt-dotty/sbt-test/sbt-dotty/example-project/project/plugins.sbt b/sbt-dotty/sbt-test/sbt-dotty/example-project/project/plugins.sbt
new file mode 100644
index 000000000000..c17caab2d98c
--- /dev/null
+++ b/sbt-dotty/sbt-test/sbt-dotty/example-project/project/plugins.sbt
@@ -0,0 +1 @@
+addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % sys.props("plugin.version"))
diff --git a/sbt-dotty/sbt-test/sbt-dotty/example-project/src/main/scala/hello/Hello.scala b/sbt-dotty/sbt-test/sbt-dotty/example-project/src/main/scala/hello/Hello.scala
new file mode 100644
index 000000000000..79c1971ce830
--- /dev/null
+++ b/sbt-dotty/sbt-test/sbt-dotty/example-project/src/main/scala/hello/Hello.scala
@@ -0,0 +1,7 @@
+package hello
+object Hello {
+ def main(args: Array[String]): Unit = {
+ val dotty: Int | String = "dotty"
+ println(s"Hello $dotty!")
+ }
+}
diff --git a/sbt-dotty/sbt-test/sbt-dotty/example-project/test b/sbt-dotty/sbt-test/sbt-dotty/example-project/test
new file mode 100644
index 000000000000..62ea636c177f
--- /dev/null
+++ b/sbt-dotty/sbt-test/sbt-dotty/example-project/test
@@ -0,0 +1 @@
+> run
diff --git a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala
new file mode 100644
index 000000000000..31ca1cfd9f7c
--- /dev/null
+++ b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala
@@ -0,0 +1,104 @@
+package dotty.tools.sbtplugin
+
+import sbt._
+import sbt.Keys._
+
+object DottyPlugin extends AutoPlugin {
+ object autoImport {
+ val isDotty = settingKey[Boolean]("Is this project compiled with Dotty?")
+
+ // NOTE:
+ // - 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.1\..*-bin.*)""".r
+ val latest = scala.io.Source
+ .fromURL(
+ "http://repo1.maven.org/maven2/ch/epfl/lamp/dotty_0.1/maven-metadata.xml")
+ .getLines()
+ .collect { case Version(version) => version }
+ .toSeq
+ .lastOption
+ println(s"Latest Dotty nightly build version: $latest")
+ latest
+ }
+
+ implicit class DottyCompatModuleID(moduleID: ModuleID) {
+ /** If this ModuleID cross-version is a Dotty version, replace it
+ * by the Scala 2.x version that the Dotty version is retro-compatible with.
+ *
+ * This setting is useful when your build contains dependencies that have only
+ * been published with Scala 2.x, if you have:
+ * {{{
+ * libraryDependencies += "a" %% "b" % "c"
+ * }}}
+ * you can replace it by:
+ * {{{
+ * libraryDependencies += ("a" %% "b" % "c").withDottyCompat()
+ * }}}
+ * This will have no effect when compiling with Scala 2.x, but when compiling
+ * with Dotty this will change the cross-version to a Scala 2.x one. This
+ * works because Dotty is currently retro-compatible with Scala 2.x.
+ *
+ * NOTE: Dotty's retro-compatibility with Scala 2.x will be dropped before
+ * Dotty is released, you should not rely on it.
+ */
+ def withDottyCompat(): ModuleID =
+ moduleID.cross(CrossVersion.binaryMapped {
+ case version if version.startsWith("0.") => "2.11"
+ case version => version
+ })
+ }
+ }
+
+ import autoImport._
+
+ override def requires: Plugins = plugins.JvmPlugin
+ override def trigger = allRequirements
+
+ // Adapted from CrossVersionUtil#sbtApiVersion
+ private def sbtFullVersion(v: String): Option[(Int, Int, Int)] =
+ {
+ val ReleaseV = """(\d+)\.(\d+)\.(\d+)(-\d+)?""".r
+ val CandidateV = """(\d+)\.(\d+)\.(\d+)(-RC\d+)""".r
+ val NonReleaseV = """(\d+)\.(\d+)\.(\d+)([-\w+]*)""".r
+ v match {
+ case ReleaseV(x, y, z, ht) => Some((x.toInt, y.toInt, z.toInt))
+ case CandidateV(x, y, z, ht) => Some((x.toInt, y.toInt, z.toInt))
+ case NonReleaseV(x, y, z, ht) if z.toInt > 0 => Some((x.toInt, y.toInt, z.toInt))
+ case _ => None
+ }
+ }
+
+
+ override def projectSettings: Seq[Setting[_]] = {
+ Seq(
+ isDotty := {
+ val log = sLog.value
+
+ sbtFullVersion(sbtVersion.value) match {
+ case Some((sbtMajor, sbtMinor, sbtPatch)) if sbtMajor == 0 && sbtMinor == 13 && sbtPatch < 15 =>
+ log.error(s"The sbt-dotty plugin cannot work with this version of sbt (${sbtVersion.value}), sbt >= 0.13.15 is required.")
+ false
+ case _ =>
+ scalaVersion.value.startsWith("0.")
+ }
+ },
+ scalaOrganization := {
+ if (isDotty.value)
+ "ch.epfl.lamp"
+ else
+ scalaOrganization.value
+ },
+
+ scalaBinaryVersion := {
+ if (isDotty.value)
+ "0.1" // TODO: Fix sbt so that this isn't needed
+ else
+ scalaBinaryVersion.value
+ }
+ )
+ }
+}