From 2283c68031732751b2488d3571f3bf68a6694178 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 10 Jan 2017 16:56:11 +0100 Subject: [PATCH] Automatically choose proper compiler bridge for dotty Before this commit, using dotty in your sbt project required to add: scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-sbt-bridge" % scalaVersion.value % "component").sources() in your build.sbt. We might as well automatically do this, this reduces the boilerplate for using dotty in your project to: scalaOrganization := "ch.epfl.lamp" scalaVersion := "0.1.1-SNAPSHOT" scalaBinaryVersion := "2.11" // dotty itself is only published as a // 2.11 artefact currently --- main/src/main/scala/sbt/Defaults.scala | 7 ++++++- notes/0.13.14/dotty_bridge.md | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 notes/0.13.14/dotty_bridge.md diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index fb7d4e07e..300026bbd 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -283,7 +283,12 @@ object Defaults extends BuildCommon { val _ = clean.value IvyActions.cleanCachedResolutionCache(ivyModule.value, streams.value.log) }, - scalaCompilerBridgeSource := Compiler.defaultCompilerBridgeSource(scalaVersion.value) + scalaCompilerBridgeSource := { + if (ScalaInstance.isDotty(scalaVersion.value)) + // Maintained at https://github.com/lampepfl/dotty/tree/master/sbt-bridge + ModuleID(scalaOrganization.value, "dotty-sbt-bridge", scalaVersion.value).withConfigurations(Some("component")).sources() + else Compiler.defaultCompilerBridgeSource(scalaVersion.value) + } ) // must be a val: duplication detected by object identity private[this] lazy val compileBaseGlobal: Seq[Setting[_]] = globalDefaults(Seq( diff --git a/notes/0.13.14/dotty_bridge.md b/notes/0.13.14/dotty_bridge.md new file mode 100644 index 000000000..3902ae3c5 --- /dev/null +++ b/notes/0.13.14/dotty_bridge.md @@ -0,0 +1,11 @@ +### Improvements + +- When sbt detects that the project is compiled with dotty, it now automatically + set `scalaCompilerBridgeSource` correctly, this reduces the boilerplate needed + to make a dotty project. Note that dotty support in sbt is still considered + experimental and not officially supported, see [dotty.epfl.ch][dotty] for + more information. [#2902][2902] by [@smarter][@smarter] + + [dotty]: http://dotty.epfl.ch/ + [2902]: https://github.com/sbt/sbt/pull/2902 + [@smarter]: https://github.com/smarter