Skip to content

Commit 3945ce4

Browse files
committed
Adding documentation for foreign-modules
1 parent ff5cf2b commit 3945ce4

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

docs/pages/5 - Modules.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,41 @@ that is shared by the entire build: for example,
155155
`mill.scalalib.ScalaWorkerApi/scalaWorker` provides a shared Scala compilation
156156
service & cache that is shared between all `ScalaModule`s, and
157157
`mill.scalalib.GenIdea/idea` lets you generate IntelliJ projects without
158-
needing to define your own `T.command` in your `build.sc` file
158+
needing to define your own `T.command` in your `build.sc` file
159+
160+
## Foreign Modules
161+
162+
Mill can load other mill projects from external (or sub) directories,
163+
using Ammonite's `$file` magic import, allowing to depend on foreign modules.
164+
This allows, for instance, to depend on other projects' sources, or split
165+
your build logic into smaller files.
166+
167+
168+
For instance, assuming the following stucture :
169+
170+
```text
171+
foo/
172+
build.sc
173+
bar/
174+
build.sc
175+
baz/
176+
build.sc
177+
```
178+
179+
you can write the following in `foo/build.sc` :
180+
181+
```scala
182+
183+
import $file.bar.build
184+
import $file.^.baz.build
185+
import mill._
186+
187+
def someFoo = T {
188+
189+
^.baz.build.someBaz(...)
190+
bar.build.someBar(...)
191+
...
192+
}
193+
```
194+
195+
The output of the foreign tasks will be cached under `foo/out/foreign-modules/`.

0 commit comments

Comments
 (0)