Scala/Mill: Step 6, Creating a Fat Jar (assembly)

When using the Scala Mill build tool, if you want to create a “fat jar” file that contains all of the classes from your application and all of its dependencies, use the Mill assembly command.

For example, I have a project named RssAtomReader, so to create a fat jar file I use this assembly command:

$ mill RssAtomReader.assembly

While Mill currently doesn’t show the output of that command — hopefully it will in the future — you can find the fat jar file at this location:

./out/RssAtomReader/assembly/dest/out.jar

Resource files

If you have any resource files that your application needs, place them in a resources folder at the same level as your src folder. This tree command shows what I mean:

$ tree .
.
├── HelloWorld
│   ├── lib
│   │   └── stringutils_2.12-1.0.jar
│   ├── resources
│   │   └── application.conf
│   └── src
│       └── main
│           └── scala
│               └── hello
│                   └── Hello.scala
├── build.sc

This is different than the typical Maven/SBT directory structure, but I just tested it with the Mill assembly command and it places the resource file in the fat jar file it creates.

books i’ve written