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.

librarys.html 19 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <!-- Content Stylesheet for Site -->
  3. <!-- start the processing -->
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  7. <meta name="author" value="Peter Donald">
  8. <meta name="email" value="peter@apache.org">
  9. <title>Apache Myrmidon - On Librarys in Ant2</title>
  10. </head>
  11. <body bgcolor="#ffffff" text="#000000" link="#525D76">
  12. <table border="0" width="100%" cellspacing="0">
  13. <!-- TOP IMAGE -->
  14. <tr>
  15. <td> <td colspan="2">
  16. <a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" align="left" border="0"/></a>
  17. </td>
  18. </td>
  19. <td valign="bottom"><div align="right"><b><font size="+3" color="#525D76">Apache Myrmidon</font></b></div></td>
  20. </tr>
  21. </table>
  22. <table border="0" width="100%" cellspacing="4">
  23. <tr><td colspan="2">
  24. <hr noshade="" size="1"/>
  25. </td></tr>
  26. <tr>
  27. <!-- LEFT SIDE NAVIGATION -->
  28. <td valign="top" nowrap="true">
  29. <p><strong>Myrmidon</strong></p>
  30. <ul>
  31. <li> <a href="./index.html">Introduction</a>
  32. </li>
  33. <li> <a href="./getinvolved.html">Get Involved</a>
  34. </li>
  35. <li> <a href="./user.html">Building Myrmidon</a>
  36. </li>
  37. <li> <a href="./todo.html">Todo List</a>
  38. </li>
  39. </ul>
  40. <p><strong>User Guide</strong></p>
  41. <ul>
  42. <li> <a href="./buildfile.html">Build file</a>
  43. </li>
  44. <li> <a href="./vfs.html">Virtual File System</a>
  45. </li>
  46. <li> <a href="./ant1compat.html">Ant1 Compatibility Layer</a>
  47. </li>
  48. <li> <a href="./differences.html">Differences to Ant1</a>
  49. </li>
  50. </ul>
  51. <p><strong>Extending Ant</strong></p>
  52. <ul>
  53. <li> <a href="./task.html">Task Writers HOWTO</a>
  54. </li>
  55. <li> <a href="./classloader.html">ClassLoader HOWTO</a>
  56. </li>
  57. <li> <a href="./librarys.html">Library HOWTO</a>
  58. </li>
  59. </ul>
  60. <p><strong>Container Design</strong></p>
  61. <ul>
  62. </ul>
  63. </td>
  64. <td align="left" valign="top">
  65. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  66. <tr><td bgcolor="#525D76">
  67. <font color="#ffffff" face="arial,helvetica,sanserif">
  68. <a name="Library Management"><strong>Library Management</strong></a>
  69. </font>
  70. </td></tr>
  71. <tr><td>
  72. <blockquote>
  73. <p>Long ago there was identified the need for librarys that contain
  74. tasks and other elements present in the build file. This document
  75. attempts to describe the mechanism via which these libraries will be
  76. defined and used in Ant2. The librarys (also referred to as
  77. deployments) will be termed antlibs.</p>
  78. <p>Ant librarys can be packaged and signed into a ANt Type Library
  79. format (.atl) using the standard Java Archive tools. (For details on
  80. the .jar file format see the
  81. <a href="http://java.sun.com/j2se/1.3/docs/guide/jar/index.html">
  82. Jar Specification</a>.
  83. </p>
  84. <p>When packaged into such a form the META-INF/ directory contains
  85. ant specific descriptors in addition to the standard Jar manifest
  86. and other descriptor files. The archive will also contain the
  87. <code>.class</code> files for all the tasks and other types the
  88. library defines. It may also contain additional resources that can
  89. be referenced in the build file (an example being DTDs).
  90. </p>
  91. <p>The library may also need access to other librarys or resources
  92. to perform its job. For instance, if the task loaded an XML document
  93. and then processed said document using the
  94. <em>Trax API</em> then
  95. the Ant library needs to have access to the
  96. <em>Trax API</em> and an
  97. implementation of the API. The Antlib mechanism thus uses the standard
  98. "Optional Package" Specification to declare dependencies on other
  99. libraries.
  100. </p>
  101. <p>The libraries will usually be installed in standard locations that
  102. make it possible for the Ant container to automatically locate and scan
  103. the libraries. It will also be possible for the users to specify
  104. additional search locations or even the specific location of ant
  105. libraries.</p>
  106. <p>The following sections will describe each of these different facets
  107. in greater detail.</p>
  108. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  109. <tr><td bgcolor="#828DA6">
  110. <font color="#ffffff" face="arial,helvetica,sanserif">
  111. <a name="Descriptors"><strong>Descriptors</strong></a>
  112. </font>
  113. </td></tr>
  114. <tr><td>
  115. <blockquote>
  116. <p>FIXME: Import this part from other doco</p>
  117. </blockquote>
  118. </td></tr>
  119. </table>
  120. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  121. <tr><td bgcolor="#828DA6">
  122. <font color="#ffffff" face="arial,helvetica,sanserif">
  123. <a name="Class and Resource Files"><strong>Class and Resource Files</strong></a>
  124. </font>
  125. </td></tr>
  126. <tr><td>
  127. <blockquote>
  128. <p>The class and resources files should be stored as in standard jars. The
  129. root directory being the base via which code and resources are loaded. So
  130. the
  131. <code>.class</code> file for the Java class
  132. <code>com.biz.tasks.Mytask</code>
  133. would be stored in
  134. <code>/com/biz/tasks/Mytask.class</code>
  135. </p>
  136. </blockquote>
  137. </td></tr>
  138. </table>
  139. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  140. <tr><td bgcolor="#828DA6">
  141. <font color="#ffffff" face="arial,helvetica,sanserif">
  142. <a name="Dependencies"><strong>Dependencies</strong></a>
  143. </font>
  144. </td></tr>
  145. <tr><td>
  146. <blockquote>
  147. <p>It is often the case that a library will need external resources. The
  148. example given above described dependence on an external XML library. The
  149. ant library thus needs a mechanism via which to declare dependencies on
  150. external libraries.</p>
  151. <p>Ant2 uses the "Optional Package" mechanism. Prior to JDK1.3, an "Optional
  152. Package" was known as an
  153. <em>Extension</em>. The specification for this
  154. mechanism is available in the JDK1.3 documentation in the directory
  155. <code>$JDK_HOME/docs/guide/extensions/versioning.html</code>. Alternatively
  156. it is available online at
  157. <a href="http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html">
  158. http://java.sun.com/j2se/1.3/docs/guide/extensions/versioning.html</a>.
  159. </p>
  160. <p>This mechanism was adopted as it is an established standard. The standard
  161. is also begining to be adopted by other specifications such as the
  162. <em>Servlet
  163. 2.3 API</em>. Thus we are likely to see an increase of jars using this mechanism
  164. to specify dependencies.
  165. </p>
  166. <p>The "Optional Package" mechanism allows jars to specify dependencies on other
  167. jars that implement a particular specification at particular version levels. For
  168. example you could specify a dependency on the Trax 1.1 API by adding the following
  169. to the manifest of your jar.</p>
  170. <div align="left">
  171. <table cellspacing="4" cellpadding="0" border="0">
  172. <tr>
  173. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  174. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  175. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  176. </tr>
  177. <tr>
  178. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  179. <td bgcolor="#ffffff"><pre>
  180. Extension-List: trax
  181. trax-Extension-Name: Java API for XML Parsing
  182. trax-Specification-Version: 1.1
  183. </pre></td>
  184. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  185. </tr>
  186. <tr>
  187. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  188. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  189. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  190. </tr>
  191. </table>
  192. </div>
  193. <p>In some cases you may also wish to specify a dependency on a specific vendors
  194. implementation. For instance you may need to use xalan due to it implementing a
  195. particular extension you need. In that case you manifest may contain;</p>
  196. <div align="left">
  197. <table cellspacing="4" cellpadding="0" border="0">
  198. <tr>
  199. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  200. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  201. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  202. </tr>
  203. <tr>
  204. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  205. <td bgcolor="#ffffff"><pre>
  206. Extension-List: trax
  207. trax-Extension-Name: Java API for XML Parsing
  208. trax-Specification-Version: 1.1
  209. trax-Implementation-Title: org.apache.xalan.xslt
  210. trax-Implementation-Version: 2.1.0
  211. trax-Implementation-Vendor: Apache Software Foundation
  212. </pre></td>
  213. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  214. </tr>
  215. <tr>
  216. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  217. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  218. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  219. </tr>
  220. </table>
  221. </div>
  222. <p>In many cases there will be no distinction between the specification and
  223. the implementation of a library. For instance the Velocity project only has
  224. one implementation and one specification. In which case it is sufficient to
  225. just declare a dependency on the Velocity "Specification". A library that uses
  226. both the Trax API and the Velocity project may look like;</p>
  227. <div align="left">
  228. <table cellspacing="4" cellpadding="0" border="0">
  229. <tr>
  230. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  231. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  232. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  233. </tr>
  234. <tr>
  235. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  236. <td bgcolor="#ffffff"><pre>
  237. Extension-List: trax velocity
  238. velocity-Extension-Name: org.apache.velocity
  239. velocity-Specification-Version: 1.0
  240. trax-Extension-Name: Java API for XML Parsing
  241. trax-Specification-Version: 1.1
  242. trax-Implementation-Title: org.apache.xalan.xslt
  243. trax-Implementation-Version: 2.1.0
  244. trax-Implementation-Vendor: Apache Software Foundation
  245. </pre></td>
  246. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  247. </tr>
  248. <tr>
  249. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  250. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  251. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  252. </tr>
  253. </table>
  254. </div>
  255. <p>To make other jars available to Ant librarys as "Optional Packages"
  256. or Extensions then you need to add a few lines to the manifest of the
  257. other jar. The minimal manifest is the following;</p>
  258. <div align="left">
  259. <table cellspacing="4" cellpadding="0" border="0">
  260. <tr>
  261. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  262. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  263. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  264. </tr>
  265. <tr>
  266. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  267. <td bgcolor="#ffffff"><pre>
  268. Extension-Name: org.realityforge.dve
  269. Specification-Vendor: Peter Donald
  270. Specification-Version: 1.0
  271. </pre></td>
  272. <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  273. </tr>
  274. <tr>
  275. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  276. <td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  277. <td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
  278. </tr>
  279. </table>
  280. </div>
  281. <p>It is important to note that looking for dependencies is recursive. For example,
  282. if the ant library depends upon jar A and and A depends on B then both A and B will
  283. need to be loaded by the container.</p>
  284. </blockquote>
  285. </td></tr>
  286. </table>
  287. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  288. <tr><td bgcolor="#828DA6">
  289. <font color="#ffffff" face="arial,helvetica,sanserif">
  290. <a name="Implementation Notes"><strong>Implementation Notes</strong></a>
  291. </font>
  292. </td></tr>
  293. <tr><td>
  294. <blockquote>
  295. <p>So far there has been no mention of implementation strategies for
  296. managing ClassLoaders and other details about where the "Optional Packages"
  297. are stored. This section will outline such details but they could change
  298. in the future. The above specification will still be accurate but the approach
  299. to implementing specification will be different.</p>
  300. <p>In the current architecture all of the "Optional Packages" are assumed to
  301. be stored in the
  302. <code>$ANT_HOME/ext</code> directory. The runtime will scan
  303. this directory for jars and add all the "optional Packages" found into a
  304. registry. This registry will be used by the library loading mechanism to locate
  305. all the "Optional Packages". The user is able to specify an alternative directory
  306. or add a new directory to search on the commandline.
  307. </p>
  308. <p>When the container attempts to load an ant library it will also try to load
  309. any needed dependencies. First it will check the parent ClassLoaders to see if any
  310. of them contain the required dependencies. If not then it will search the
  311. "Optional Packages" registry. If the dependency is not found then a error will be
  312. signaled. If the dependency is found in the "Optional Packages" registry then it is
  313. loaded by the same ClassLoader that is used to load the Ant library.</p>
  314. </blockquote>
  315. </td></tr>
  316. </table>
  317. </blockquote>
  318. </td></tr>
  319. </table>
  320. </td>
  321. </tr>
  322. <!-- FOOTER -->
  323. <tr><td colspan="2">
  324. <hr noshade="" size="1"/>
  325. </td></tr>
  326. <tr><td colspan="2">
  327. <div align="center"><font color="#525D76" size="-1"><em>
  328. Copyright &#169; 2000-2002, Apache Software Foundation
  329. </em></font></div>
  330. </td></tr>
  331. </table>
  332. </body>
  333. </html>
  334. <!-- end the processing -->