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 3.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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>Input Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="input">Import</a></h2>
  9. <h3>Description</h3>
  10. Imports another build file into the current project.<br>
  11. <br>
  12. On execution it will read another Ant file into
  13. the same Project. This means that it basically works like the <a
  14. href="http://ant.apache.org/faq.html#xml-entity-include">Entity
  15. Includes as explained in the Ant FAQ</a>, as if the imported file was
  16. contained in the importing file, minus the top <code>&lt;project&gt;</code>
  17. tag.<br>
  18. <br>
  19. There are two further functional aspects that pertain to this task and
  20. that are not possible with entity includes:<br>
  21. <ul>
  22. <li>target overriding</li>
  23. <li>special properties<br>
  24. </li>
  25. </ul>
  26. <b>Target overriding<br>
  27. <br>
  28. </b>If a target in the main file is also present in at least one of the
  29. imported files, it takes precedence.<br>
  30. <br>
  31. So if I import for example a <i>docsbuild.xml</i> file named <b>builddocs</b>,
  32. that contains a "<b>docs</b>" target, I can redefine it in my main
  33. buildfile and that is the one that will be called. It makes it easy to
  34. keep the same target name, that has the same dependencies (so it is
  35. still called by the other targets), but use a different implementation.<br>
  36. <br>
  37. The original target is still available though, and is called <b>"builddocs</b><b>.docs"</b>.
  38. This means that in my new implementation, I can still call the old
  39. target, making it possible to <i>enhance </i>it with tasks called
  40. before or after it.<br>
  41. <b></b><b><br>
  42. Special Properties<br>
  43. <br>
  44. </b>Imported files are treated as they are present in the main
  45. buildfile. This makes it easy to understand, but it makes it impossible
  46. for them to reference files and resources relative to their path.
  47. Because of this, for every imported file, Ant adds a property that
  48. contains the path to the imported buildfile. With this path, the
  49. imported buildfile can keep resources and be able to reference them
  50. relative to its position.<br>
  51. <br>
  52. So if I import for example a <i>docsbuild.xml</i> file named <b>builddocs</b>,
  53. I can get its path as <b>ant.file.builddocs</b>, similarly to the <b>ant.file</b>
  54. property of the main buildfile.<br>
  55. Note that "builddocs" is not the filename, but the @name attribute
  56. present in the imported project tag.<br>
  57. <br>
  58. <b>Important</b>: We have not finalized how relative file references
  59. will be resolved in deep/complex build hierarchies -such as what
  60. happens when an imported file imports another file. Use absolute
  61. references for enhanced build file stability, especially in the
  62. imported files.<br>
  63. &nbsp;<br>
  64. <h3>Parameters</h3>
  65. <table border="1" cellpadding="2" cellspacing="0">
  66. <tbody>
  67. <tr>
  68. <td valign="top"><b>Attribute</b></td>
  69. <td valign="top"><b>Description</b></td>
  70. <td align="center" valign="top"><b>Required</b></td>
  71. </tr>
  72. <tr>
  73. <td valign="top">file<br>
  74. </td>
  75. <td valign="top">The file to import.<br>
  76. </td>
  77. <td valign="top" align="center">Yes</td>
  78. </tr>
  79. </tbody>
  80. </table>
  81. <h3><br>
  82. </h3>
  83. <h3>Examples</h3>
  84. <pre>&nbsp; &lt;import file="../common-targets.xml" /&gt;<br></pre>
  85. <br>
  86. Imports targets from the common-targets.xml file that is in a parent
  87. directory.<br>
  88. <br>
  89. <pre>&nbsp; &lt;import file="${deploy-platform}.xml" /&gt;<br></pre>
  90. <br>
  91. Imports the project defined by the property deploy-platform<br>
  92. <br>
  93. <br>
  94. <hr>
  95. <p align="center">Copyright &copy; 2003 Apache Software
  96. Foundation. All rights
  97. Reserved.</p>
  98. </body>
  99. </html>