Reference: DAML packages¶
This page gives reference information on DAML package dependencies:
When a DAML project is build with
daml build, build artifacts are generated in the hidden
.daml/dist/ relative to the project root directory. The main build artifact of a
project is the DAML archive, recognized by the
.dar file ending. DAML archives are platform
independent. They can be deployed on a ledger (see deploy) or can be
imported into other projects as a package dependency.
A DAML project can import DAML archive dependencies. Note that currently there is no tooling for
DAML package management. To import a package
Bar in project
Foo, add the file path of the
Bar DAML archive to the
dependencies section of the daml.yaml project file:
sdk-version: 0.0.0 name: foo source: daml version: 1.0.0 exposed-modules: - Some.Module - Some.Other.Module dependencies: - daml-prim - daml-stdlib - /home/johndoe/bar/.daml/dist/bar-1.0.0.dar
The import path needs to be the relative or absolute path pointing to the created DAML archive of
bar project. The archive can reside anywhere on the local file system. Note that the SDK
versions of the packages
bar need to match, i.e. it is an error to import a package
that was created with an older SDK.
Once a package has been added to the dependencies of the
foo project, modules of
bar can be
imported as usual with the
import Some.Module directive (see Imports).
If both projects
foo as well as
bar contain a module with the same name, the import can be
disambiguated by adding the package name in front of the module name, e.g.
Note that all modules of package
foo that should be available as imports of other packages need
to be exposed by adding them to the
exposed-modules stanza of the daml.yaml file. If the
exposed-modules stanza is omitted, all modules of the project are exposed by default.
All DAML archive dependencies of a project need to be compiled with the same SDK as the project
itself. However, it is possible to import templates and data types of an archive compiled with an
older SDK, by listing them under the
sdk-version: 0.0.0 name: foo source: daml version: 1.0.0 exposed-modules: - Some.Module - Some.Other.Module dependencies: - daml-prim - daml-stdlib - /home/johndoe/bar/.daml/dist/bar.dar data-dependencies: - /home/jondoe/bar-0.0.0/.daml/dist/bar-0.0.0.dar
Modules from data dependencies can be imported as usual, but need to be qualified by the (generated) instances package:
import "instances-bar" Foo