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 17 kB

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