summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-12-04 21:59:13 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-12-04 21:59:13 -0800
commit52f5a07a2b2b3f1885e83d09414aa3da385f4419 (patch)
treeaa8b168383dd7144b2c0aa9d653a97b34e4faabb
parent422d41498d43ad9b437b2d4460f61849e78bb6fa (diff)
downloadmill-52f5a07a2b2b3f1885e83d09414aa3da385f4419.tar.gz
mill-52f5a07a2b2b3f1885e83d09414aa3da385f4419.tar.bz2
mill-52f5a07a2b2b3f1885e83d09414aa3da385f4419.zip
Make more stuff use the implicit `T.ctx()`
-rw-r--r--core/src/main/scala/mill/modules/Jvm.scala9
-rw-r--r--core/src/test/scala/mill/eval/JavaCompileJarTests.scala13
-rw-r--r--scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala4
3 files changed, 13 insertions, 13 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{
diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
index e25d13de..eb9026ba 100644
--- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
+++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
@@ -358,9 +358,7 @@ trait ScalaModule extends Module with TaskModule{ outer =>
def classpath = T{ Seq(resources(), compile()) }
def jar = T{
- val dest = T.ctx().dest
- createJar(dest, Seq(resources(), compile()).map(_.path).filter(exists))
- PathRef(dest)
+ createJar(Seq(resources(), compile()).map(_.path).filter(exists))
}
def run(mainClass: String) = T.command{