From 8c360c652902b9ccf13060ea1fd050bf473bf2d8 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sat, 3 Mar 2018 11:14:22 -0800 Subject: Split out `upstreamAssembly` from `assembly` Also re-write `Jvm.createAssembly` to allow incremental assembly construction. This should allow much faster assembly creation in the common case where upstream dependencies do not change --- scalalib/src/mill/scalalib/ScalaModule.scala | 36 ++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'scalalib/src') diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala index c7dbc322..5a355bc6 100644 --- a/scalalib/src/mill/scalalib/ScalaModule.scala +++ b/scalalib/src/mill/scalalib/ScalaModule.scala @@ -2,16 +2,15 @@ package mill package scalalib import ammonite.ops._ -import coursier.{Cache, MavenRepository, Repository} -import mill.define.{Cross, Task} +import coursier.Repository +import mill.define.Task import mill.define.TaskModule import mill.eval.{PathRef, Result} import mill.modules.Jvm -import mill.modules.Jvm.{createAssembly, createJar, interactiveSubprocess, runLocal, subprocess} +import mill.modules.Jvm.{createAssembly, createJar, subprocess} import Lib._ -import mill.define.Cross.Resolver import mill.util.Loose.Agg -import mill.util.{DummyInputStream, Strict} +import mill.util.DummyInputStream /** * Core configuration required to compile a single Scala compilation target @@ -144,6 +143,7 @@ trait ScalaModule extends mill.Module with TaskModule { outer => if path.isFile && (path.ext == "scala" || path.ext == "java") } yield PathRef(path) } + def compile: T[CompilationResult] = T.persistent{ scalaWorker.worker().compileScala( scalaVersion(), @@ -165,19 +165,35 @@ trait ScalaModule extends mill.Module with TaskModule { outer => resolveDeps(T.task{compileIvyDeps() ++ scalaLibraryIvyDeps() ++ transitiveIvyDeps()})() } - def runClasspath = T{ + def upstreamAssemblyClasspath = T{ upstreamRunClasspath() ++ - Agg(compile().classes) ++ - resources() ++ unmanagedClasspath() ++ resolveDeps(T.task{runIvyDeps() ++ scalaLibraryIvyDeps() ++ transitiveIvyDeps()})() } + def runClasspath = T{ + Agg(compile().classes) ++ + resources() ++ + upstreamAssemblyClasspath() + + } + + /** + * Build the assembly for upstream dependencies separate from the current classpath + * + * This should allow much faster assembly creation in the common case where + * upstream dependencies do not change + */ + def upstreamAssembly = T{ + createAssembly(upstreamAssemblyClasspath().map(_.path), mainClass()) + } + def assembly = T{ createAssembly( - runClasspath().map(_.path).filter(exists), + Agg.from(resources().map(_.path)) ++ Agg(compile().classes.path), mainClass(), - prependShellScript = prependShellScript() + prependShellScript(), + Some(upstreamAssembly().path) ) } -- cgit v1.2.3