You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

import.html 4.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Language" content="en-us">
  5. <title>Import Task</title>
  6. <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
  7. </head>
  8. <body>
  9. <h2><a name="import">Import</a></h2>
  10. <h3>Description</h3>
  11. <p>
  12. Imports another build file into the current project.
  13. </p>
  14. <p>
  15. On execution it will read another Ant file into
  16. the same Project. This means that it basically works like the
  17. <a href="http://ant.apache.org/faq.html#xml-entity-include">Entity
  18. Includes as explained in the Ant FAQ</a>, as if the imported file was
  19. contained in the importing file, minus the top <code>&lt;project&gt;</code>
  20. tag.
  21. </p>
  22. <p>
  23. The import task may only be used as a top-level task. This means that
  24. it may not be used in a target.
  25. </p>
  26. <p>
  27. There are two further functional aspects that pertain to this task and
  28. that are not possible with entity includes:
  29. <ul>
  30. <li>target overriding</li>
  31. <li>special properties</li>
  32. </ul>
  33. </p>
  34. <b>Target overriding</b><br />
  35. <br />
  36. If a target in the main file is also present in at least one of the
  37. imported files, it takes precedence.<br />
  38. <br />
  39. So if I import for example a <i>docsbuild.xml</i> file named <b>builddocs</b>,
  40. that contains a &quot;<b>docs</b>&quot; target, I can redefine it in my main
  41. buildfile and that is the one that will be called. This makes it easy to
  42. keep the same target name, so that the overriding target is still called
  43. by any other targets--in either the main or imported buildfile(s)--for which
  44. it is a dependency, with a different implementation. The original target is
  45. made available by the name &quot;<b>builddocs</b><b>.docs</b>&quot;.
  46. This enables the new implementation to call the old target, thus
  47. <i>enhancing</i> it with tasks called before or after it.<br />
  48. <br />
  49. <b>Special Properties</b><br />
  50. <br />
  51. Imported files are treated as they are present in the main
  52. buildfile. This makes it easy to understand, but it makes it impossible
  53. for them to reference files and resources relative to their path.
  54. Because of this, for every imported file, Ant adds a property that
  55. contains the path to the imported buildfile. With this path, the
  56. imported buildfile can keep resources and be able to reference them
  57. relative to its position.<br />
  58. <br />
  59. So if I import for example a <i>docsbuild.xml</i> file named <b>builddocs</b>,
  60. I can get its path as <b>ant.file.builddocs</b>, similarly to the <b>ant.file</b>
  61. property of the main buildfile.<br />
  62. Note that &quot;builddocs&quot; is not the filename, but the name attribute
  63. present in the imported project tag.<br />
  64. <br />
  65. <b>Important</b>: We have not finalized how relative file references
  66. will be resolved in deep/complex build hierarchies -such as what
  67. happens when an imported file imports another file. Use absolute
  68. references for enhanced build file stability, especially in the
  69. imported files.<br />
  70. &nbsp;<br />
  71. <h3>Parameters</h3>
  72. <table border="1" cellpadding="2" cellspacing="0">
  73. <tbody>
  74. <tr>
  75. <td valign="top"><b>Attribute</b></td>
  76. <td valign="top"><b>Description</b></td>
  77. <td align="center" valign="top"><b>Required</b></td>
  78. </tr>
  79. <tr>
  80. <td valign="top">
  81. file
  82. </td>
  83. <td valign="top">
  84. The file to import.
  85. </td>
  86. <td valign="top" align="center">Yes</td>
  87. </tr>
  88. <tr>
  89. <td valign="top">
  90. optional
  91. </td>
  92. <td valign="top">
  93. if true, do not issue stop the build if the file does not exist,
  94. default is false.
  95. </td>
  96. <td valign="top" align="center">No</td>
  97. </tr>
  98. </tbody>
  99. </table>
  100. <h3><br />
  101. </h3>
  102. <h3>Examples</h3>
  103. <pre>&nbsp; &lt;import file=&quot;../common-targets.xml&quot; /&gt;<br /></pre>
  104. <br />
  105. Imports targets from the common-targets.xml file that is in a parent
  106. directory.<br />
  107. <br />
  108. <pre>&nbsp; &lt;import file=&quot;${deploy-platform}.xml&quot; /&gt;<br /></pre>
  109. <br />
  110. Imports the project defined by the property deploy-platform<br />
  111. <br />
  112. <br />
  113. <hr>
  114. <p align="center">Copyright &copy; 2003-2004 The Apache Software
  115. Foundation. All rights
  116. Reserved.</p>
  117. </body>
  118. </html>