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.

index.html 13 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <html>
  2. <head>
  3. <title>Ant Proposal - Frantic</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <style type="text/css">
  6. <!--
  7. .quote { font-family: "Times New Roman", Times, serif; font-size: 24pt}
  8. p { font-family: Verdana, Arial, Helvetica, sans-serif}
  9. h1 { font-family: "Times New Roman", Times, serif; color: #330099; font-weight: bold}
  10. h2 { font-family: Verdana, Arial, Helvetica, sans-serif; color: #3300CC}
  11. h3 { font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #3300CC}
  12. a { text-decoration: none; color: #9900FF}
  13. a:hover { text-decoration: underline}
  14. h5 { font-family: Verdana, Arial, Helvetica, sans-serif}
  15. -->
  16. </style>
  17. </head>
  18. <body bgcolor="#FFFFFF">
  19. <h1 align="center"><img src="images/frantic_logo.gif" width="250" height="264" align="left">Ant
  20. 2.0 Proposal</h1>
  21. <h2 align="center">Code Name - Frantic</h2>
  22. <p>Frantic hardly describes the proposal process...more like my coding and design
  23. efforts! I am relatively new to Ant and the mail list, and I have posted several
  24. emails recently regarding the use of DOM in the future of Ant. Once I discovered
  25. the mail archive (thanks Simeon), I had a chance to notice that many of my questions
  26. were asked before. My extemporaneous emails were not without consequence it
  27. seems. After writing one of them it set some wheels in motion for what I hope
  28. is a useful addition to the current (and growing) number of proposals for Ant
  29. 2.0.</p>
  30. <center>
  31. <table width="50%" border="0" bgcolor="#9933FF" cellpadding="1" cellspacing="0">
  32. <tr>
  33. <td>
  34. <table width="100%" border="0" cellpadding="4">
  35. <tr bgcolor="#CCCCFF" align="center">
  36. <td>
  37. <p>I think the concept behind Ant should be changed to be a "Task
  38. Execution Engine", and the concept of Project and Target can be
  39. generalized into a specific form of a Task.</p>
  40. </td>
  41. </tr>
  42. </table>
  43. </td>
  44. </tr>
  45. </table>
  46. </center>
  47. <p>&nbsp;</p>
  48. <p>The email list has received some requests from developers to extend Ant to
  49. support different problem domains. Peter Donald has latched onto this issue
  50. and I understand that he has incorporated some of these ideas into his Ant proposal.
  51. I also have seen some very impressive DOM support integrated into Antidote,
  52. an elegant basis for a GUI editor crafted by Simeon Fitch. Sim achieves a great
  53. deal of flexibility by using the W3C DOM as a superclass to his Project/Target/Task
  54. objects. He has, in effect, abstracted each of these &quot;core&quot; Ant objects
  55. until they are simply DOM nodes.</p>
  56. <p>Peter's and Sim's ideas struck a chord and I thought that Peter's desire to
  57. allow Ant to break free from the Build domain and into Install domains by extending
  58. Ant, could be achieved by looking at the problem from a different point of view.
  59. As I stated in my email, we can achieve a much higher degree of flexibility
  60. in Ant by generalizing more.</p>
  61. <h3>Design Proposal</h3>
  62. <p>I believe that Ant 2.0 should be re-termed a <b><i>Task Execution Engine</i></b>,
  63. and the core of Ant becomes the Engine and the Task. This seems a little radical
  64. considering that the Project/Target/Task object model has served us so well
  65. in Ant 1.x, however it is very clear that Project and Target are simple another
  66. type of Task.</p>
  67. <p>An enormous amount of code has been added to maintain Project and Target as
  68. separate classes with distinct, hard-coded behaviors. From the proof-of-concept
  69. code that I have been developing, I am inspired by how much more elegant the
  70. code becomes when this simplified model is realized. </p>
  71. <p>Having a base Task interface that all Tasks implement will also offer a generalized
  72. approach that benefits GUI's in much the same manner that the DOM has helped
  73. Antidote. Also, by making Task an interface instead of a class, we can finally
  74. free ourselves of implementation specifics.</p>
  75. <p>As I was writing the concept code, it struck me that I was too worried about
  76. the XML. Simeon Fitch mentioned in an email in early December, the possibility
  77. of storing build scripts in a database. I think this, along with various comments
  78. about DOM dependencies from Peter Donald, Jose Alberto Fernandez, and Stefan
  79. Bodewig made me realize that Core Ant shouldn't care where the build script
  80. lives or in which format it is stored. It is the object model that is primarily
  81. important.</p>
  82. <h3>The Task</h3>
  83. <p>The cornerstone of this proposal hinges on the <a href="Task.html" target="new">Task</a>
  84. Interface. It is the only type of external object that the Execution Engine
  85. knows how to handle. It is in this simplicity that the most powerful Ant can
  86. be realized.</p>
  87. <p>The Task is an object that is aware of it's place in ahierarchy. To this end
  88. it is aware of its parent and its children. Please note that this is a runtime
  89. dependency and a scripting language (or the Task itself) can dynamically change
  90. the relationship of Tasks.</p>
  91. <table border="0" align="left">
  92. <tr>
  93. <td><img src="images/task_hierarchy.gif" width="200" height="140"></td>
  94. </tr>
  95. <tr align="center">
  96. <td>
  97. <h5><i>Figure 1</i></h5>
  98. </td>
  99. </tr>
  100. </table>
  101. <p>Key to being able to manipulate Tasks at runtime is some sort of naming conventions.
  102. Currently in the Frantic design is the concept of a Task name. Tasks, being
  103. hierarchical, can be thought of as a directory structure (see figure 1). If
  104. each Task is assigned a name that is unique among its siblings, we can then
  105. have a powerful means of locating and referencing a particular Task anywhere
  106. in the hierarchy. </p>
  107. <p>For example, the Property Task below the Target named &quot;build&quot; has
  108. a name of &quot;prop3&quot;, however its &quot;fully-qualified&quot; name is
  109. /root/build/prop3. The root of a Task execution list is &quot;/&quot; and the
  110. tag name, in our example /root. In the concept source code I use this principal
  111. of hierarchical naming to support dependencies. Currently, I am treating these
  112. Task names as directories and not as files. This should perhaps change slightly
  113. to the filename approach. In the directory-based approach, a sibling is named
  114. &quot;../sibling&quot;. It would be more convenient to not require the &quot;../&quot;.
  115. In fact, I think I have convinced myself of this.</p>
  116. <h3> Task Discovery</h3>
  117. <p>I haven't coded this portion, however I plan on basing it on Duncan's idea
  118. of using the Jar manifests to locate and identify tasks on the classpath. I
  119. was first exposed to this technique in the OpenTools API of Borland's JBuilder
  120. IDE, and I have since used it on a large project for a consulting customer.</p>
  121. <p>The classpath is scanned at runtime to locate all directories and jar files.
  122. These directories and jar files will have a manifest file that will contain
  123. manifest entries that serve to tie a string token to the Task implementation
  124. class responsible for that token. Directories cannot have manifests per se,
  125. but we will utilize a file, one-level up from the directory, with a name &quot;directory-name.mf&quot;.
  126. This file will be in the format of a manifest file. This will allow developers
  127. to create and test new Tasks without the burden of having to make a Jar archive
  128. every time.</p>
  129. <h3>Attribute Validation</h3>
  130. <p>Brett McLaughlin introduced a very interesting techique to perform object validation
  131. using XML Schema in a series of <a href="http://www.javaworld.com/javaworld/jw-09-2000/jw-0908-validation.html">JavaWorld
  132. articles</a>. I can see this technique applied to Tasks as well. The user could
  133. include a schema with a special name in the jar file that accompanies the Tasks.
  134. This schema could be used at runtime to validate a Task's attributes.</p>
  135. <p>I would imagine that this feature would be outside of what is considered &quot;core&quot;
  136. Ant.</p>
  137. <h3>The Execution Engine</h3>
  138. <p>The engine only knows how to process Task objects, and that is what makes it
  139. extremely efficient. It is modeled after how I believe a compiler, or command
  140. interpreter would function. It contains a call stack which I call a <i><b>task
  141. stack</b></i>, and this task stack is under complete control of the engine.
  142. This is not to say that Tasks cannot manipulate the task stack at runtime, because
  143. they do. However, all of this access takes place under the watchful eye of the
  144. execution engine. </p>
  145. <h3>Properties</h3>
  146. <p>Keeping track of properties is closely tied to the execution engine, and I
  147. modeled it in a manner consistent with how I believe compilers must work. I
  148. use the concept of a hierarchical series of hashtables that support the concept
  149. of scope in property lists.</p>
  150. <p>I had originally put the concept of a property into a Task and completely implemented
  151. the bugger. It turned out during testing that my logic was flawed. It seemed
  152. to work well at first...a property defined in a Task would be available to all
  153. child Tasks, but unavailable to any ancestors. When a Task requested the latest
  154. data on a property, it would look in its property list. If it wasn't found there,
  155. it would look in its parent's list, and so on. Instant scope.</p>
  156. <p>However, it became quickly apparent that properties are a &quot;runtime&quot;
  157. consideration. This is something that Jose Alberto Fernandez will not let any
  158. of us forget for long. :-) What I needed was to move this hierarchical chain
  159. of property lists into the engine. For each new Task executed, a new property
  160. list is created and also pushed onto the stack. It seems to work like a champ.</p>
  161. <p>I also coded up key substitution into the getParameterValue() events. They
  162. seem to work fine, although I haven't worked up enough test cases to be sure.</p>
  163. <p>One additional cool feature is that parameters need not only hold Strings.
  164. I thought that there would be occasions where properties will hold Tasks as
  165. well. I believe this will turn out to be a prime mechanism for creating reference
  166. id Tasks like the current FileSet objects and referring to them in other Tasks
  167. just as you would any property value.</p>
  168. <h3>Attributes</h3>
  169. <p>I haven't spent any time addresing what is currently referred to a Task's attributes
  170. in Ant 1.x. I still need to think about this concept some more, but as I dwell
  171. on what an attribute is, I keep coming back to the properties. Just like a property
  172. functions as a scoped variable, an attribute is the same thing. Albeit, its
  173. scope is limited to the Task that uses it, but so what.</p>
  174. <h3>Execution Events</h3>
  175. <p>The execution engine also supports a few key events that can occur during the
  176. execution lifecycle. Currently events exist for execution start/finish, task
  177. start/execute/finish, exceptions, and simple messaging. The messaging event
  178. allows Tasks to communicate in a standard way that will leverage the engine's
  179. event system to allow various front-ends to intelligently and appropriately
  180. process the output.</p>
  181. <h3>Scripting</h3>
  182. <p>I have no experience with incorporating a scripting engine into an engine,
  183. but I do know that this proposal should address the primary issues that surround
  184. such an integration. I think that two features which are absolutely essential
  185. are:</p>
  186. <p> Provide some sort of naming convention such that a particular Task can be
  187. found given an absolute name or a name relative to another Task. This is complete
  188. and working in the concept code.</p>
  189. <p>Leave all decisions regarding property evaluation and Task's knowledge of these
  190. properties until the last possible moment.</p>
  191. <h3>Recursive Tasks</h3>
  192. <p>I realize that Ant 1.x spent some clock cycles dedicated to resolving circular
  193. references in the Task definitions. I didn't spend any time on that intentionally.
  194. I am not so sure that the elimination of circular references is a good idea.
  195. Especially moving forward, with the incorporation of a scripting language, I
  196. can envision Tasks the assembler wants to execute repeatedly, perhaps even recursively.
  197. I think we should treat this the same way that any modern computer language
  198. would &#151; <i>caveat emptor</i>.</p>
  199. <h3>Summary</h3>
  200. <p>There is a lot more to do with this proposal and the concept code. It has been
  201. an exciting weekend getting these thoughts down and trying to back them up.
  202. I look forward to collaborating with others on the list if they wish to help
  203. me, even though I am in proposal phase. I certainly don't know much about XML
  204. parsing and I could use some ideas on how to further my starting model. I would
  205. love to show the Ant core model built in a Builder agnostic manner. Basically,
  206. I want XML to be an option, not a requirement.</p>
  207. <p>I would also be interested in perhaps building an adapter task that will allow
  208. Ant 1.x tasks to be reused unchanged in the Frantic proposal. The concept of
  209. a Task hasn't changed much, so perhaps this is a possibility.</p>
  210. <p>As always, your feedback is welcome. I expect that I have missed some major
  211. holes and I would like the opportunity to work with others to plug them up!</p>
  212. <p><a href="mailto:jimcook@visualxs.com">Jim Cook</a><br>
  213. <a href="http://www.visualxs.com/">Visual XS</a></p>
  214. </body>
  215. </html>