diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/api/src/mill/api/BspCompileArguments.scala | 18 | ||||
-rw-r--r-- | main/api/src/mill/api/BspContext.scala | 30 | ||||
-rw-r--r-- | main/api/src/mill/api/Ctx.scala | 15 | ||||
-rw-r--r-- | main/api/src/mill/api/TestReporter.scala | 60 | ||||
-rw-r--r-- | main/core/src/eval/Evaluator.scala | 43 |
5 files changed, 85 insertions, 81 deletions
diff --git a/main/api/src/mill/api/BspCompileArguments.scala b/main/api/src/mill/api/BspCompileArguments.scala deleted file mode 100644 index 73586cc8..00000000 --- a/main/api/src/mill/api/BspCompileArguments.scala +++ /dev/null @@ -1,18 +0,0 @@ -package mill.api - -/** - * Data structure to represent Bsp client-specified - * compilation arguments - */ -class BspCompileArguments { - var arguments: Seq[String] = Seq.empty[String] - - /** - * Return the compilation arguments specified by the - * Bsp client, which may or may not be found in the - * compiler options of any module from the build file. - */ - def args: Seq[String] = { - arguments - } -} diff --git a/main/api/src/mill/api/BspContext.scala b/main/api/src/mill/api/BspContext.scala deleted file mode 100644 index 1281518d..00000000 --- a/main/api/src/mill/api/BspContext.scala +++ /dev/null @@ -1,30 +0,0 @@ -package mill.api - -import sbt.testing.Event - -/** - * Bsp Context with functionality for retrieving compile - * arguments provided by a Bsp client, as well as for logging - * the start and finish of a task triggered by the request of - * a Bsp client. Can be integrated into mill's Ctx to inject - * Bsp functionality into tasks like compile/run/test. - */ -trait BspContext extends BspCompileArguments with TestReporter - -/** - * Dummy Bsp Context that does nothing - * upon starting or finishing a task, and - * contains no client-specified compilation - * arguments - */ -object DummyBspContext extends BspContext { - override def args = Seq.empty[String] - - override def logStart(event: Event): Unit = { - - } - - override def logFinish(event: Event): Unit = { - - } -}
\ No newline at end of file diff --git a/main/api/src/mill/api/Ctx.scala b/main/api/src/mill/api/Ctx.scala index 02d50b22..96da84eb 100644 --- a/main/api/src/mill/api/Ctx.scala +++ b/main/api/src/mill/api/Ctx.scala @@ -3,7 +3,6 @@ package mill.api import scala.annotation.{StaticAnnotation, compileTimeOnly} import scala.language.implicitConversions import os.Path -import sbt.internal.inc.ManagedLoggedReporter /** * Provides access to various resources in the context of a currently execution Target. @@ -56,13 +55,13 @@ object Ctx { class Ctx( - val args: IndexedSeq[_], - dest0: () => os.Path, - val log: Logger, - val home: os.Path, - val env: Map[String, String], - val reporter: Int => Option[ManagedLoggedReporter], - val bsp: BspContext + val args: IndexedSeq[_], + dest0: () => os.Path, + val log: Logger, + val home: os.Path, + val env: Map[String, String], + val reporter: Int => Option[BuildProblemReporter], + val testReporter: TestReporter ) extends Ctx.Dest with Ctx.Log diff --git a/main/api/src/mill/api/TestReporter.scala b/main/api/src/mill/api/TestReporter.scala index 97dec761..8adea687 100644 --- a/main/api/src/mill/api/TestReporter.scala +++ b/main/api/src/mill/api/TestReporter.scala @@ -1,5 +1,7 @@ package mill.api +import java.io.File + import sbt.testing._ /** @@ -20,12 +22,66 @@ trait TestReporter { * Dummy Test Reporter that doesn't report * anything for any testing event. */ -object DummyReporter extends TestReporter { +object DummyTestReporter extends TestReporter { override def logStart(event: Event): Unit = { } - override def logFinish(event: Event): Unit = { } } + +trait BuildProblemReporter { + def logError(problem: Problem): Unit + + def logWarning(problem: Problem): Unit + + def logInfo(problem: Problem): Unit + + def printSummary(): Unit +} + +trait ProblemPosition { + def line: Option[Int] + + def lineContent: String + + def offset: Option[Int] + + def pointer: Option[Int] + + def pointerSpace: Option[String] + + def sourcePath: Option[String] + + def sourceFile: Option[File] + + def startOffset: Option[Int] = Option.empty + + def endOffset: Option[Int] = Option.empty + + def startLine: Option[Int] = Option.empty + + def startColumn: Option[Int] = Option.empty + + def endLine: Option[Int] = Option.empty + + def endColumn: Option[Int] = Option.empty +} + +sealed trait Severity +case object Info extends Severity +case object Error extends Severity +case object Warn extends Severity + +trait Problem { + def category: String + + def severity: Severity + + def message: String + + def position: ProblemPosition +} + + diff --git a/main/core/src/eval/Evaluator.scala b/main/core/src/eval/Evaluator.scala index 75103398..37de69b3 100644 --- a/main/core/src/eval/Evaluator.scala +++ b/main/core/src/eval/Evaluator.scala @@ -2,21 +2,18 @@ package mill.eval import java.net.URLClassLoader -import scala.collection.JavaConverters._ -import scala.collection.mutable -import scala.util.control.NonFatal import ammonite.runtime.SpecialClassLoader -import mill.api.{BspContext, DummyBspContext} -import mill.util.Router.EntryPoint -import mill.define.{Ctx => _, _} import mill.api.Result.{Aborted, OuterStack, Success} +import mill.api.Strict.Agg +import mill.api.{DummyTestReporter, TestReporter, BuildProblemReporter} +import mill.define.{Ctx => _, _} import mill.util +import mill.util.Router.EntryPoint import mill.util._ -import mill.api.Strict.Agg -import sbt.internal.inc.{CompilerArguments, ManagedLoggedReporter} -import sbt.internal.util.{ConsoleOut, MainAppender} -import sbt.testing.Event -import sbt.util.LogExchange + +import scala.collection.JavaConverters._ +import scala.collection.mutable +import scala.util.control.NonFatal case class Labelled[T](task: NamedTask[T], segments: Segments){ @@ -45,8 +42,8 @@ case class Evaluator(home: os.Path, val classLoaderSignHash = classLoaderSig.hashCode() def evaluate(goals: Agg[Task[_]], - reporter: Int => Option[ManagedLoggedReporter] = (int: Int) => Option.empty[ManagedLoggedReporter], - bspContext: BspContext = DummyBspContext, + reporter: Int => Option[BuildProblemReporter] = (int: Int) => Option.empty[BuildProblemReporter], + testReporter: TestReporter = DummyTestReporter, logger: Logger = log): Evaluator.Results = { os.makeDir.all(outPath) val (sortedGroups, transitive) = Evaluator.plan(rootModule, goals) @@ -74,7 +71,7 @@ case class Evaluator(home: os.Path, results, counterMsg, reporter, - bspContext, + testReporter, logger ) someTaskFailed = someTaskFailed || newResults.exists(task => !task._2.isInstanceOf[Success[_]]) @@ -121,8 +118,8 @@ case class Evaluator(home: os.Path, group: Agg[Task[_]], results: collection.Map[Task[_], Result[(Any, Int)]], counterMsg: String, - reporter: Int => Option[ManagedLoggedReporter], - bspContext: BspContext, + zincProblemReporter: Int => Option[BuildProblemReporter], + testReporter: TestReporter, logger: Logger ): (collection.Map[Task[_], Result[(Any, Int)]], Seq[Task[_]], Boolean) = { @@ -146,8 +143,8 @@ case class Evaluator(home: os.Path, paths = None, maybeTargetLabel = None, counterMsg = counterMsg, - reporter, - bspContext, + zincProblemReporter, + testReporter, logger ) (newResults, newEvaluated, false) @@ -201,8 +198,8 @@ case class Evaluator(home: os.Path, paths = Some(paths), maybeTargetLabel = Some(msgParts.mkString), counterMsg = counterMsg, - reporter, - bspContext, + zincProblemReporter, + testReporter, logger ) @@ -278,8 +275,8 @@ case class Evaluator(home: os.Path, paths: Option[Evaluator.Paths], maybeTargetLabel: Option[String], counterMsg: String, - reporter: Int => Option[ManagedLoggedReporter], - bspContext: BspContext, + reporter: Int => Option[BuildProblemReporter], + testReporter: TestReporter, logger: Logger): (mutable.LinkedHashMap[Task[_], Result[(Any, Int)]], mutable.Buffer[Task[_]]) = { @@ -342,7 +339,7 @@ case class Evaluator(home: os.Path, home, env, reporter, - bspContext + testReporter ) val out = System.out |