diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-11-02 10:53:45 +0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-11-02 11:54:27 +0800 |
commit | 189f950d5ad3634a38652aac320c4fa103ea6100 (patch) | |
tree | e43d73df758bc9f75b1fdd5658461517e7b132c8 /scalalib/worker/src | |
parent | c948427e2c11b412ab7121c4c2804105cde711ae (diff) | |
download | mill-189f950d5ad3634a38652aac320c4fa103ea6100.tar.gz mill-189f950d5ad3634a38652aac320c4fa103ea6100.tar.bz2 mill-189f950d5ad3634a38652aac320c4fa103ea6100.zip |
Fix https://github.com/lihaoyi/mill/issues/475
Diffstat (limited to 'scalalib/worker/src')
-rw-r--r-- | scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala b/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala index 8a3a3b02..78595b14 100644 --- a/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala +++ b/scalalib/worker/src/mill/scalalib/worker/ZincWorkerImpl.scala @@ -49,8 +49,21 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx, @volatile var mixedCompilersCache = Option.empty[(Long, Compilers)] - def docJar(args: Seq[String]): Boolean = { - new scala.tools.nsc.ScalaDoc().process(args.toArray) + def docJar(scalaVersion: String, + compilerBridgeSources: Path, + compilerClasspath: Agg[Path], + scalacPluginClasspath: Agg[Path], + args: Seq[String]) + (implicit ctx: mill.util.Ctx): Boolean = { + val compilers: Compilers = prepareCompilers( + scalaVersion, + compilerBridgeSources, + compilerClasspath, + scalacPluginClasspath + ) + val scaladocClass = compilers.scalac().scalaInstance().loader().loadClass("scala.tools.nsc.ScalaDoc") + val scaladocMethod = scaladocClass.getMethod("process", classOf[Array[String]]) + scaladocMethod.invoke(scaladocClass.newInstance(), args.toArray).asInstanceOf[Boolean] } /** Compile the bridge if it doesn't exist yet and return the output directory. * TODO: Proper invalidation, see #389 @@ -127,6 +140,28 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx, compilerClasspath: Agg[Path], scalacPluginClasspath: Agg[Path]) (implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult] = { + val compilers: Compilers = prepareCompilers( + scalaVersion, + compilerBridgeSources, + compilerClasspath, + scalacPluginClasspath + ) + + compileInternal( + upstreamCompileOutput, + sources, + compileClasspath, + javacOptions, + scalacOptions = scalacPluginClasspath.map(jar => s"-Xplugin:${jar}").toSeq ++ scalacOptions, + compilers + ) + } + + private def prepareCompilers(scalaVersion: String, + compilerBridgeSources: Path, + compilerClasspath: Agg[Path], + scalacPluginClasspath: Agg[Path]) + (implicit ctx: mill.util.Ctx)= { val combinedCompilerClasspath = compilerClasspath ++ scalacPluginClasspath val combinedCompilerJars = combinedCompilerClasspath.toArray.map(_.toIO) @@ -139,7 +174,7 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx, val compilersSig = compilerBridgeSig + - combinedCompilerClasspath.map(p => p.toString().hashCode + p.mtime.toMillis).sum + combinedCompilerClasspath.map(p => p.toString().hashCode + p.mtime.toMillis).sum val compilers = mixedCompilersCache match { case Some((k, v)) if k == compilersSig => v @@ -166,15 +201,7 @@ class ZincWorkerImpl(ctx0: mill.util.Ctx, mixedCompilersCache = Some((compilersSig, compilers)) compilers } - - compileInternal( - upstreamCompileOutput, - sources, - compileClasspath, - javacOptions, - scalacOptions = scalacPluginClasspath.map(jar => s"-Xplugin:${jar}").toSeq ++ scalacOptions, - compilers - ) + compilers } private def compileInternal(upstreamCompileOutput: Seq[CompilationResult], |