diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-04 21:59:13 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-04 21:59:13 -0800 |
commit | 52f5a07a2b2b3f1885e83d09414aa3da385f4419 (patch) | |
tree | aa8b168383dd7144b2c0aa9d653a97b34e4faabb /core | |
parent | 422d41498d43ad9b437b2d4460f61849e78bb6fa (diff) | |
download | mill-52f5a07a2b2b3f1885e83d09414aa3da385f4419.tar.gz mill-52f5a07a2b2b3f1885e83d09414aa3da385f4419.tar.bz2 mill-52f5a07a2b2b3f1885e83d09414aa3da385f4419.zip |
Make more stuff use the implicit `T.ctx()`
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/scala/mill/modules/Jvm.scala | 9 | ||||
-rw-r--r-- | core/src/test/scala/mill/eval/JavaCompileJarTests.scala | 13 |
2 files changed, 12 insertions, 10 deletions
diff --git a/core/src/main/scala/mill/modules/Jvm.scala b/core/src/main/scala/mill/modules/Jvm.scala index 74eecba4..a2277e36 100644 --- a/core/src/main/scala/mill/modules/Jvm.scala +++ b/core/src/main/scala/mill/modules/Jvm.scala @@ -31,10 +31,11 @@ object Jvm { m } - def createJar(outputPath: Path, inputPaths: Seq[Path], mainClass: Option[String] = None): Option[Path] = { + def createJar(inputPaths: Seq[Path], mainClass: Option[String] = None) + (implicit ctx: Ctx.DestCtx): PathRef = { + val outputPath = ctx.dest rm(outputPath) - if(inputPaths.isEmpty) None - else { + if(inputPaths.nonEmpty) { mkdir(outputPath/up) val jar = new JarOutputStream( @@ -60,8 +61,8 @@ object Jvm { jar.close() } - Some(outputPath) } + PathRef(outputPath) } diff --git a/core/src/test/scala/mill/eval/JavaCompileJarTests.scala b/core/src/test/scala/mill/eval/JavaCompileJarTests.scala index 72e8c858..6c32f9b8 100644 --- a/core/src/test/scala/mill/eval/JavaCompileJarTests.scala +++ b/core/src/test/scala/mill/eval/JavaCompileJarTests.scala @@ -5,16 +5,17 @@ import ammonite.ops._ import mill.define.{Target, Task} import mill.discover.Discovered import mill.modules.Jvm.jarUp -import mill.{T, Module} +import mill.util.Ctx.DestCtx +import mill.{Module, T} import mill.util.OSet import utest._ object JavaCompileJarTests extends TestSuite{ - def compileAll(dest: Path, sources: Seq[PathRef]) = { - mkdir(dest) + def compileAll(sources: Seq[PathRef])(implicit ctx: DestCtx) = { + mkdir(ctx.dest) import ammonite.ops._ - %("javac", sources.map(_.path.toString()), "-d", dest)(wd = dest) - PathRef(dest) + %("javac", sources.map(_.path.toString()), "-d", ctx.dest)(wd = ctx.dest) + PathRef(ctx.dest) } val tests = Tests{ @@ -37,7 +38,7 @@ object JavaCompileJarTests extends TestSuite{ def sourceRoot = T.source{ sourceRootPath } def resourceRoot = T.source{ resourceRootPath } def allSources = T{ ls.rec(sourceRoot().path).map(PathRef(_)) } - def classFiles = T{ compileAll(T.ctx().dest, allSources()) } + def classFiles = T{ compileAll(allSources()) } def jar = T{ jarUp(resourceRoot, classFiles) } def run(mainClsName: String) = T.command{ |