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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  5. <title>Libraries Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="echo">Libraries</a></h2>
  9. <h3>Description</h3>
  10. <p>
  11. Extensible library download mechanism, integrated with the
  12. <a href="http://maven.apache.org/">Maven</a> repository hosted
  13. at ibiblio.org.
  14. </p>
  15. <p>
  16. This task can:
  17. </p>
  18. <ol>
  19. <li>Download publicly published JAR files by version</li>
  20. <li>Download JAR files from private file: or http: repositories</li>
  21. <li>Cache the JAR files in a directory tree</li>
  22. <li>Check for updates on a regular schedule</li>
  23. <li>Build paths for compilation/execution</li>
  24. <li>Fail the build if needed libraries are missing</li>
  25. <li>Force an update of all libraries</li>
  26. <li>Skip all downloading when offline
  27. </ol>
  28. <h3>Parameters</h3>
  29. <table border="1" cellpadding="2" cellspacing="0">
  30. <tr>
  31. <td valign="top"><b>Attribute</b></td>
  32. <td valign="top"><b>Description</b></td>
  33. <td align="center" valign="top"><b>Required</b></td>
  34. </tr>
  35. <tr>
  36. <td valign="top">destDir</td>
  37. <td valign="top">Destination directory for all downloads
  38. </td>
  39. <td valign="top" align="center">No - default is ${user.home}/.maven/repository</td>
  40. </tr>
  41. <tr>
  42. <td valign="top">offline</td>
  43. <td valign="top">Flag to indicate that the system is offline, and that
  44. no downloads should take place.
  45. </td>
  46. <td valign="top" align="center">No</td>
  47. </tr>
  48. <tr>
  49. <td valign="top">flatten</td>
  50. <td valign="top">flag to indicate that files should be flattened when downloaded
  51. </td>
  52. <td valign="top" align="center">No -default false</td>
  53. </tr>
  54. <tr>
  55. <td valign="top">usetimestamp</td>
  56. <td valign="top">flag to indicate that timestamps should
  57. be compared when probing for updates.
  58. </td>
  59. <td valign="top" align="center">No -default false</td>
  60. </tr>
  61. <tr>
  62. <td valign="top">pathID</td>
  63. <td valign="top">Name of a path to create containing all
  64. libraries in this declaration.
  65. </td>
  66. <td valign="top" align="center">No</td>
  67. </tr>
  68. <tr>
  69. <td valign="top">repositoryRef</td>
  70. <td valign="top">Reference to a predefined repository
  71. </td>
  72. <td valign="top" align="center">No</td>
  73. </tr>
  74. </table>
  75. <p>
  76. The default destination is that used by Maven,
  77. ${user.home}/.maven/repository . It can be overridden by setting the
  78. property <code>ant.maven.repository.dir</code> to a new location.
  79. </p>
  80. </table>
  81. <h3>Nested Elements</h3>
  82. <h4>library</h4>
  83. This is the core of the system: a library to (potentially) download.
  84. <table border="1" cellpadding="2" cellspacing="0">
  85. <tr>
  86. <td valign="top"><b>Attribute</b></td>
  87. <td valign="top"><b>Description</b></td>
  88. <td align="center" valign="top"><b>Required</b></td>
  89. </tr>
  90. <tr>
  91. <td valign="top">project</td>
  92. <td valign="top">Name of the project
  93. </td>
  94. <td valign="top" align="center">Yes</td>
  95. </tr>
  96. <tr>
  97. <td valign="top">version</td>
  98. <td valign="top">
  99. </td>
  100. <td valign="top" align="center">Yes</td>
  101. </tr>
  102. <tr>
  103. <td valign="top">archive</td>
  104. <td valign="top">Name of the archive
  105. </td>
  106. <td valign="top" align="center">No</td>
  107. </tr>
  108. <tr>
  109. <td valign="top">destinationName</td>
  110. <td valign="top">Filename of downloaded file
  111. </td>
  112. <td valign="top" align="center">No, default remote name</td>
  113. </tr>
  114. <tr>
  115. <td valign="top">suffix</td>
  116. <td valign="top">Suffix of the archive
  117. </td>
  118. <td valign="top" align="center">No -default ".jar"</td>
  119. </tr>
  120. <tr>
  121. <td valign="top">enabled</td>
  122. <td valign="top">flag to turn on or off specific download/use
  123. of an archive
  124. </td>
  125. <td valign="top" align="center">No -default "true"</td>
  126. </tr>
  127. </table>
  128. <h4>Repository</h4>
  129. <p>
  130. A repository is an Ant datatype that extends the <code>Repository</code>
  131. type. Ant only ships with one: the mavenrepository. If no repository is
  132. declared inline, and no repositoryref attribute set, the task
  133. will default to the maven repository.
  134. </p>
  135. <table border="1" cellpadding="2" cellspacing="0">
  136. <tr>
  137. <td valign="top"><b>Attribute</b></td>
  138. <td valign="top"><b>Description</b></td>
  139. <td align="center" valign="top"><b>Required</b></td>
  140. </tr>
  141. <tr>
  142. <td valign="top">url</td>
  143. <td valign="top">URL of the repository
  144. </td>
  145. <td valign="top" align="center">No</td>
  146. </tr>
  147. </table>
  148. <p>Example:</p>
  149. <pre>
  150. &lt;repository ref=&quot;predefined.repository&quot; /&gt;
  151. </pre>
  152. <h4>mavenrepository</h4>
  153. <p>
  154. This connects to the Maven repository at ibiblio.org, or another
  155. chosen. Private repositories should copy the existing layout.
  156. </p>
  157. <p>
  158. If no <code>url</code> is set, the default URL is
  159. <code>http://ibiblio.org/maven</code>, unless the property
  160. <code>ant.maven.repository.url</code> is set to something else.
  161. <table border="1" cellpadding="2" cellspacing="0">
  162. <tr>
  163. <td valign="top"><b>Attribute</b></td>
  164. <td valign="top"><b>Description</b></td>
  165. <td align="center" valign="top"><b>Required</b></td>
  166. </tr>
  167. <tr>
  168. <td valign="top">url</td>
  169. <td valign="top">URL of the repository
  170. </td>
  171. <td valign="top" align="center">No</td>
  172. </tr>
  173. <tr>
  174. <td valign="top">checkMD5</td>
  175. <td valign="top">Flag to turn on MD5 checking
  176. (unimplemented)
  177. </td>
  178. <td valign="top" align="center">No</td>
  179. </tr>
  180. <tr>
  181. <td valign="top">username</td>
  182. <td valign="top">HTTP authentication username
  183. </td>
  184. <td valign="top" align="center">No</td>
  185. </tr>
  186. <tr>
  187. <td valign="top">password</td>
  188. <td valign="top">HTTP authentication password
  189. </td>
  190. <td valign="top" align="center">Only if username is set</td>
  191. </tr>
  192. </table>
  193. <h3>UpdatePolicies</h3>
  194. <P>Update policies are an (extensible) means of tuning the download, running
  195. code before and possibly after a download. They can enable or disable
  196. checks for individual files, skip the download process, or perform some
  197. post-download validation.
  198. </P>
  199. <P>All policies have at least the common set of attributes; some may have more,
  200. in which case an updated attribute list is shown. </P>
  201. <table border="1" cellpadding="2" cellspacing="0">
  202. <tr>
  203. <td valign="top"><b>Attribute</b></td>
  204. <td valign="top"><b>Description</b></td>
  205. <td align="center" valign="top"><b>Required</b></td>
  206. </tr>
  207. <tr>
  208. <td valign="top">enabled</td>
  209. <td valign="top">Enabled flag
  210. </td>
  211. <td valign="top" align="center">No -default "true"</td>
  212. </tr>
  213. </table>
  214. <P>Policies can be chained by listing them in order. Before an update/download
  215. takes place, all policies will be executed in order. After the download, the
  216. policies will be invoked in reverse order. The compound policy in such a
  217. situation is left to the experimentor, though reading the source will help.
  218. </P>
  219. <p>
  220. Developers may add new policies (such as signing incoming files) by adding
  221. new datatypes extending the <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 count="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" /&gt;
  348. &lt;scheduledupdate markerfile="build/lib/marker.properties"
  349. hours="11" /&gt;
  350. &lt;/libraries&gt;
  351. </pre>
  352. <p>Download doomed/dead-code.LATEST.war from a private repository, save it to
  353. build/lib/product.war with an update schedule of every eleven hours.
  354. </p>
  355. <hr>
  356. <p align="center">Copyright &copy; 2005 The Apache Software Foundation. All rights
  357. Reserved.</p>
  358. </body>
  359. </html>