Mod note: As of SDK 1.5.0 Scenarios have been superseded by the more powerful Daml Script. We now recommend using that for all purposes. For more information, and to learn how to use Script please check out @Andreas’ post on our blog.
I have defined templates and scenarios in the same file and some scenarios in specific files, this is great during the dev time. But when I prepare the build for production dars can I avoid including scenarios being compiled and bundled in the dars?
If you have the scenarios in the same file then you are stuck at the moment. There is no option in the compiler to omit all scenarios when producing a DAR.
However, if you have them in different files but within the same project you get fairly similar properties to having them in the same file, e.g., changing a template in one file will immediately be picked up by the scenario in another file. And in that case you can make something like this work! The crucial part here is the
source field here. To provide an example, let’s say we have the following file structure:
We assume that the scenarios are in
BTest and let’s also assume the following dependency tree
The crucial part is that there is one module at the root of everything (
BTest) and one module at the root of the modules without scenarios (
B). If you do not have such root modules, create two new modules that just import all other modules.
Now we’re ready to make things work: Create two
daml.yaml files. E.g one in the root directory called
daml.yaml. Give that one a
source: "daml/B.daml" field. Now in another directory, e.g., in a
test subdirectory create another
daml.yamlfile and give that a
source: "../daml/BTest.daml" field. Now if you run
daml build in the root directory you will rceate a DAR that only contains
B whereas running
daml build in the
test directory will include all files including scenarios.