summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandra Dima <alexandra.dima@jetbrains.com>2019-07-24 14:03:48 +0200
committerSamvel Abrahamyan <samvel1024@gmail.com>2019-10-12 14:33:11 +0200
commit0b4bcbbfabe06d549d95efb427e75356287398fb (patch)
tree38496e9791f508276b58fdcf8aef46ffe1a5d971
parentfca29d647f2ae0b71c5b66b3ea4462987e08c911 (diff)
downloadmill-0b4bcbbfabe06d549d95efb427e75356287398fb.tar.gz
mill-0b4bcbbfabe06d549d95efb427e75356287398fb.tar.bz2
mill-0b4bcbbfabe06d549d95efb427e75356287398fb.zip
Changed the clean cache method to usethe clean command form mill's MainModule rather than start the clean command as a separate subprocess. Removed dead code comment and added show message notifications to the MillBspLogger.
-rw-r--r--.gitignore3
-rw-r--r--contrib/bsp/src/mill/contrib/bsp/MillBspLogger.scala21
-rw-r--r--contrib/bsp/src/mill/contrib/bsp/MillBuildServer.scala36
-rw-r--r--scalalib/worker/src/ZincWorkerImpl.scala2
4 files changed, 36 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
index 53cea62c..84df7fe8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,5 @@ out/
/.metals/
contrib/bsp/mill-external-bs
contrib/bsp/mill-out-bs
-mill.iml \ No newline at end of file
+mill.iml
+.bsp/ \ No newline at end of file
diff --git a/contrib/bsp/src/mill/contrib/bsp/MillBspLogger.scala b/contrib/bsp/src/mill/contrib/bsp/MillBspLogger.scala
index 811c898c..195d9aab 100644
--- a/contrib/bsp/src/mill/contrib/bsp/MillBspLogger.scala
+++ b/contrib/bsp/src/mill/contrib/bsp/MillBspLogger.scala
@@ -1,9 +1,7 @@
package mill.contrib.bsp
-import java.io.{InputStream, PrintStream}
-
-import ch.epfl.scala.bsp4j.{BuildClient, TaskId, TaskProgressParams}
-import mill.api.{BspContext, Logger}
+import ch.epfl.scala.bsp4j._
+import mill.api.Logger
import mill.util.ProxyLogger
class MillBspLogger(client: BuildClient, taskId: Int, logger: Logger) extends ProxyLogger(logger) {
@@ -24,4 +22,19 @@ class MillBspLogger(client: BuildClient, taskId: Int, logger: Logger) extends Pr
}
}
+ override def error(s: String): Unit = {
+ super.error(s)
+ client.onBuildShowMessage(new ShowMessageParams(MessageType.ERROR, s))
+ }
+
+ override def info(s: String): Unit = {
+ super.info(s)
+ client.onBuildShowMessage(new ShowMessageParams(MessageType.INFORMATION, s))
+ }
+
+ override def debug(s: String): Unit = {
+ super.debug(s)
+ client.onBuildShowMessage(new ShowMessageParams(MessageType.LOG, s))
+ }
+
}
diff --git a/contrib/bsp/src/mill/contrib/bsp/MillBuildServer.scala b/contrib/bsp/src/mill/contrib/bsp/MillBuildServer.scala
index b5ebf83e..f34571e4 100644
--- a/contrib/bsp/src/mill/contrib/bsp/MillBuildServer.scala
+++ b/contrib/bsp/src/mill/contrib/bsp/MillBuildServer.scala
@@ -20,6 +20,7 @@ import scala.collection.JavaConverters._
import mill.modules.Jvm
import mill.util.Ctx
import mill.define.{Discover, ExternalModule}
+import mill.main.MainModule
import sbt.internal.util.{ConsoleOut, MainAppender, ManagedLogger}
import sbt.util.LogExchange
@@ -393,30 +394,25 @@ class MillBuildServer(evaluator: Evaluator,
var cleaned = true
for (targetId <- cleanCacheParams.getTargets.asScala) {
val module = targetIdToModule(targetId)
- val cleanCommand = List("java",
- s"-DMILL_CLASSPATH=${System.getProperty("MILL_CLASSPATH")}",
- s"-DMILL_VERSION=${System.getProperty("MILL_VERSION")}",
- "-Djna.nosys=true", "-cp",
- System.getProperty("MILL_CLASSPATH"),
- "mill.MillMain", "clean",
- s"${module.millModuleSegments.render}.compile")
- val process = Runtime.getRuntime.exec(cleanCommand.mkString(" "))
-
- val processIn = process.getInputStream
- val processErr = process.getErrorStream
-
- val errMessage = Source.fromInputStream(processErr).getLines().mkString("\n")
- val message = Source.fromInputStream(processIn).getLines().mkString("\n")
- msg += s"Cleaning cache for target ${targetId} produced the following message: ${message}, ${errMessage}"
- if (msg.contains("failed")) {
+ val mainModule = new MainModule {
+ override implicit def millDiscover: Discover[_] = {
+ Discover[this.type]
+ }
+ }
+ val cleanCommand = mainModule.clean(millEvaluator, List(s"${module.millModuleSegments.render}.compile"):_*)
+ val cleanResult = millEvaluator.evaluate(
+ Strict.Agg(cleanCommand),
+ logger = new MillBspLogger(client, cleanCommand.hashCode, millEvaluator.log)
+ )
+ if (cleanResult.failing.keyCount > 0) {
cleaned = false
+ msg += s" Target ${module.millModuleSegments.render} could not be cleaned."
}
- process.waitFor()
}
- new CleanCacheResult(msg, cleaned)
+ new CleanCacheResult(msg, cleaned)
+ }
+ handleExceptions[String, CleanCacheResult]((in) => getCleanCacheResult, "")
}
- handleExceptions[String, CleanCacheResult]((in) => getCleanCacheResult, "")
- }
override def buildTargetScalacOptions(scalacOptionsParams: ScalacOptionsParams):
CompletableFuture[ScalacOptionsResult] = {
diff --git a/scalalib/worker/src/ZincWorkerImpl.scala b/scalalib/worker/src/ZincWorkerImpl.scala
index 7c696ccc..a1d632df 100644
--- a/scalalib/worker/src/ZincWorkerImpl.scala
+++ b/scalalib/worker/src/ZincWorkerImpl.scala
@@ -362,7 +362,7 @@ class ZincWorkerImpl(compilerBridge: Either[
zincIOFile,
new FreshCompilerCache,
IncOptions.of(),
- newReporter,//new ManagedLoggedReporter(10, logger),
+ newReporter,
None,
Array()
),