References
References allow the usage of tasks defined in other build files. They can be used to split up tasks into separate files.
Each build file can have a references map pointing at other build files. The
referenced file brings in more tasks and services, which you can then use directly
from the cli or as task dependencies.
references:
foo: project/footasks:
example:
cmds:
- echo "foo bar"Naming and prefixes
A referenced task is addressed as <prefix>:<taskName>, where the prefix is the
key you gave it in the references map. The example task above becomes
foo:example:
hammerkit foo:exampleThe same prefix:name syntax is what you use in deps and needs:
references:
foo: project/foo
tasks:
build:
deps: [foo:example]
cmds:
- echo "after foo"References can be nested — a referenced file can have its own references — and the
prefixes stack (foo:bar:task). This same prefix rule is shared with
includes and extend.
References keep their own working directory
The key difference from includes: a referenced task runs with its
own directory as the working directory. Commands and relative src/generates
paths resolve against the referenced file's location, not yours. Use a reference
when the other file is a real project in its own right; use an include when you
want to reuse a task definition in the current project's directory.
Build-file envs do not cross a reference. Variables declared at the top level
of one file are not visible to a referenced (or included) file —
each file's envs are scoped to that file. Declare the variables a referenced task
needs in that file (or on the task itself).
Environment Variables
Environment variables come from three sources: the shell environment, .env files and values defined in the build file.
Includes
Includes are similar to references, with one key difference: the working directory. An included build file runs in the directory of the file that includes it.