bodewig 2004/06/29 02:01:53 Modified: docs/manual/CoreTasks import.html Log: How to resolve files in imported build files by Ivan Ivanov Revision Changes Path 1.14 +42 -1 ant/docs/manual/CoreTasks/import.html Index: import.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/import.html,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- import.html 29 Apr 2004 10:13:17 -0000 1.13 +++ import.html 29 Jun 2004 09:01:53 -0000 1.14 @@ -61,7 +61,48 @@ property of the main buildfile.<br /> Note that "builddocs" is not the filename, but the name attribute present in the imported project tag.<br /> -<br /> + +<br/> +<b>Resolving files against the imported file</b> + +<p>Suppose your main build file called <code>importing.xml</code> +imports a build file <code>imported.xml</code>, located anywhere on +the file system, and <code>imported.xml</code> reads a set of +properties from <code>imported.properties</code>:</p> + +<pre><-- 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> +</pre> + +<p>This snippet however will resolve <code>imported.properties</code> +against the basedir of <code>importing.xml</code>, because the basedir +of <code>imported.xml</code> is ignored by Ant. The right way to use +<code>imported.properties</code> is:</p> + +<pre> +<-- imported.xml --> +<project name="imported" basedir="." default="..."> + <dirname property="imported.basedir" file="${ant.file.imported}"/> + <property file="${imported.basedir}/imported.properties"/> +</project> +</pre> + +<p>As explained above <code>${ant.file.imported}</code> stores the +path of the build script, that defines the project called +<code>imported</code>, (in short it stores the path to +<code>imported.xml</code>) and <a +href="dirname.html"><code><dirname></code></a> takes its +directory. This technique also allows <code>imported.xml</code> to be +used as a standalone file (without being imported in other +project).</p> + <h3>Parameters</h3> <table border="1" cellpadding="2" cellspacing="0"> <tbody>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]