Generate sources from IDL

While it is possible to use Mu by hand-writing your service definitions, message classes and clients in Scala, we recommend you use sbt-mu-srcgen to generate this code from Protobuf/Avro/OpenAPI IDL files.

IDL files are language-agnostic, more concise than Scala code, easily shared with 3rd parties, and supported by a lot of existing tools.

Mu can generate code from a number of different IDL formats:

Plugin Installation

Add the following line to project/plugins.sbt:

addSbtPlugin("io.higherkindness" % "sbt-mu-srcgen" % "0.26.0")


For users of the sbt-mu-srcgen plugin v0.22.x and below, the plugin is enabled automatically as soon as it’s added to the project/plugins.sbt. However, for users of the sbt-mu-srcgen plugin v0.23.x and beyond, the plugin needs to be manually enabled for any module for which you want to generate code. To enable the module, add the following line to your build.sbt


Once the plugin is installed and enabled, you can configure it

How to use the plugin

The muSrcGen sbt task generates Scala source code from IDL files.

The plugin will automatically integrate the source generation into your compile process, so the sources are generated before compilation when you run the compile task.

You can also run the sbt task manually:

```shell script sbt muSrcGen

## Import

You will need to add this import at the top of your `build.sbt`:



For an explanation of the plugin’s settings, see the source generation reference.