Imports
Imports provide a way to split your pulse™ file among multiple physical files, which can be useful both for logical separation and sharing. Imported files, similar to macros, are treated as fragments of XML which are evaluated in the context where they are imported.
A file designed for importing can have an arbitrary root element - it is only used as a container. The imported fragment consists of the child nodes of the root. This fragment can be an arbitrary chunk of XML, but it must be valid when evaluated at the point of import. An imported file may import other files and so on arbitrarily (more properly, until a depth limit is hit, although this should not happen in practice).
Attributes
| Attribute |
Description |
Required |
Default |
| path |
The path of the file to include, with elements separated always by forward slashes. The path is relative to the including file unless it begins with a slash, in which case it is relative to the base directory. |
Yes |
|
| optional |
If specified and true, the import is considered as optional and any error locating the file to import is ignored. |
No |
false |
Child Elements
None.
Examples
In this example, we import a recipe's commands from another file nested in an "import" subdirectory. This allows the repeated commands to be captured once:
<?xml version="1.0"?>
<root>
<make name="build" targets="all" args="-Dmode=${mode}"/>
<make name="test" targets="test" args="-Dmode=${mode}"/>
</root>
<?xml version="1.0"?>
<project default-recipe="debug">
<recipe name="debug">
<property name="mode" value="DEBUG"/>
<import path="import/commands.xml"/>
</recipe>
<recipe name="release">
<property name="mode" value="RELEASE"/>
<import path="import/commands.xml"/>
</recipe>
</project>