Imports

One justfile can include the contents of another using import statements.

If you have the following justfile:

import 'foo/bar.just'

a: b
  @echo A

And the following text in foo/bar.just:

b:
  @echo B

foo/bar.just will be included in justfile and recipe b will be defined:

$ just b
B
$ just a
B
A

The import path can be absolute or relative to the location of the justfile containing it. A leading ~/ in the import path is replaced with the current users home directory.

Justfiles are insensitive to order, so included files can reference variables and recipes defined after the import statement.

Imported files can themselves contain imports, which are processed recursively.

When allow-duplicate-recipes is set, recipes in parent modules override recipes in imports. In a similar manner, when allow-duplicate-variables is set, variables in parent modules override variables in imports.

Imports may be made optional by putting a ? after the import keyword:

import? 'foo/bar.just'

Importing the same source file multiple times is not an errormaster. This allows importing multiple justfiles, for example foo.just and bar.just, which both import a third justfile containing shared recipes, for example baz.just, without the duplicate import of baz.just being an error:

# justfile
import 'foo.just'
import 'bar.just'
# foo.just
import 'baz.just'
foo: baz
# bar.just
import 'baz.just'
bar: baz
# baz
baz: