diff --git a/docs/manual/CoreTasks/import.html b/docs/manual/CoreTasks/import.html index bc1627543..cae307825 100644 --- a/docs/manual/CoreTasks/import.html +++ b/docs/manual/CoreTasks/import.html @@ -61,7 +61,48 @@ I can get its path as ant.file.builddocs, similarly to the ant.file Note that "builddocs" is not the filename, but the name attribute present in the imported project tag.
-
+ +
+Resolving files against the imported file + +

Suppose your main build file called importing.xml +imports a build file imported.xml, located anywhere on +the file system, and imported.xml reads a set of +properties from imported.properties:

+ +
<-- importing.xml -->
+<project name="importing" basedir="." default="...">
+  <import file="${path_to_imported}/imported.xml"/>
+</project>
+
+<-- imported.xml -->
+<project name="imported" basedir="." default="...">
+  <property file="imported.properties"/>
+</project>
+
+ +

This snippet however will resolve imported.properties +against the basedir of importing.xml, because the basedir +of imported.xml is ignored by Ant. The right way to use +imported.properties is:

+ +
+<-- imported.xml -->
+<project name="imported" basedir="." default="...">
+  <dirname property="imported.basedir" file="${ant.file.imported}"/>
+  <property file="${imported.basedir}/imported.properties"/>
+</project>
+
+ +

As explained above ${ant.file.imported} stores the +path of the build script, that defines the project called +imported, (in short it stores the path to +imported.xml) and <dirname> takes its +directory. This technique also allows imported.xml to be +used as a standalone file (without being imported in other +project).

+

Parameters