diff options
Diffstat (limited to 'src/test/scala/forge/Main.scala')
-rw-r--r-- | src/test/scala/forge/Main.scala | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/test/scala/forge/Main.scala b/src/test/scala/forge/Main.scala index b65099ec..e4e38b23 100644 --- a/src/test/scala/forge/Main.scala +++ b/src/test/scala/forge/Main.scala @@ -1,53 +1,53 @@ package forge import java.io.FileOutputStream -import java.nio.{file => jnio} import java.util.jar.JarEntry import collection.JavaConverters._ +import ammonite.ops._ object Main{ def main(args: Array[String]): Unit = { - val sourceRoot = Target.path(jnio.Paths.get("src/test/resources/example/src")) - val resourceRoot = Target.path(jnio.Paths.get("src/test/resources/example/resources")) + val sourceRoot = Target.path(pwd / 'src / 'test / 'resources / 'example / 'src) + val resourceRoot = Target.path(pwd / 'src / 'test / 'resources / 'example / 'resources) val allSources = list(sourceRoot) val classFiles = compileAll(allSources) val jar = jarUp(resourceRoot, classFiles) // val evaluator = new Evaluator( -// jnio.Paths.get("target/workspace"), +// Paths.get("target/workspace"), // DefCtx("forge.Main ", None) // ) // evaluator.evaluate(OSet(jar)) } - def compileAll(sources: Target[Seq[jnio.Path]]) = { + def compileAll(sources: Target[Seq[Path]]) = { new Target.Subprocess( Seq(sources), args => Seq("javac") ++ - args[Seq[jnio.Path]](0).map(_.toAbsolutePath.toString) ++ - Seq("-d", args.dest.toAbsolutePath.toString) + args[Seq[Path]](0).map(_.toString) ++ + Seq("-d", args.dest.toString) ).map(_.dest) } - def list(root: Target[jnio.Path]): Target[Seq[jnio.Path]] = { - root.map(jnio.Files.list(_).iterator().asScala.toArray[jnio.Path]) + def list(root: Target[Path]): Target[Seq[Path]] = { + root.map(ls.rec) } - case class jarUp(roots: Target[jnio.Path]*) extends Target[jnio.Path]{ + case class jarUp(roots: Target[Path]*) extends Target[Path]{ val inputs = roots - def evaluate(args: Args): jnio.Path = { + def evaluate(args: Args): Path = { - val output = new java.util.jar.JarOutputStream(new FileOutputStream(args.dest.toFile)) + val output = new java.util.jar.JarOutputStream(new FileOutputStream(args.dest.toIO)) for{ root0 <- args.args - root = root0.asInstanceOf[jnio.Path] + root = root0.asInstanceOf[Path] - path <- jnio.Files.walk(root).iterator().asScala - if jnio.Files.isRegularFile(path) + path <- ls.rec(root) + if path.isFile }{ - val relative = root.relativize(path) + val relative = path.relativeTo(root) output.putNextEntry(new JarEntry(relative.toString)) - output.write(jnio.Files.readAllBytes(path)) + output.write(read.bytes(path)) } output.close() args.dest |