diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-03-03 11:14:22 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-03-03 11:33:53 -0800 |
commit | 8c360c652902b9ccf13060ea1fd050bf473bf2d8 (patch) | |
tree | cd7d72f9fb785d193163ae768b46eea234f10b6d /scalalib/src | |
parent | 4edb1740397f6328177042a55a1404e42c1d6439 (diff) | |
download | mill-8c360c652902b9ccf13060ea1fd050bf473bf2d8.tar.gz mill-8c360c652902b9ccf13060ea1fd050bf473bf2d8.tar.bz2 mill-8c360c652902b9ccf13060ea1fd050bf473bf2d8.zip |
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
Diffstat (limited to 'scalalib/src')
-rw-r--r-- | scalalib/src/mill/scalalib/ScalaModule.scala | 36 |
1 files changed, 26 insertions, 10 deletions
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) ) } |