summaryrefslogtreecommitdiff
path: root/src/main/scala/hbt/Util.scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-10-18 21:16:19 -0700
committerLi Haoyi <haoyi.sg@gmail.com>2017-10-18 21:16:19 -0700
commit538b5ac28b80285953dbea08651cf5c5afa7c0f9 (patch)
tree22cd2d1dfe2d172124a466b8a0ecf6fff35c9634 /src/main/scala/hbt/Util.scala
parent2eab2548bdfe49f246cecfb8718632a84df68342 (diff)
downloadmill-538b5ac28b80285953dbea08651cf5c5afa7c0f9.tar.gz
mill-538b5ac28b80285953dbea08651cf5c5afa7c0f9.tar.bz2
mill-538b5ac28b80285953dbea08651cf5c5afa7c0f9.zip
Basic evaluator that creates classfiles and a jar now works
Diffstat (limited to 'src/main/scala/hbt/Util.scala')
-rw-r--r--src/main/scala/hbt/Util.scala43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/main/scala/hbt/Util.scala b/src/main/scala/hbt/Util.scala
index a7456b56..fef4009b 100644
--- a/src/main/scala/hbt/Util.scala
+++ b/src/main/scala/hbt/Util.scala
@@ -10,43 +10,52 @@ import scala.collection.JavaConverters._
import scala.collection.mutable
object Util{
- def compileAll(sources: Target[Seq[jnio.Path]])
- (implicit path: Enclosing): Target[jnio.Path] = {
- for(sources0 <- sources) yield {
- val output = jnio.Paths.get(path.value)
- jnio.Files.createDirectories(output)
+ case class compileAll(sources: Target[Seq[jnio.Path]])
+ (implicit path: Enclosing) extends Target[jnio.Path]{
+ val label = path.value
+ val inputs = Seq(sources)
+ def evaluate(args: Args): jnio.Path = {
+
+ jnio.Files.createDirectories(args.dest)
val command =
Seq("scalac") ++
- sources0.map(_.toString) ++
- Seq("-d", path.value)
-
+ args[Seq[jnio.Path]](0).map(_.toString) ++
+ Seq("-d", args.dest.toString)
-
- new java.lang.ProcessBuilder()
+ val result = new java.lang.ProcessBuilder()
.command(command: _*)
.start()
.waitFor()
- output
+ args.dest
}
}
def list(root: Target[jnio.Path]): Target[Seq[jnio.Path]] = {
root.map(jnio.Files.list(_).iterator().asScala.toArray[jnio.Path])
}
- def jarUp(roots: Target[jnio.Path]*)(implicit path: Enclosing): Target[jnio.Path] = {
- for(rootsValue <- Target.traverse(roots)) yield {
- val output = new java.util.jar.JarOutputStream(new FileOutputStream(path.value))
+ case class jarUp(roots: Target[jnio.Path]*)(implicit path: Enclosing) extends Target[jnio.Path]{
+ val label = path.value
+ val inputs = roots
+ def evaluate(args: Args): jnio.Path = {
+
+ val output = new java.util.jar.JarOutputStream(new FileOutputStream(args.dest.toFile))
for{
- root <- rootsValue
- path <- jnio.Files.list(root).iterator().asScala
+ root0 <- args.args
+ root = root0.asInstanceOf[jnio.Path]
+
+ path <- jnio.Files.walk(root).iterator().asScala
+ if jnio.Files.isRegularFile(path)
}{
val relative = root.relativize(path)
output.putNextEntry(new JarEntry(relative.toString))
output.write(jnio.Files.readAllBytes(path))
}
- jnio.Paths.get(path.value)
+ output.close()
+ args.dest
}
+
+
}