summaryrefslogtreecommitdiff
path: root/scalaplugin/src/main
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-12-04 21:55:01 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-12-04 21:55:15 -0800
commit422d41498d43ad9b437b2d4460f61849e78bb6fa (patch)
tree167ebadc8dab617bbc6388d1ff4d13b5b08115d1 /scalaplugin/src/main
parente9f3c71f670f93c95f0ae47860e663b768885067 (diff)
downloadmill-422d41498d43ad9b437b2d4460f61849e78bb6fa.tar.gz
mill-422d41498d43ad9b437b2d4460f61849e78bb6fa.tar.bz2
mill-422d41498d43ad9b437b2d4460f61849e78bb6fa.zip
- Make `T.ctx()` available implicitly
- Convert `ScalaModule.{compile,assembly}` to use the new implicit `T.ctx()` - Add a `log: PrintStream` to the `T.ctx()`, in preparation for per-task logging
Diffstat (limited to 'scalaplugin/src/main')
-rw-r--r--scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala28
1 files changed, 13 insertions, 15 deletions
diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
index 3d194190..e25d13de 100644
--- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
+++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
@@ -13,6 +13,7 @@ import mill.define.Task.{Module, TaskModule}
import mill.eval.{PathRef, Result}
import mill.modules.Jvm
import mill.modules.Jvm.{createAssembly, createJar, subprocess}
+import mill.util.Ctx
import sbt.internal.inc._
import sbt.internal.util.{ConsoleOut, MainAppender}
import sbt.util.{InterfaceUtil, LogExchange}
@@ -39,10 +40,10 @@ object ScalaModule{
compilerClasspath: Seq[Path],
compilerBridge: Seq[Path],
scalacOptions: Seq[String],
- javacOptions: Seq[String],
- outputPath: Path): PathRef = {
+ javacOptions: Seq[String])
+ (implicit ctx: Ctx): PathRef = {
val compileClasspathFiles = compileClasspath.map(_.toIO).toArray
- val binaryScalaVersion = scalaVersion.split('.').dropRight(1).mkString(".")
+
def grepJar(classPath: Seq[Path], s: String) = {
classPath
.find(_.toString.endsWith(s))
@@ -79,13 +80,13 @@ object ScalaModule{
val scalac = ZincUtil.scalaCompiler(scalaInstance, compilerBridgeJar)
- mkdir(outputPath)
+ mkdir(ctx.dest)
val ic = new sbt.internal.inc.IncrementalCompilerImpl()
val logger = {
- val console = ConsoleOut.systemOut
- val consoleAppender = MainAppender.defaultScreen(console)
+
+ val consoleAppender = MainAppender.defaultScreen(ConsoleOut.printStreamOut(ctx.log))
val l = LogExchange.logger("Hello")
LogExchange.unbindLoggerAppenders("Hello")
LogExchange.bindLoggerAppenders("Hello", (consoleAppender -> sbt.util.Level.Info) :: Nil)
@@ -105,9 +106,9 @@ object ScalaModule{
override def startUnit(phase: String, unitPath: String): Unit = ()
}
- val zincFile = (outputPath/'zinc).toIO
+ val zincFile = (ctx.dest/'zinc).toIO
val store = FileAnalysisStore.binary(zincFile)
- val classesDir = (outputPath / 'classes).toIO
+ val classesDir = (ctx.dest / 'classes).toIO
val newResult = ic.compile(
ic.inputs(
classpath = classesDir +: compileClasspathFiles,
@@ -147,7 +148,7 @@ object ScalaModule{
)
)
- PathRef(outputPath/'classes)
+ PathRef(ctx.dest/'classes)
}
def resolveDependencies(repositories: Seq[Repository],
@@ -344,18 +345,15 @@ trait ScalaModule extends Module with TaskModule{ outer =>
scalaCompilerClasspath().map(_.path),
compilerBridgeClasspath().map(_.path),
scalacOptions(),
- javacOptions(),
- T.ctx().dest
+ javacOptions()
)
}
def assembly = T{
- val dest = T.ctx().dest
createAssembly(
- dest,
- (runDepClasspath().filter(_.path.ext != "pom") ++ Seq(resources(), compile())).map(_.path).filter(exists),
+ (runDepClasspath().filter(_.path.ext != "pom") ++
+ Seq(resources(), compile())).map(_.path).filter(exists),
prependShellScript = prependShellScript()
)
- PathRef(dest)
}
def classpath = T{ Seq(resources(), compile()) }