Build multiple DAML files

Hey DAML’ers

This may be a simple question…

If I have a main.daml and ScriptExample.daml

How can I build them at the same time ?

Based on my daml.yaml it currently only builds the first one, not the second one.

Thanks

3 Likes

The DAML source files that are part of your project are defined by the source field in your daml.yaml. There are two possible formats here:

  1. source points to a directory. In that case, all DAML files recursively contained within that directory are part of the project and will be built. So in this case, just set it to the directory (daml is a common name for the directory containing your source files) and it should work out.
  2. source points to an individual file. In this case, the file and all files transitively referenced by this file (via imports) are part of the project. If either ScriptExample.daml imports Main.daml, you can set source: ScriptExample.daml and both will be built (or the other way around if Main imports ScriptExample). If neither of them imports the other and you do not want to add an import, then you can add a third module that imports both (LibraryModules.daml is a popular name for that).

I would recommend 1 for pretty much all usecases. Much easier to keep up2date without having to manage a file that imports everything. Originally, we only supported 2 so you’ll still see this in a few examples and it can still occasionally come in handy if you only want to build a subset of a project (e.g., because the full project doesn’t compile atm) but that’s usually a temporary situation.

3 Likes

Thanks. Solved it

3 Likes