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 KiB

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