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.

libraries.html 11 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Libraries Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="echo">Libraries</a></h2>
  8. <h3>Description</h3>
  9. <p>
  10. Extensible library download mechanism, integrated with the
  11. <a href="http://maven.apache.org/">Maven</a> repository hosted
  12. at ibiblio.org.
  13. </p>
  14. <p>
  15. This task can:
  16. </p>
  17. <ol>
  18. <li>Download publicly published JAR files by version.</li>
  19. <li>Download JAR files from private file: or http: repositories</li>
  20. <li>Cache the JAR files in a directory tree</li>
  21. <li>Check for updates on a regular schedule</li>
  22. <li>Build paths for compilation/execution.</li>
  23. <li>Fail the build if needed libraries are missing</li>
  24. <li>Force an update of all libraries</li>
  25. <li>Skip all downloading when offline
  26. </ol>
  27. <h3>Parameters</h3>
  28. <table border="1" cellpadding="2" cellspacing="0">
  29. <tr>
  30. <td valign="top"><b>Attribute</b></td>
  31. <td valign="top"><b>Description</b></td>
  32. <td align="center" valign="top"><b>Required</b></td>
  33. </tr>
  34. <tr>
  35. <td valign="top">destDir</td>
  36. <td valign="top">Destination directory for all downloads
  37. </td>
  38. <td valign="top" align="center">No - default is ${user.home}/.maven/repository</td>
  39. </tr>
  40. <tr>
  41. <td valign="top">offline</td>
  42. <td valign="top">Flag to indicate that the system is offline, and that
  43. no downloads should take place.
  44. </td>
  45. <td valign="top" align="center">No</td>
  46. </tr>
  47. <tr>
  48. <td valign="top">flatten</td>
  49. <td valign="top">flag to indicate that files should be flattened when downloaded
  50. </td>
  51. <td valign="top" align="center">No -default false</td>
  52. </tr>
  53. <tr>
  54. <td valign="top">pathID</td>
  55. <td valign="top">Name of a path to create containing all
  56. libraries in this declaration.
  57. </td>
  58. <td valign="top" align="center">No</td>
  59. </tr>
  60. <tr>
  61. <td valign="top">repositoryRef</td>
  62. <td valign="top">Reference to a predefined repository
  63. </td>
  64. <td valign="top" align="center">No</td>
  65. </tr>
  66. </table>
  67. <p>
  68. The default destination is that used by Maven,
  69. ${user.home}/.maven/repository . It can be overridden by setting the
  70. property <code>ant.maven.repository.dir</code> to a new location.
  71. </p>
  72. </table>
  73. <h3>Nested Elements</h3>
  74. <h4>library</h4>
  75. This is the core of the system; a library to (potentially) download.
  76. <table border="1" cellpadding="2" cellspacing="0">
  77. <tr>
  78. <td valign="top"><b>Attribute</b></td>
  79. <td valign="top"><b>Description</b></td>
  80. <td align="center" valign="top"><b>Required</b></td>
  81. </tr>
  82. <tr>
  83. <td valign="top">project</td>
  84. <td valign="top">Name of the project
  85. </td>
  86. <td valign="top" align="center">Yes</td>
  87. </tr>
  88. <tr>
  89. <td valign="top">version</td>
  90. <td valign="top">
  91. </td>
  92. <td valign="top" align="center">Yes</td>
  93. </tr>
  94. <tr>
  95. <td valign="top">archive</td>
  96. <td valign="top">Name of the archive
  97. </td>
  98. <td valign="top" align="center">No</td>
  99. </tr>
  100. <tr>
  101. <td valign="top">destinationName</td>
  102. <td valign="top">Filename of downloaded file
  103. </td>
  104. <td valign="top" align="center">No, default remote name</td>
  105. </tr>
  106. <tr>
  107. <td valign="top">suffix</td>
  108. <td valign="top">Suffix of the archive
  109. </td>
  110. <td valign="top" align="center">No -default ".jar"</td>
  111. </tr>
  112. <tr>
  113. <td valign="top">enabled</td>
  114. <td valign="top">flag to turn on or off specific download/use
  115. of an archive
  116. </td>
  117. <td valign="top" align="center">No -default "true"</td>
  118. </tr>
  119. </table>
  120. <h4>Repository</h4>
  121. <p>
  122. A repository is Ant datatype that extends the <code>Repository</code> type.
  123. Ant only ships with one: the mavenrepository. If no repository is
  124. declared inline, and no repositoryref attribute set, the task
  125. will default to the maven repository.
  126. </p>
  127. <table border="1" cellpadding="2" cellspacing="0">
  128. <tr>
  129. <td valign="top"><b>Attribute</b></td>
  130. <td valign="top"><b>Description</b></td>
  131. <td align="center" valign="top"><b>Required</b></td>
  132. </tr>
  133. <tr>
  134. <td valign="top">url</td>
  135. <td valign="top">URL of the repository
  136. </td>
  137. <td valign="top" align="center">No</td>
  138. </tr>
  139. </table>
  140. <p>Example:</p>
  141. <pre>
  142. &lt;repository ref=&quot;predefined.repository&quot; /&gt;
  143. </pre>
  144. <h4>mavenrepository</h4>
  145. <p>
  146. This connects to the Maven repository at ibiblio.org, or another
  147. chosen. Private repositories should copy the existing layout.
  148. </p>
  149. <p>
  150. If no <code>url</code> is set, the default URL is
  151. <code>http://ibiblio.org/maven</code>, unless the property
  152. <code>ant.maven.repository.url</code> is set to something else.
  153. <table border="1" cellpadding="2" cellspacing="0">
  154. <tr>
  155. <td valign="top"><b>Attribute</b></td>
  156. <td valign="top"><b>Description</b></td>
  157. <td align="center" valign="top"><b>Required</b></td>
  158. </tr>
  159. <tr>
  160. <td valign="top">url</td>
  161. <td valign="top">URL of the repository
  162. </td>
  163. <td valign="top" align="center">No</td>
  164. </tr>
  165. <tr>
  166. <td valign="top">checkMD5</td>
  167. <td valign="top">Flag to turn on MD5 checking
  168. (unimplemented)
  169. </td>
  170. <td valign="top" align="center">No</td>
  171. </tr>
  172. <tr>
  173. <td valign="top">username</td>
  174. <td valign="top">HTTP authentication username
  175. </td>
  176. <td valign="top" align="center">No</td>
  177. </tr>
  178. <tr>
  179. <td valign="top">password</td>
  180. <td valign="top">HTTP authentication password
  181. </td>
  182. <td valign="top" align="center">Only if username is set</td>
  183. </tr>
  184. </table>
  185. <h3>UpdatePolicies</h3>
  186. <P>Update policies are an (extensible) means of tuning the download, running
  187. code before and possibly after a download. They can enable or disable
  188. checks for individual files, skip the download process, or perform some
  189. post-download validation.
  190. </P>
  191. <P>All policies have at least the common set of attributes; some may have more,
  192. in which case an updated attribute list is shown. </P>
  193. <table border="1" cellpadding="2" cellspacing="0">
  194. <tr>
  195. <td valign="top"><b>Attribute</b></td>
  196. <td valign="top"><b>Description</b></td>
  197. <td align="center" valign="top"><b>Required</b></td>
  198. </tr>
  199. <tr>
  200. <td valign="top">enabled</td>
  201. <td valign="top">Enabled flag
  202. </td>
  203. <td valign="top" align="center">No -default "true"</td>
  204. </tr>
  205. </table>
  206. <P>Policies can be chained by listing them in order. Before an update/download
  207. takes place, all policies will be executed in order. After the download, the
  208. policies will be invoked in reverse order. The compound policy in such a
  209. situation is left to the experimentor, though reading the source will help.
  210. </P>
  211. <p>
  212. Developers may add new polices (such
  213. as signing incoming files) by adding new datatypes extending the
  214. <code>LibraryPolicy</code> class. </P>
  215. <h4>noupdate</h4>
  216. <P>This policy will disable remote downloads when enabled. It is the policy
  217. equivalent of the offline flag.</P>
  218. <p>Example:</p>
  219. <pre>
  220. &lt;noupdate /&gt;
  221. </pre>
  222. <h4>forceupdate</h4>
  223. <P>This policy forces all libraries to be downloaded. If any download failed,
  224. the build will halt.</P>
  225. <p>Example:</p>
  226. <pre>
  227. &lt;forceupdate /&gt;
  228. </pre>
  229. <h4>timestamp</h4>
  230. <P>This policy tells Ant to check the repository to see if the files have changed
  231. using timestamp checks. Any files which are up to date will not be downloaded again. </P>
  232. <p>Example:</p>
  233. <pre>
  234. &lt;timestamp /&gt;
  235. </pre>
  236. <h4>scheduledupdate</h4>
  237. This policy tells Ant to check the repository to see if the files have changed,
  238. but only intermittently. An interval of the size of the schedule has to have
  239. passed, or the set of files to check has to have changed.
  240. <table border="1" cellpadding="2" cellspacing="0">
  241. <tr>
  242. <td valign="top"><b>Attribute</b></td>
  243. <td valign="top"><b>Description</b></td>
  244. <td align="center" valign="top"><b>Required</b></td>
  245. </tr>
  246. <tr>
  247. <td valign="top">enabled</td>
  248. <td valign="top">Enabled flag
  249. </td>
  250. <td valign="top" align="center">No -default "true"</td>
  251. </tr>
  252. <tr>
  253. <td valign="top">markerFile</td>
  254. <td valign="top">Name of a file to cache download history
  255. </td>
  256. <td valign="top" align="center">Yes</td>
  257. </tr>
  258. <tr>
  259. <td valign="top">Days</td>
  260. <td valign="top">number of days between update checks
  261. </td>
  262. <td valign="top" align="center">No</td>
  263. </tr>
  264. <tr>
  265. <td valign="top">Hours</td>
  266. <td valign="top">number of hours between update checks
  267. </td>
  268. <td valign="top" align="center">No</td>
  269. </tr>
  270. <tr>
  271. <td valign="top">Minutes</td>
  272. <td valign="top">number of minutes between update checks
  273. </td>
  274. <td valign="top" align="center">No</td>
  275. </tr>
  276. </table>
  277. <p>Example:</p>
  278. <pre>
  279. &lt;scheduledupdate days="1" hours="3" minutes="17" /&gt;
  280. </pre>
  281. <P>Check for an update every 27 hours, 17 minutes. </P>
  282. <h4>assertdownloaded</h4>
  283. <P>This policy is really for testing the library. It does not
  284. alter the download policy, but after any download has taken place,
  285. it verifies that the number of files downloaded matches the number
  286. expected.</P>
  287. <table border="1" cellpadding="2" cellspacing="0">
  288. <tr>
  289. <td valign="top"><b>Attribute</b></td>
  290. <td valign="top"><b>Description</b></td>
  291. <td align="center" valign="top"><b>Required</b></td>
  292. </tr>
  293. <tr>
  294. <td valign="top">count</td>
  295. <td valign="top">number of downloaded files expected.
  296. </td>
  297. <td valign="top" align="center">Yes</td>
  298. </tr>
  299. <tr>
  300. <td valign="top">enabled</td>
  301. <td valign="top">Enabled flag
  302. </td>
  303. <td valign="top" align="center">No -default "true"</td>
  304. </tr>
  305. </table>
  306. <p>Example:</p>
  307. <pre>
  308. &lt;assertdownloaded cound="4" /&gt;
  309. </pre>
  310. <h3>Examples</h3>
  311. <pre>
  312. &lt;!--
  313. versions.properties says
  314. xdoclet.version=2.0
  315. commons-logging.version=1.0.3
  316. commons-collections.version=3.1
  317. --&gt;
  318. &lt;property file="versions.properties" /&gt;
  319. &lt;libraries destDir="${lib.dir}" pathid="xdoclet.lib" &gt;
  320. &lt;mavenrepository /&gt;
  321. &lt;library project="xdoclet"
  322. version="${xdoclet.version}" /&gt;
  323. &lt;library project="commons-logging"
  324. version="${commons-logging.version}" /&gt;
  325. &lt;library project="commons-collections"
  326. version="${commons-collections.version}" /&gt;
  327. &lt;/libraries&gt;
  328. </pre>
  329. <P>Load in versions from a file, then download the relevant archives. No
  330. update schedule is defined, but a path is created for insertion into a
  331. classpath. This property file driven dependency model is what we recommend
  332. over hard coding versions in a build file.
  333. </P>
  334. <PRE> &lt;libraries destDir="build/lib" offline="${offline}" flatten="true"&gt;
  335. &lt;mavenrepository url="${private.server}"/&gt;
  336. &lt;library project="doomed" archive="dead-code"
  337. suffix=".war"
  338. destinationName="product.war"
  339. version="LATEST"
  340. /&gt;
  341. &lt;scheduledupdate markerfile="build/lib/marker.properties"
  342. hours="11" /&gt;
  343. &lt;/libraries&gt;
  344. </PRE>
  345. <P>Download doomed/dead-code.LATEST.war from a private repository, save it to
  346. build/lib/product.war with an update schedule of every eleven hours.
  347. </P>
  348. <p align="center">Copyright &copy; 2005 The Apache Software Foundation. All rights
  349. Reserved.</p>
  350. </body>
  351. </html>