Skip to content

Commit fb655f7

Browse files
authored
Merge pull request #5106 from dotty-staging/proper-sbt-reporting-3
Upgrade to sbt 1.2.3, properly report problems to sbt
2 parents 7dc2226 + cbff210 commit fb655f7

File tree

7 files changed

+30
-35
lines changed

7 files changed

+30
-35
lines changed

.drone.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ pipeline:
2323
# We run tests in parallel. Tests run in a copy of the working directory to avoid conflict
2424
test:
2525
group: test
26-
image: lampepfl/dotty:2018-08-31
26+
image: lampepfl/dotty:2018-09-14-2
2727
commands:
2828
- cp -R . /tmp/1/ && cd /tmp/1/
2929
- ./project/scripts/sbt ";compile ;test"
3030
- ./project/scripts/cmdTests
3131

3232
test_bootstrapped:
3333
group: test
34-
image: lampepfl/dotty:2018-08-31
34+
image: lampepfl/dotty:2018-09-14-2
3535
commands:
3636
- cp -R . /tmp/2/ && cd /tmp/2/
3737
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test"
3838
- ./project/scripts/bootstrapCmdTests
3939

4040
test_sbt:
4141
group: test
42-
image: lampepfl/dotty:2018-08-31
42+
image: lampepfl/dotty:2018-09-14-2
4343
commands:
4444
- cp -R . /tmp/4/ && cd /tmp/4/
4545
- ./project/scripts/sbt sbt-dotty/scripted
@@ -49,7 +49,7 @@ pipeline:
4949

5050
# DOCUMENTATION:
5151
documentation:
52-
image: lampepfl/dotty:2018-08-31
52+
image: lampepfl/dotty:2018-09-14-2
5353
commands:
5454
- ./project/scripts/genDocs
5555
secrets: [ bot_pass ]
@@ -61,7 +61,7 @@ pipeline:
6161
# PUBLISHING:
6262
# Publishing expect NIGHTLYBUILD or RELEASEBUILD to be set. See dottyVersion in Build.scala
6363
publish_nightly:
64-
image: lampepfl/dotty:2018-08-31
64+
image: lampepfl/dotty:2018-09-14-2
6565
environment:
6666
- NIGHTLYBUILD=yes
6767
commands:
@@ -72,7 +72,7 @@ pipeline:
7272
environment: nightly
7373

7474
publish_release:
75-
image: lampepfl/dotty:2018-08-31
75+
image: lampepfl/dotty:2018-09-14-2
7676
environment:
7777
- RELEASEBUILD=yes
7878
commands:
@@ -96,7 +96,7 @@ pipeline:
9696
event: tag
9797

9898
publish_sbt_release:
99-
image: lampepfl/dotty:2018-08-31
99+
image: lampepfl/dotty:2018-09-14-2
100100
environment:
101101
- RELEASEBUILD=yes
102102
commands:

project/Build.scala

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import complete.DefaultParsers._
1010
import pl.project13.scala.sbt.JmhPlugin
1111
import pl.project13.scala.sbt.JmhPlugin.JmhKeys.Jmh
1212
import sbt.Package.ManifestAttributes
13+
import sbt.plugins.SbtPlugin
1314
import sbt.ScriptedPlugin.autoImport._
1415
import xerial.sbt.pack.PackPlugin
1516
import xerial.sbt.pack.PackPlugin.autoImport._
@@ -356,7 +357,6 @@ object Build {
356357
lazy val `dotty-bootstrapped` = project.asDottyRoot(Bootstrapped)
357358

358359
lazy val `dotty-interfaces` = project.in(file("interfaces")).
359-
disablePlugins(ScriptedPlugin).
360360
settings(commonScala2Settings). // Java-only project, so this is fine
361361
settings(
362362
// Do not append Scala versions to the generated artifacts
@@ -530,7 +530,7 @@ object Build {
530530
// FIXME: Not needed, but should be on the compiler CP
531531
("org.scala-lang.modules" %% "scala-xml" % "1.1.0").withDottyCompat(scalaVersion.value),
532532
"org.scala-lang" % "scala-library" % scalacVersion % "test",
533-
Dependencies.compilerInterface(sbtVersion.value),
533+
Dependencies.`compiler-interface`,
534534
"org.jline" % "jline-reader" % "3.9.0", // used by the REPL
535535
"org.jline" % "jline-terminal" % "3.9.0",
536536
"org.jline" % "jline-terminal-jna" % "3.9.0" // needed for Windows
@@ -799,8 +799,8 @@ object Build {
799799
description := "sbt compiler bridge for Dotty",
800800
resolvers += Resolver.typesafeIvyRepo("releases"), // For org.scala-sbt:api
801801
libraryDependencies ++= Seq(
802-
Dependencies.compilerInterface(sbtVersion.value) % Provided,
803-
(Dependencies.zincApiinfo(sbtVersion.value) % Test).withDottyCompat(scalaVersion.value)
802+
Dependencies.`compiler-interface` % Provided,
803+
(Dependencies.`zinc-api-info` % Test).withDottyCompat(scalaVersion.value)
804804
),
805805
// The sources should be published with crossPaths := false since they
806806
// need to be compiled by the project using the bridge.
@@ -893,7 +893,7 @@ object Build {
893893
buildInfoPackage in Test := "dotty.tools.languageserver.util.server",
894894
BuildInfoPlugin.buildInfoScopedSettings(Test),
895895
BuildInfoPlugin.buildInfoDefaultSettings
896-
).disablePlugins(ScriptedPlugin)
896+
)
897897

898898
lazy val `dotty-bench` = project.in(file("bench")).asDottyBench(NonBootstrapped)
899899
lazy val `dotty-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped)
@@ -928,6 +928,7 @@ object Build {
928928
// sbt plugin to use Dotty in your own build, see
929929
// https://github.com/lampepfl/dotty-example-project for usage.
930930
lazy val `sbt-dotty` = project.in(file("sbt-dotty")).
931+
enablePlugins(SbtPlugin).
931932
settings(commonSettings).
932933
settings(
933934
version := {
@@ -938,11 +939,10 @@ object Build {
938939
// Keep in sync with inject-sbt-dotty.sbt
939940
libraryDependencies ++= Seq(
940941
Dependencies.`jackson-databind`,
941-
Dependencies.compilerInterface(sbtVersion.value)
942+
Dependencies.`compiler-interface`
942943
),
943944
unmanagedSourceDirectories in Compile +=
944945
baseDirectory.value / "../language-server/src/dotty/tools/languageserver/config",
945-
sbtPlugin := true,
946946
sbtTestDirectory := baseDirectory.value / "sbt-test",
947947
scriptedLaunchOpts ++= Seq(
948948
"-Dplugin.version=" + version.value,
@@ -1253,7 +1253,6 @@ object Build {
12531253

12541254
// FIXME: we do not aggregate `bin` because its tests delete jars, thus breaking other tests
12551255
def asDottyRoot(implicit mode: Mode): Project = project.withCommonSettings.
1256-
disablePlugins(ScriptedPlugin).
12571256
aggregate(`dotty-interfaces`, dottyLibrary, dottyCompiler, dottyDoc, dottySbtBridgeReference).
12581257
bootstrappedAggregate(`scala-library`, `scala-compiler`, `scala-reflect`, scalap, `dotty-language-server`).
12591258
dependsOn(dottyCompiler).
@@ -1263,38 +1262,32 @@ object Build {
12631262
)
12641263

12651264
def asDottyCompiler(implicit mode: Mode): Project = project.withCommonSettings.
1266-
disablePlugins(ScriptedPlugin).
12671265
dependsOn(`dotty-interfaces`).
12681266
dependsOn(dottyLibrary).
12691267
settings(dottyCompilerSettings)
12701268

12711269
def asDottyLibrary(implicit mode: Mode): Project = project.withCommonSettings.
1272-
disablePlugins(ScriptedPlugin).
12731270
settings(dottyLibrarySettings).
12741271
bootstrappedSettings(
12751272
// Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called.
12761273
scalacOptions in Compile ++= Seq("-sourcepath", (scalaSource in Compile).value.getAbsolutePath)
12771274
)
12781275

12791276
def asDottyDoc(implicit mode: Mode): Project = project.withCommonSettings.
1280-
disablePlugins(ScriptedPlugin).
12811277
dependsOn(dottyCompiler, dottyCompiler % "test->test").
12821278
settings(dottyDocSettings)
12831279

12841280
def asDottySbtBridge(implicit mode: Mode): Project = project.withCommonSettings.
1285-
disablePlugins(ScriptedPlugin).
12861281
dependsOn(dottyCompiler % Provided).
12871282
dependsOn(dottyDoc % Provided).
12881283
settings(dottySbtBridgeSettings)
12891284

12901285
def asDottyBench(implicit mode: Mode): Project = project.withCommonSettings.
1291-
disablePlugins(ScriptedPlugin).
12921286
dependsOn(dottyCompiler).
12931287
settings(commonBenchmarkSettings).
12941288
enablePlugins(JmhPlugin)
12951289

12961290
def asDist(implicit mode: Mode): Project = project.
1297-
disablePlugins(ScriptedPlugin).
12981291
enablePlugins(PackPlugin).
12991292
withCommonSettings.
13001293
dependsOn(`dotty-interfaces`, dottyCompiler, dottyLibrary, dottyDoc).

project/Dependencies.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ object Dependencies {
1010
val `jackson-dataformat-yaml` =
1111
"com.fasterxml.jackson.dataformat" % "jackson-dataformat-yaml" % jacksonVersion
1212

13-
def compilerInterface(sbtVersion: String) = "org.scala-sbt" % "compiler-interface" % sbtVersion
14-
def zincApiinfo(sbtVersion: String) = "org.scala-sbt" %% "zinc-apiinfo" % sbtVersion
13+
private val zincVersion = "1.2.2"
14+
val `compiler-interface` = "org.scala-sbt" % "compiler-interface" % zincVersion
15+
val `zinc-api-info` = "org.scala-sbt" %% "zinc-apiinfo" % zincVersion
1516
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.1.6
1+
sbt.version=1.2.3

project/inject-sbt-dotty.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ unmanagedSourceDirectories in Compile += baseDirectory.value / "../sbt-dotty/src
77
// Keep in sync with `sbt-dotty` config in Build.scala
88
libraryDependencies ++= Seq(
99
Dependencies.`jackson-databind`,
10-
Dependencies.compilerInterface(sbtVersion.value)
10+
Dependencies.`compiler-interface`
1111
)
1212
unmanagedSourceDirectories in Compile +=
1313
baseDirectory.value / "../language-server/src/dotty/tools/languageserver/config"

sbt-bridge/src/xsbt/DelegatingReporter.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class DelegatingReporter(delegate: xsbti.Reporter) extends Reporter
2929
}
3030

3131
val position =
32-
if (false && cont.pos.exists) { // Disabled because it duplicates the information printed by Dotty
32+
if (cont.pos.exists) {
3333
val pos = cont.pos
3434
val src = pos.source
3535
new Position {
@@ -46,13 +46,14 @@ final class DelegatingReporter(delegate: xsbti.Reporter) extends Reporter
4646
} else
4747
noPosition
4848

49-
val sb = new StringBuilder()
50-
sb.append(messageAndPos(cont.contained(), cont.pos, diagnosticLevel(cont)))
51-
if (ctx.shouldExplain(cont) && cont.contained().explanation.nonEmpty) {
52-
sb.append(explanation(cont.contained()))
49+
val message = cont.contained()
50+
val rendered = new StringBuilder()
51+
rendered.append(messageAndPos(message, cont.pos, diagnosticLevel(cont)))
52+
if (ctx.shouldExplain(cont) && message.explanation.nonEmpty) {
53+
rendered.append(explanation(message))
5354
}
5455

55-
delegate.log(Problem(position, sb.toString(), severity))
56+
delegate.log(Problem(position, message.msg, severity, rendered.toString))
5657
}
5758

5859
private[this] def maybe[T](opt: Option[T]): Optional[T] = opt match {

sbt-bridge/src/xsbt/Problem.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package xsbt
22

3+
import java.util.Optional
34
import xsbti.{Position, Severity}
45

56
final case class Problem(override val position: Position,
67
override val message: String,
7-
override val severity: Severity) extends xsbti.Problem {
8+
override val severity: Severity,
9+
rendered0: String) extends xsbti.Problem {
810
override val category = ""
9-
override def toString = s"[$severity] $position: $message"
10-
11+
override val rendered = Optional.of(rendered0)
1112
}
12-

0 commit comments

Comments
 (0)