Build option to package

Greetings everyone,
I am working on a project where we need to use two different packages that contain two clashing namespaces (let’s call them x-0.0.1 and x-0.0.2).

In order to differentiate between both I am using the build-option on our daml.yaml as demonstrated here:

build-options:
- '--package'
- 'x-0.0.1 with (Asset.Operator.Role as From.Asset.Operator.Role)'
- '--package'
- 'x-0.0.2 with (Asset.Operator.Role as To.Asset.Operator.Role)'

The issue with the following approach is that, for every module I want to import I have to declare a build option similar to the above. For instance, if I wanted to add a asset service as an import, I would do:

build-options:
- '--package'
- 'x-0.0.1 with (Asset.Operator.Role as From.Asset.Operator.Role)'
- '--package'
- 'x-0.0.2 with (Asset.Operator.Role as To.Asset.Operator.Role)'
- '--package'
- 'x-0.0.1 with (Asset.Operator.Role as From.Asset.Service.Role)'
- '--package'
- 'x-0.0.2 with (Asset.Operator.Role as To.Asset.Service.Role)'

Eventually, this results in a very complex daml.yaml file because of all of these build-options. I therefore wonder, if it is possible to achieve the same result in a more elegant way (for instance, an approach that would allow me to import every module within Asset. namespace.

Thank you for your attention

1 Like

You can use module-prefixes field in daml.yaml file to assign a prefix to all modules in a package. See the bottom of this page in the documentation.
E.g. the following entry in daml.yaml file

module-prefixes:
  x-0.0.1: From
  x-0.0.2: To

allows you to import modules from x-0.0.1 and x-0.0.2 using

import qualified From.Asset.Operator.Role
import qualified To.Asset.Operator.Role
import qualified From.Asset.Service.Role
import qualified To.Asset.Service.Role