summaryrefslogtreecommitdiff
path: root/main/test/resources/examples/javac/build.sc
diff options
context:
space:
mode:
Diffstat (limited to 'main/test/resources/examples/javac/build.sc')
-rw-r--r--main/test/resources/examples/javac/build.sc23
1 files changed, 23 insertions, 0 deletions
diff --git a/main/test/resources/examples/javac/build.sc b/main/test/resources/examples/javac/build.sc
new file mode 100644
index 00000000..0783ac17
--- /dev/null
+++ b/main/test/resources/examples/javac/build.sc
@@ -0,0 +1,23 @@
+import ammonite.ops._
+import mill.T
+import mill.eval.JavaCompileJarTests.compileAll
+import mill.eval.PathRef
+import mill.modules.Jvm
+import mill.util.Loose
+
+def sourceRootPath = millSourcePath / 'src
+def resourceRootPath = millSourcePath / 'resources
+
+// sourceRoot -> allSources -> classFiles
+// |
+// v
+// resourceRoot ----> jar
+def sourceRoot = T.sources{ sourceRootPath }
+def resourceRoot = T.sources{ resourceRootPath }
+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)) }
+
+def run(mainClsName: String) = T.command{
+ %%('java, "-cp", classFiles().path, mainClsName)(T.ctx().dest)
+}