From acecf20f25da2b0eb777ff08c5fad8712d4c3c72 Mon Sep 17 00:00:00 2001 From: Nikolay Tatarinov <5min4eq.unity@gmail.com> Date: Sun, 26 Nov 2017 20:30:26 +0300 Subject: fix console command in scala plugin; use subprocess for run (#21) --- .../src/main/scala/mill/scalaplugin/ScalaModule.scala | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'scalaplugin') diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala index 96716fff..02f202de 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala @@ -8,9 +8,8 @@ import ammonite.ops._ import coursier.{Cache, Fetch, MavenRepository, Repository, Resolution} import mill.define.Task import mill.define.Task.{Module, TaskModule} -import mill.eval.{Evaluator, PathRef} -import mill.modules.Jvm.{createAssembly, createJar} -import mill.util.OSet +import mill.eval.PathRef +import mill.modules.Jvm.{createAssembly, createJar, subprocess} import sbt.internal.inc._ import sbt.internal.util.{ConsoleOut, MainAppender} import sbt.util.{InterfaceUtil, LogExchange} @@ -282,17 +281,14 @@ trait ScalaModule extends Module with TaskModule{ outer => } def run(mainClass: String) = T.command{ - import ammonite.ops._, ImplicitWd._ - %('java, "-cp", (runDepClasspath().map(_.path) :+ compile().path).mkString(":"), mainClass) + subprocess(mainClass, runDepClasspath().map(_.path) :+ compile().path) } def console() = T.command{ - import ammonite.ops._, ImplicitWd._ - %('java, - "-cp", - (runDepClasspath().map(_.path) :+ compile().path).mkString(":"), - "scala.tools.nsc.MainGenericRunner", - "-usejavacp" + subprocess( + mainClass = "scala.tools.nsc.MainGenericRunner", + classPath = externalCompileDepClasspath().map(_.path) :+ compile().path, + options = Seq("-usejavacp") ) } } -- cgit v1.2.3 From 082a6eab011173fa09a0e6b4cbd2234d1dcb5138 Mon Sep 17 00:00:00 2001 From: Nikolay Tatarinov <5min4eq.unity@gmail.com> Date: Sun, 26 Nov 2017 21:03:21 +0300 Subject: pass scalacOptions and javacOptions to compile (#23) --- .../src/main/scala/mill/scalaplugin/ScalaModule.scala | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'scalaplugin') diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala index 02f202de..b454d793 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala @@ -31,6 +31,8 @@ object ScalaModule{ def compileScala(scalaVersion: String, sources: Path, compileClasspath: Seq[Path], + scalacOptions: Seq[String], + javacOptions: Seq[String], outputPath: Path): PathRef = { val compileClasspathFiles = compileClasspath.map(_.toIO).toArray val binaryScalaVersion = scalaVersion.split('.').dropRight(1).mkString(".") @@ -95,8 +97,8 @@ object ScalaModule{ classpath = classesDir +: compileClasspathFiles, sources = ls.rec(sources).filter(_.isFile).map(_.toIO).toArray, classesDirectory = classesDir, - scalacOptions = Array(), - javacOptions = Array(), + scalacOptions = scalacOptions.toArray, + javacOptions = javacOptions.toArray, maxErrors = 10, sourcePositionMappers = Array(), order = CompileOrder.Mixed, @@ -194,6 +196,9 @@ trait ScalaModule extends Module with TaskModule{ outer => def runIvyDeps = T{ Seq[Dep]() } def basePath: Path + def scalacOptions = T{ Seq.empty[String] } + def javacOptions = T{ Seq.empty[String] } + val repositories: Seq[Repository] = Seq( Cache.ivy2Local, MavenRepository("https://repo1.maven.org/maven2") @@ -261,7 +266,13 @@ trait ScalaModule extends Module with TaskModule{ outer => def sources = T.source{ basePath / 'src } def resources = T.source{ basePath / 'resources } def compile = T.persistent{ - compileScala(scalaVersion(), sources().path, compileDepClasspath().map(_.path), T.ctx().dest) + compileScala( + scalaVersion(), + sources().path, + compileDepClasspath().map(_.path), + scalacOptions(), + javacOptions(), + T.ctx().dest) } def assembly = T{ val dest = T.ctx().dest -- cgit v1.2.3 From 1c1abf19b34bc6a467c25b8838f7816694d423d1 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Sun, 26 Nov 2017 19:32:09 +0100 Subject: Cleaner logging of Zinc activities. (#25) * Bust caches when the build itself has changed. Use the Ammonite classloader to check if the classpath has changed Fix #7 * Cleaner logging of Zinc activities. Removed printlns and bumped up the Zinc log level to Info. This show the nice `Compiling Scala sources` messages, and the useless `Done compiling` line at the end. --- .../src/main/scala/mill/scalaplugin/ScalaModule.scala | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'scalaplugin') diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala index b454d793..f42a3055 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala @@ -64,7 +64,7 @@ object ScalaModule{ val consoleAppender = MainAppender.defaultScreen(console) val l = LogExchange.logger("Hello") LogExchange.unbindLoggerAppenders("Hello") - LogExchange.bindLoggerAppenders("Hello", (consoleAppender -> sbt.util.Level.Warn) :: Nil) + LogExchange.bindLoggerAppenders("Hello", (consoleAppender -> sbt.util.Level.Info) :: Nil) l } val compiler = new IncrementalCompilerImpl @@ -77,18 +77,11 @@ object ScalaModule{ val extra = Array(InterfaceUtil.t2(("key", "value"))) var lastCompiledUnits: Set[String] = Set.empty - val progress = new CompileProgress { + val ignoreProgress = new CompileProgress { override def advance(current: Int, total: Int): Boolean = true - - override def startUnit(phase: String, unitPath: String): Unit = { - println(unitPath) - lastCompiledUnits += unitPath - } + override def startUnit(phase: String, unitPath: String): Unit = () } - println("Running Compile") - println(outputPath/'zinc) - println(exists(outputPath/'zinc)) val zincFile = (outputPath/'zinc).toIO val store = FileAnalysisStore.binary(zincFile) val classesDir = (outputPath / 'classes).toIO @@ -110,12 +103,11 @@ object ScalaModule{ compilerCache, IncOptions.of(), reporter, - Some(progress), + Some(ignoreProgress), extra ), pr = { val prev = store.get() - println(prev) PreviousResult.of(prev.map(_.getAnalysis), prev.map(_.getMiniSetup)) } ), -- cgit v1.2.3