summaryrefslogtreecommitdiff
path: root/docs/pages/3 - Common Project Layouts.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/pages/3 - Common Project Layouts.md')
-rw-r--r--docs/pages/3 - Common Project Layouts.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/docs/pages/3 - Common Project Layouts.md b/docs/pages/3 - Common Project Layouts.md
index a0e3afbe..a53fb1b1 100644
--- a/docs/pages/3 - Common Project Layouts.md
+++ b/docs/pages/3 - Common Project Layouts.md
@@ -4,6 +4,50 @@ Earlier, we have shown how to work with the Mill default Scala module layout.
Here we will explore some other common project layouts that you may want in your
Scala build:
+### Java Project with Test Suite
+
+```scala
+trait JUnitTests extends TestModule{
+ def testFrameworks = Seq("com.novocode.junit.JUnitFramework")
+ def ivyDeps = Agg(ivy"com.novocode:junit-interface:0.11")
+}
+
+object core extends JavaModule{
+ object test extends Tests with JUnitTests
+}
+object app extends JavaModule{
+ def moduleDeps = Seq(core)
+ object test extends Tests with JUnitTests
+}
+```
+
+This build is a two-module Java project with junit test suites. It expects the
+following filesystem layout:
+
+```text
+build.sc
+app/
+ src/hello/
+ Main.java
+ test/src/hello/
+ MyAppTests.java
+core/
+ src/hello/
+ Core.java
+ test/src/hello/
+ MyCoreTests.java
+```
+
+You can then run the junit tests using `mill app.test` or `mill core.test`, and
+configure which exact tests you want to run using the flags defined on the
+[JUnit Test Interface](https://github.com/sbt/junit-interface#junit-interface).
+
+For a more more complex, real-world example of a Java build, check out our
+example build for the popular [Caffeine](https://github.com/ben-manes/caffeine)
+project:
+
+- [Example Build](https://github.com/lihaoyi/mill/blob/master/integration/test/resources/caffeine/build.sc)
+
### Cross Scala-Version Modules
```scala