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

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