From 1d10d31f24a199ec3b5cf1bb39d9d19ff2046dda Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 28 Aug 2018 17:56:21 +0900 Subject: [PATCH 1/3] Upgrade to sbt 1.2.3 We cannot use sbtVersion.value for compiler-interface and zinc-api-info anymore because sbt 1.2.3 uses Zinc 1.2.2 --- project/Build.scala | 21 +++++++-------------- project/Dependencies.scala | 5 +++-- project/build.properties | 2 +- project/inject-sbt-dotty.sbt | 2 +- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 8ada0ccab0a8..7b984cf2aef3 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -10,6 +10,7 @@ import complete.DefaultParsers._ import pl.project13.scala.sbt.JmhPlugin import pl.project13.scala.sbt.JmhPlugin.JmhKeys.Jmh import sbt.Package.ManifestAttributes +import sbt.plugins.SbtPlugin import sbt.ScriptedPlugin.autoImport._ import xerial.sbt.pack.PackPlugin import xerial.sbt.pack.PackPlugin.autoImport._ @@ -356,7 +357,6 @@ object Build { lazy val `dotty-bootstrapped` = project.asDottyRoot(Bootstrapped) lazy val `dotty-interfaces` = project.in(file("interfaces")). - disablePlugins(ScriptedPlugin). settings(commonScala2Settings). // Java-only project, so this is fine settings( // Do not append Scala versions to the generated artifacts @@ -530,7 +530,7 @@ object Build { // FIXME: Not needed, but should be on the compiler CP ("org.scala-lang.modules" %% "scala-xml" % "1.1.0").withDottyCompat(scalaVersion.value), "org.scala-lang" % "scala-library" % scalacVersion % "test", - Dependencies.compilerInterface(sbtVersion.value), + Dependencies.`compiler-interface`, "org.jline" % "jline-reader" % "3.9.0", // used by the REPL "org.jline" % "jline-terminal" % "3.9.0", "org.jline" % "jline-terminal-jna" % "3.9.0" // needed for Windows @@ -799,8 +799,8 @@ object Build { description := "sbt compiler bridge for Dotty", resolvers += Resolver.typesafeIvyRepo("releases"), // For org.scala-sbt:api libraryDependencies ++= Seq( - Dependencies.compilerInterface(sbtVersion.value) % Provided, - (Dependencies.zincApiinfo(sbtVersion.value) % Test).withDottyCompat(scalaVersion.value) + Dependencies.`compiler-interface` % Provided, + (Dependencies.`zinc-api-info` % Test).withDottyCompat(scalaVersion.value) ), // The sources should be published with crossPaths := false since they // need to be compiled by the project using the bridge. @@ -893,7 +893,7 @@ object Build { buildInfoPackage in Test := "dotty.tools.languageserver.util.server", BuildInfoPlugin.buildInfoScopedSettings(Test), BuildInfoPlugin.buildInfoDefaultSettings - ).disablePlugins(ScriptedPlugin) + ) lazy val `dotty-bench` = project.in(file("bench")).asDottyBench(NonBootstrapped) lazy val `dotty-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped) @@ -928,6 +928,7 @@ object Build { // 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")). + enablePlugins(SbtPlugin). settings(commonSettings). settings( version := { @@ -938,11 +939,10 @@ object Build { // Keep in sync with inject-sbt-dotty.sbt libraryDependencies ++= Seq( Dependencies.`jackson-databind`, - Dependencies.compilerInterface(sbtVersion.value) + Dependencies.`compiler-interface` ), unmanagedSourceDirectories in Compile += baseDirectory.value / "../language-server/src/dotty/tools/languageserver/config", - sbtPlugin := true, sbtTestDirectory := baseDirectory.value / "sbt-test", scriptedLaunchOpts ++= Seq( "-Dplugin.version=" + version.value, @@ -1253,7 +1253,6 @@ object Build { // FIXME: we do not aggregate `bin` because its tests delete jars, thus breaking other tests def asDottyRoot(implicit mode: Mode): Project = project.withCommonSettings. - disablePlugins(ScriptedPlugin). aggregate(`dotty-interfaces`, dottyLibrary, dottyCompiler, dottyDoc, dottySbtBridgeReference). bootstrappedAggregate(`scala-library`, `scala-compiler`, `scala-reflect`, scalap, `dotty-language-server`). dependsOn(dottyCompiler). @@ -1263,13 +1262,11 @@ object Build { ) def asDottyCompiler(implicit mode: Mode): Project = project.withCommonSettings. - disablePlugins(ScriptedPlugin). dependsOn(`dotty-interfaces`). dependsOn(dottyLibrary). settings(dottyCompilerSettings) def asDottyLibrary(implicit mode: Mode): Project = project.withCommonSettings. - disablePlugins(ScriptedPlugin). settings(dottyLibrarySettings). bootstrappedSettings( // Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called. @@ -1277,24 +1274,20 @@ object Build { ) def asDottyDoc(implicit mode: Mode): Project = project.withCommonSettings. - disablePlugins(ScriptedPlugin). dependsOn(dottyCompiler, dottyCompiler % "test->test"). settings(dottyDocSettings) def asDottySbtBridge(implicit mode: Mode): Project = project.withCommonSettings. - disablePlugins(ScriptedPlugin). dependsOn(dottyCompiler % Provided). dependsOn(dottyDoc % Provided). settings(dottySbtBridgeSettings) def asDottyBench(implicit mode: Mode): Project = project.withCommonSettings. - disablePlugins(ScriptedPlugin). dependsOn(dottyCompiler). settings(commonBenchmarkSettings). enablePlugins(JmhPlugin) def asDist(implicit mode: Mode): Project = project. - disablePlugins(ScriptedPlugin). enablePlugins(PackPlugin). withCommonSettings. dependsOn(`dotty-interfaces`, dottyCompiler, dottyLibrary, dottyDoc). diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 7e52dbc95bd3..bd835b00b2d9 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -10,6 +10,7 @@ object Dependencies { val `jackson-dataformat-yaml` = "com.fasterxml.jackson.dataformat" % "jackson-dataformat-yaml" % jacksonVersion - def compilerInterface(sbtVersion: String) = "org.scala-sbt" % "compiler-interface" % sbtVersion - def zincApiinfo(sbtVersion: String) = "org.scala-sbt" %% "zinc-apiinfo" % sbtVersion + private val zincVersion = "1.2.2" + val `compiler-interface` = "org.scala-sbt" % "compiler-interface" % zincVersion + val `zinc-api-info` = "org.scala-sbt" %% "zinc-apiinfo" % zincVersion } diff --git a/project/build.properties b/project/build.properties index d6e35076cc16..0cd8b07982e1 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.6 +sbt.version=1.2.3 diff --git a/project/inject-sbt-dotty.sbt b/project/inject-sbt-dotty.sbt index a73be671d462..d2962d3d901e 100644 --- a/project/inject-sbt-dotty.sbt +++ b/project/inject-sbt-dotty.sbt @@ -7,7 +7,7 @@ unmanagedSourceDirectories in Compile += baseDirectory.value / "../sbt-dotty/src // Keep in sync with `sbt-dotty` config in Build.scala libraryDependencies ++= Seq( Dependencies.`jackson-databind`, - Dependencies.compilerInterface(sbtVersion.value) + Dependencies.`compiler-interface` ) unmanagedSourceDirectories in Compile += baseDirectory.value / "../language-server/src/dotty/tools/languageserver/config" From e7d172ce5c37aad5ebde513524ef83f8b4d0629d Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 14 Sep 2018 14:34:11 +0200 Subject: [PATCH 2/3] .drone.yml: Upgrade docker image The new image has updated dependencies and is based on Ubuntu instead of Alpine. --- .drone.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7532a05f6950..712dfc3817e9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,7 +23,7 @@ pipeline: # We run tests in parallel. Tests run in a copy of the working directory to avoid conflict test: group: test - image: lampepfl/dotty:2018-08-31 + image: lampepfl/dotty:2018-09-14-2 commands: - cp -R . /tmp/1/ && cd /tmp/1/ - ./project/scripts/sbt ";compile ;test" @@ -31,7 +31,7 @@ pipeline: test_bootstrapped: group: test - image: lampepfl/dotty:2018-08-31 + image: lampepfl/dotty:2018-09-14-2 commands: - cp -R . /tmp/2/ && cd /tmp/2/ - ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test" @@ -39,7 +39,7 @@ pipeline: test_sbt: group: test - image: lampepfl/dotty:2018-08-31 + image: lampepfl/dotty:2018-09-14-2 commands: - cp -R . /tmp/4/ && cd /tmp/4/ - ./project/scripts/sbt sbt-dotty/scripted @@ -49,7 +49,7 @@ pipeline: # DOCUMENTATION: documentation: - image: lampepfl/dotty:2018-08-31 + image: lampepfl/dotty:2018-09-14-2 commands: - ./project/scripts/genDocs secrets: [ bot_pass ] @@ -61,7 +61,7 @@ pipeline: # PUBLISHING: # Publishing expect NIGHTLYBUILD or RELEASEBUILD to be set. See dottyVersion in Build.scala publish_nightly: - image: lampepfl/dotty:2018-08-31 + image: lampepfl/dotty:2018-09-14-2 environment: - NIGHTLYBUILD=yes commands: @@ -72,7 +72,7 @@ pipeline: environment: nightly publish_release: - image: lampepfl/dotty:2018-08-31 + image: lampepfl/dotty:2018-09-14-2 environment: - RELEASEBUILD=yes commands: @@ -96,7 +96,7 @@ pipeline: event: tag publish_sbt_release: - image: lampepfl/dotty:2018-08-31 + image: lampepfl/dotty:2018-09-14-2 environment: - RELEASEBUILD=yes commands: From cbff210c2cf407b61451feb706c6616576227a58 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 28 Aug 2018 18:00:55 +0900 Subject: [PATCH 3/3] Properly report problems to sbt Dotty has its own logic for displaying problems with the proper file path, position, and caret, but if we store this information in Problem#message we end up with duplicated information in the output since Zinc will prepend/append similar things (see sbt.internal.inc.ProblemStringFormats). So far, we worked around this in Dotty by using an empty position in the sbt bridge reporter, but this means that crucial semantic information that could be used by a Build Server Protocol implementation and other tools is lost. Thanks to https://github.com/sbt/zinc/pull/588 we can now fully customize how the message is displayed to the user using Problem#rendered, so we can now store the position information without any adverse effect. --- sbt-bridge/src/xsbt/DelegatingReporter.scala | 13 +++++++------ sbt-bridge/src/xsbt/Problem.scala | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sbt-bridge/src/xsbt/DelegatingReporter.scala b/sbt-bridge/src/xsbt/DelegatingReporter.scala index 6ac533a9cb13..d97af019837d 100644 --- a/sbt-bridge/src/xsbt/DelegatingReporter.scala +++ b/sbt-bridge/src/xsbt/DelegatingReporter.scala @@ -29,7 +29,7 @@ final class DelegatingReporter(delegate: xsbti.Reporter) extends Reporter } val position = - if (false && cont.pos.exists) { // Disabled because it duplicates the information printed by Dotty + if (cont.pos.exists) { val pos = cont.pos val src = pos.source new Position { @@ -46,13 +46,14 @@ final class DelegatingReporter(delegate: xsbti.Reporter) extends Reporter } else noPosition - val sb = new StringBuilder() - sb.append(messageAndPos(cont.contained(), cont.pos, diagnosticLevel(cont))) - if (ctx.shouldExplain(cont) && cont.contained().explanation.nonEmpty) { - sb.append(explanation(cont.contained())) + val message = cont.contained() + val rendered = new StringBuilder() + rendered.append(messageAndPos(message, cont.pos, diagnosticLevel(cont))) + if (ctx.shouldExplain(cont) && message.explanation.nonEmpty) { + rendered.append(explanation(message)) } - delegate.log(Problem(position, sb.toString(), severity)) + delegate.log(Problem(position, message.msg, severity, rendered.toString)) } private[this] def maybe[T](opt: Option[T]): Optional[T] = opt match { diff --git a/sbt-bridge/src/xsbt/Problem.scala b/sbt-bridge/src/xsbt/Problem.scala index f92d8c284f89..991dbc2bf308 100644 --- a/sbt-bridge/src/xsbt/Problem.scala +++ b/sbt-bridge/src/xsbt/Problem.scala @@ -1,12 +1,12 @@ package xsbt +import java.util.Optional import xsbti.{Position, Severity} final case class Problem(override val position: Position, override val message: String, - override val severity: Severity) extends xsbti.Problem { + override val severity: Severity, + rendered0: String) extends xsbti.Problem { override val category = "" - override def toString = s"[$severity] $position: $message" - + override val rendered = Optional.of(rendered0) } -