Skip to content

Upgrade to sbt 1.2.3, properly report problems to sbt #5106

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 3 commits into from
Sep 14, 2018
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
14 changes: 7 additions & 7 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ 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"
- ./project/scripts/cmdTests

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"
- ./project/scripts/bootstrapCmdTests

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
Expand All @@ -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 ]
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
21 changes: 7 additions & 14 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 := {
Expand All @@ -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,
Expand Down Expand Up @@ -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).
Expand All @@ -1263,38 +1262,32 @@ 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.
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath)
)

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).
Expand Down
5 changes: 3 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.1.6
sbt.version=1.2.3
2 changes: 1 addition & 1 deletion project/inject-sbt-dotty.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
13 changes: 7 additions & 6 deletions sbt-bridge/src/xsbt/DelegatingReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions sbt-bridge/src/xsbt/Problem.scala
Original file line number Diff line number Diff line change
@@ -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)
}