How to build dars but not include scenarios?

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:

- daml/A.daml
- daml/B.daml
- daml/ATest.daml
- daml/BTest.daml 

We assume that the scenarios are in ATest and BTest and let’s also assume the following dependency tree

BTest
  - ATest
    - A
  - B
     - A

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 A and B whereas running daml build in the test directory will include all files including scenarios.

4 Likes