summaryrefslogtreecommitdiff
path: root/core/src/test/examples/javac/build.sc
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/examples/javac/build.sc')
-rw-r--r--core/src/test/examples/javac/build.sc69
1 files changed, 0 insertions, 69 deletions
diff --git a/core/src/test/examples/javac/build.sc b/core/src/test/examples/javac/build.sc
deleted file mode 100644
index e4f7ea01..00000000
--- a/core/src/test/examples/javac/build.sc
+++ /dev/null
@@ -1,69 +0,0 @@
-import mill.define.Task
-import mill.eval.PathRef
-
-object Foo {
-
- import java.io.FileOutputStream
- import java.util.jar.JarEntry
-
- import ammonite.ops.{ls, pwd, read}
- import mill.discover.Discovered
- import mill.util.Ctx
-
- val workspacePath = pwd / 'target / 'workspace / 'javac
- val javacSrcPath = pwd / 'src / 'test / 'examples / 'javac
- val javacDestPath = workspacePath / 'src
-
- val sourceRootPath = javacDestPath / 'src
- val resourceRootPath = javacDestPath / 'resources
-
- // sourceRoot -> allSources -> classFiles
- // |
- // v
- // resourceRoot ----> jar
- val sourceRoot = Task.path(sourceRootPath)
- val resourceRoot = Task.path(resourceRootPath)
- val allSources = list(sourceRoot)
- val classFiles = compileAll(allSources)
- val jar = jarUp(resourceRoot, classFiles)
-
- def compileAll(sources: Task[Seq[PathRef]]) = {
- new Task.Subprocess(
- Seq(sources),
- args =>
- Seq("javac") ++
- args[Seq[PathRef]](0).map(_.path.toString) ++
- Seq("-d", args.dest.toString)
- ).map(_.dest)
- }
-
- def list(root: Task[PathRef]): Task[Seq[PathRef]] = {
- root.map(x => ls.rec(x.path).map(PathRef(_)))
- }
-
- case class jarUp(roots: Task[PathRef]*) extends Task[PathRef] {
-
- val inputs = roots
-
- def evaluate(args: Ctx): PathRef = {
-
- val output = new java.util.jar.JarOutputStream(new FileOutputStream(args.dest.toIO))
- for {
- root0 <- args.args
- root = root0.asInstanceOf[PathRef]
-
- path <- ls.rec(root.path)
- if path.isFile
- } {
- val relative = path.relativeTo(root.path)
- output.putNextEntry(new JarEntry(relative.toString))
- output.write(read.bytes(path))
- }
- output.close()
- args.dest
- }
- }
-
-}
-
-@main def main(): Any = Foo -> mill.Discovered[Foo.type]