Building multiple dar variants from a single daml project source code

I was attempting to build several variants dars from a single daml project source code during a script run without manual intervention and @Richard_Kapolnai provided a good suggestion for accomplishing this detailed below in:

In my scenario, I am attempting to build 2 dars with incremental dar versions built using Daml SDKs 2.3.7 and 2.9.7 respectively.

To accomplish this, 2 daml.yaml files with differing project versions and SDK versions, but referring to the same daml source code can be set up in their individual folders. These daml.yaml-containing folders can be anywhere in the system, as long as the source path variable defined in the daml.yaml files correctly point to the daml folder in which the daml source code is contained.

My set up example directory structure along with the accompanying daml.yaml files is shown below:

--------project-root
|    |------src
|         |---daml (contains daml source code)
|
|---------dar-2.3.7
|     |-----daml.yaml
|
|---------dar-2.9.7
      |-----daml.yaml

daml.yaml (in dar-2.3.7 folder)

sdk-version: 2.3.7
name: daml-project
source: ../src/daml
version: 1.0.0

daml.yaml (in dar-2.9.7 folder)

sdk-version: 2.9.7
name: daml-project
source: ../src/daml
version: 1.0.1

Running daml build within the dar-2.3.7 and dar-2.9.7 folders will produce a dar with the properties defined by each folder’s daml.yaml file within each folder.
The dars will be generated in each folder’s .daml/dist/ folder as is the case when normally building a daml project.

Additionally, these folders can also be specified as packages to be built in a multi-package.yaml in the project-root folder to automatically build the dars defined by each daml.yaml when executing daml build --all from the project-root folder.

multi-package.yaml (in project-root folder)

packages:
- ./dar-2.3.7
- ./dar-2.9.7
3 Likes

Daml Assistant’s Environment Variable Interpolation is another useful technique:

sdk-version: ${SDK_VERSION}
name: ${DAR_NAME}
source: daml
version: ${DAR_VERSION}
       :
3 Likes