diff options
author | Jim Lawson <ucbjrl@berkeley.edu> | 2018-10-09 10:16:59 -0700 |
---|---|---|
committer | Tobias Roeser <le.petit.fou@web.de> | 2018-10-28 22:20:34 +0100 |
commit | f3ec25bccab8ee94ad30d86b56d7cc3c3ca610a4 (patch) | |
tree | 2fd622ba815762383f429083e80277ede527cf3f /main/test/src | |
parent | c854d55b8cfb0481a76ee6886cb31275fe8d5ffe (diff) | |
download | mill-f3ec25bccab8ee94ad30d86b56d7cc3c3ca610a4.tar.gz mill-f3ec25bccab8ee94ad30d86b56d7cc3c3ca610a4.tar.bz2 mill-f3ec25bccab8ee94ad30d86b56d7cc3c3ca610a4.zip |
Add a filter parameter (default true for all files) to createJar().
Add createJar() filter test.
Diffstat (limited to 'main/test/src')
-rw-r--r-- | main/test/src/mill/eval/JavaCompileJarTests.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/main/test/src/mill/eval/JavaCompileJarTests.scala b/main/test/src/mill/eval/JavaCompileJarTests.scala index 37e4c119..e6d1c10a 100644 --- a/main/test/src/mill/eval/JavaCompileJarTests.scala +++ b/main/test/src/mill/eval/JavaCompileJarTests.scala @@ -39,6 +39,8 @@ object JavaCompileJarTests extends TestSuite{ def allSources = T{ sourceRoot().flatMap(p => ls.rec(p.path)).map(PathRef(_)) } def classFiles = T{ compileAll(allSources()) } def jar = T{ Jvm.createJar(Loose.Agg(classFiles().path) ++ resourceRoot().map(_.path)) } + // Test createJar() with optional file filter. + def filterJar(fileFilter: (Path, RelPath) => Boolean) = T{ Jvm.createJar(Loose.Agg(classFiles().path) ++ resourceRoot().map(_.path), None, fileFilter) } def run(mainClsName: String) = T.command{ %%('java, "-Duser.language=en", "-cp", classFiles().path, mainClsName) @@ -116,6 +118,13 @@ object JavaCompileJarTests extends TestSuite{ |""".stripMargin assert(jarContents.lines.toSeq == expectedJarContents.lines.toSeq) + // Create the Jar again, but this time, filter out the Foo files. + def noFoos(s: String) = !s.contains("Foo") + val filterFunc = (p: Path, r: RelPath) => noFoos(r.last) + filterJar(filterFunc) + val filteredJarContents = %%('jar, "-tf", evaluator.outPath/'filterJar/'dest/"out.jar")(evaluator.outPath).out.string + assert(filteredJarContents.lines.toSeq == expectedJarContents.lines.filter(noFoos(_)).toSeq) + val executed = %%('java, "-cp", evaluator.outPath/'jar/'dest/"out.jar", "test.Foo")(evaluator.outPath).out.string assert(executed == (31337 + 271828) + System.lineSeparator) |