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.

goals.xml 16 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <document>
  2. <properties>
  3. <author email="">Conor MacNeill</author>
  4. <title>Mutant Goals</title>
  5. </properties>
  6. <body>
  7. <section name="Goals">
  8. <p>
  9. This page describes the key goals that have shaped the development of
  10. Mutant.
  11. </p>
  12. <p>
  13. The first section identifies a set of issues with Ant1 that have cropped up as
  14. Ant1 has evolved. The design implications of each issue are then summarized as a
  15. Mutant requirement. I do not want to suggest that these problems are unsolvable
  16. within the Ant1 design. Already I believe we have seen the Ant2 proposals
  17. influencing people trying to extend Ant1. These issues may be solvable, although at
  18. the risk of backward compatability impacts or further complication of the Ant1
  19. codebase.
  20. </p>
  21. <p>
  22. The second section covers a set of additional requirements that have emerged as
  23. the whole concept of Ant2 has developed. Many of these came from the discussions
  24. on the Ant-Dev mailing list.
  25. </p>
  26. <p>
  27. The realisation of these requirements as they impact a user is on the
  28. <a href="features.html">next page</a>. Th implications for task developers and
  29. Ant developers are discussed in the following sections.
  30. </p>
  31. </section>
  32. <section name="Ant1 Issues">
  33. <subsection name="Unrestricted core access">
  34. <p>
  35. The interface between the Ant core and tasks is not controlled. It
  36. allows tasks almost complete access to the internal data structures of the
  37. core. This is poor encapsulation. Whilst most tasks do not need and do not
  38. use this access, its existence nonetheless prevents changes being made to
  39. the core without raising concerns about impacting backward compatability.
  40. </p>
  41. <p>
  42. The uncontrolled nature of the task-core interface also makes it difficult
  43. to reuse tasks and types in a different context without almost completely
  44. duplicating the Ant core
  45. </p>
  46. <box>
  47. <p>
  48. A tightly defined interface between the core and the components (tasks and
  49. types) will allow the core implementation to be changed without the risk
  50. of impacting tasks. It will also allow components to be reused in other
  51. contexts.
  52. </p>
  53. </box>
  54. </subsection>
  55. <subsection name="Lack of embedding support">
  56. <p>
  57. Ant1 does not provide strong support for embedding Ant in other systems,
  58. particularly a GUI or IDE. The development of Antidote highlighted this
  59. difficultly. Antidote was forced to perform its own XML parsing so it could
  60. build its own model of the build. There is no communication medium for a GUI to
  61. communicate with the core. Without this capability any GUI will be limited to
  62. simply editing the XML representation of the build.
  63. </p>
  64. <box>
  65. <p>
  66. The definition of a project model, a Java-based object-model of a build
  67. description would decouple Ant from the XML representation. This allows
  68. other representations to be used. Such an object model also forms the basis
  69. for communications between systems which want to embed Ant. An IDE could
  70. manipulate this project object model directly and pass to the core for
  71. processing without needing to convert to and from an external
  72. representations such as XML.
  73. </p>
  74. </box>
  75. </subsection>
  76. <subsection name="Configuration done at Parse-Time">
  77. <p>
  78. The original implementation of Ant1 performed all task configuration at the
  79. time the XML description of the build was parsed (parse-time). This approach
  80. could not handle dynamically created tasks very well since in some
  81. instances the type of the task to be configured was not known at parse-time.
  82. This limitation was overcome with the introduction of the UnknownElement and
  83. RuntimeConfigurable classes. While these work well, they are confusing and at
  84. times surprising to most Ant developers. Also some operations still occur at
  85. parse-time, notably creation of nested elements of known types. This could be
  86. overcome by going to a fully dynamic model but the fear of backward
  87. incompatability constrains this change from occuring.
  88. </p>
  89. <box>
  90. <p>
  91. Execution-time configuration of tasks allows for the latest information to be
  92. used for configuration. It is also necessary to support the concept of the
  93. project model. The project model cannot contain execution-time information as it
  94. does in Ant1
  95. </p>
  96. <p>
  97. The decoupling of the parsing and exection phases, communicating through the
  98. medium of the project model will allow the core to be modularized. The parsing
  99. and execution phases can be separated and one replaced without impacting the
  100. other.
  101. </p>
  102. </box>
  103. </subsection>
  104. <subsection name="Multiple execution">
  105. <p>
  106. In Ant1, a task, once configured, may be used more than once - i.e. its
  107. execute method may be called more than once. This occurs when the Ant
  108. command line specifies the evaluation of two targets. If those targets have
  109. overlapping dependencies, the tasks in those overlapping dependencies will
  110. be executed twice. This arrangement requires task writers to preserve the
  111. state configured by Ant during the execution of the task so that the next
  112. execution has the correct configuration.
  113. </p>
  114. <p>
  115. Many task writers are not aware of this requirement. Frequently the task's
  116. state is changed during the execution method, which can lead to mysterious
  117. falures during subsequent executions. This need to preserve the configuration
  118. state makes writing tasks much harder.
  119. </p>
  120. <box>
  121. <p>
  122. Once a task is configured, it should be executed once. If the execution of
  123. multiple targets is required, a new task instance should be created and
  124. configured from the same project model. If reuse of task instances is desired
  125. each instance must be reinitialized and reconfigured before use.
  126. </p>
  127. </box>
  128. </subsection>
  129. <subsection name="No automatic deployment of tasks">
  130. <p>
  131. Ant1 has a set of well-known tasks (and types). A well-known task is one
  132. for which a mapping between the taskname and its implementing class is
  133. predefined in Ant. This mapping is provided by the two defaults.properties
  134. files in Ant's code. These well-known tasks do not need to be taskdef'd to
  135. make them available in a build file. Conversely tasks which are not in this
  136. list need to be explicitly taskdef'd.
  137. </p>
  138. <p>
  139. Note that this distinction is not the same as the core/optional
  140. distinction found in Ant1. An Ant1 core task is notionally supported by Ant
  141. without requiring any additional external libraries - it just requires the
  142. classes available in the 1.1 JDK, in Ant and in the libraries Ant uses such
  143. as the XML parser. An optional task is a task which requires JDK 1.2+
  144. features or the support of an external library, such as jakarta-regexp.
  145. </p>
  146. <p>
  147. The problem with this system is that there is no namespace management. If a
  148. new task is added to Ant, it may invalidate buildfiles which are already
  149. using that taskname via a taskdef. Actually the taskdef may continue to work or
  150. it may not - it will depend on the nested elements that the task definitions
  151. support (see above discussion of regarding cofiguration at parse-time)
  152. </p>
  153. <box>
  154. <p>
  155. Tasks need to be deployed in libraries by either placing them in well known
  156. directories of an Ant install or by telling Ant where to look for them. Removing
  157. the central management of defined task names allows tasks libraries to be
  158. developed and maintained independently of Ant much more easily.
  159. </p>
  160. <p>
  161. Once centralised management of the task namespace is removed, there is,
  162. however, the possibility of name collision. A mechanism is required to allow a
  163. build file writer to select which particular tasks are assigned to which
  164. tasknames.
  165. </p>
  166. </box>
  167. </subsection>
  168. <subsection name="Top level tasks">
  169. <p>
  170. In Ant1 certain tasks may appear outside of any target. This is implemented as a
  171. set of hardcoded conditions in the XML parsing phase. The execution and
  172. configuration of these tasks does not involve the use of RuntimeConfigurable and
  173. UnknownElement.
  174. </p>
  175. <p>
  176. This hardcoding is not very inituitive. It is confusing to users who do not
  177. know why only some tasks may be run outside of a target. Also as the list of
  178. tasks that may be useful as a top-level task grows, further special cases must
  179. be added to the code making the code harder to maintain.
  180. </p>
  181. <box>
  182. <p>
  183. The number of special names should be kept to a minimum. Special cases should
  184. be avoided as they are not inituitive.
  185. </p>
  186. </box>
  187. </subsection>
  188. <subsection name="Build file inclusion is cumbersome">
  189. <p>
  190. In Ant1, the inclusion of a set of build file definitions or targets is achieved
  191. through the use of XML entities. This is just cumbersome.
  192. </p>
  193. <box>
  194. <p>
  195. A simplified include mechanism is required to replace the entity based
  196. inclusion of Ant1.
  197. </p>
  198. </box>
  199. </subsection>
  200. <subsection name="Classpath management">
  201. <p>
  202. Probably the greatest issue facing Ant1 today involves the management of the
  203. classpath and the associated visibility of classes. Most optional tasks in Ant1
  204. require the supporting classes for the task to be available on the system
  205. classpath. For example, the JUnit task is only usable if the JUnit jar is on
  206. the classpath. If it is not, Ant will complain about being unable to create the
  207. junit task.
  208. </p>
  209. <p>
  210. The usual solution when a user runs into this problem is to put the required jar
  211. into the ANT_HOME/lib directory. This just adds the required jar to the system
  212. classpath prior to starting Ant albeit without requiring the user to explicitly
  213. set the classpath.
  214. </p>
  215. <p>
  216. There are a number of issues with this approach. The classes on the
  217. classpath share the same classloader as Ant's classes and Ant's support
  218. libraries - particularly the XML parser. If a task wishes to use a specific XML
  219. parser, it may conflict with Ant's own parser. If two tasks require different
  220. versions of a supporting jar, these will conflict.
  221. </p>
  222. <p>
  223. Many tasks make use of factory objects (dynamic class instantiation, dynamic
  224. resource loading, etc). When the factory is in the system classpath it will not
  225. be able to load resources available in a taskdef'd task's custom classpath due
  226. to the delegating nature of classloaders. Such errors can be very confusing to
  227. users. More recent code is likely to attempt use of a context classloader but
  228. this is not set by Ant1 currently.
  229. </p>
  230. <box>
  231. <p>
  232. Do not require jars to be added to ANT_HOME/lib to enable tasks. Allow users to
  233. specify the location of support jars on a per-library basis.
  234. </p>
  235. </box>
  236. </subsection>
  237. <subsection name="Extensibility">
  238. <p>
  239. The earliest versions Ant1 did not explicitly support any datatypes. The only
  240. datatype, property, was actually created as a side-effect of running the
  241. <code>&lt;property&gt;</code> task. If it were to be implemented today, property
  242. would probably be known as a string datatype, perhaps associated with a
  243. <code>&lt;load-properties&gt;</code> task. This is also the reason property
  244. is one of those tasks which is allowed to exist outside of a target.
  245. </p>
  246. <p> As Ant1 evolved new types such as <code>&lt;path&gt;</code> and
  247. <code>&lt;fileset&gt;</code> were added. The concept of datatypes has continued
  248. to evolve to the point where users can now define new datatypes. It would be
  249. expected that in addition to new types there will be many sub-types created,
  250. such as new types of fileset. Ant1, however, does not strongly support such type
  251. extensibility. When a subtype is created by extending an existing type, Ant1
  252. requires it to be either used by reference or all tasks which accept the base
  253. type need to be modified to support the new type. Use by reference is not always
  254. possible. It will depend on whether the base type has been coded to support
  255. references. </p>
  256. <box>
  257. <p>
  258. Support polymorphic behaviour, allowing a build file to pass a subtype to a
  259. task which is defined to accept the base type. Allow task interfaces to be
  260. defined in terms of interfaces.
  261. </p>
  262. <p>
  263. Move reference processing to the core to make it more regular removing the
  264. burden of type developers to explicitly support references.
  265. </p>
  266. </box>
  267. </subsection>
  268. <subsection name="Project object does too much">
  269. <p>
  270. In Ant1 the Project object takes on too many roles including all of the
  271. following:
  272. </p>
  273. <ul>
  274. <li>Holds the project model built when parsing the build file</li>
  275. <li>Holds the run-time state of the build through the properties and current
  276. task definitions</li>
  277. <li>Provides context for task execution. All tasks have a reference to their
  278. project instance and use it to access core functions</li>
  279. <li>Provides the implementation of common task operations</li>
  280. <li>Build event management</li>
  281. <li>Message logging</li>
  282. <li>Global filter definitions</li>
  283. <li>Java Version</li>
  284. <li>Property replacement</li>
  285. <li>Message Levels</li>
  286. <li>Utility functions such as boolean conversion and path translation</li>
  287. <li>Integration point for embedding Ant</li>
  288. </ul>
  289. <p> As a class, Project is not cohesive. Reuse of the Ant core functionality is
  290. difficulty as all of these concerns bring in many other support classes.
  291. </p>
  292. <box>
  293. <p>
  294. Separate the various roles of Project into more cohesive classes.
  295. </p>
  296. </box>
  297. </subsection>
  298. </section>
  299. <section name="Other Goals">
  300. <p>
  301. In addition to the issues which arise from Ant1 limitations, there are a number
  302. of requirements which have emerged in the mailing list discussions about Ant2.
  303. This isn't a complete list - just the ones I picked up for Mutant.
  304. </p>
  305. <subsection name="Limited project reuse">
  306. <p> In Ant1 the only way to reuse build file definitions is to use the
  307. <code>&lt;ant&gt;</code> task. While useful, it is relatively coarse-grained. It
  308. can also be tedious if you are trying to extend an existing project definition -
  309. that is, adding new targets while retaining a user's ability to access the
  310. existing targets. </p>
  311. <p>
  312. In addition to the extension of projects, it should be possible to compose
  313. projects creating dependencies between the targets of the different projects,
  314. and to access the data and definitions of one project by a controlling project
  315. </p>
  316. <box>
  317. <p>
  318. Allow a project to extend and control other projects
  319. </p>
  320. </box>
  321. </subsection>
  322. <subsection name="Ant1 Compatibility - Zero Friction">
  323. <p>
  324. While it has always been accepted that there will be come backward compatibility
  325. breaks in moving from Ant1 to Ant2, these should be minimized. If the changeover
  326. from Ant1 to Ant2 is difficult, it may never happen. On the other hand, the
  327. openness of the Ant1 interface means that some tasks will not work as expected -
  328. the most difficult being the <code>&lt;script&gt;</code> task.
  329. </p>
  330. <box>
  331. <p>
  332. Achieve a practical level of compatability without degrading the integrity of
  333. the core's interfaces. A practical level of compatability is intentionally a
  334. vague measure but it would require the majority of projects in Gump to be built
  335. without noticeable differences from Ant1
  336. </p>
  337. </box>
  338. </subsection>
  339. <subsection name="XML Configuration">
  340. <p>
  341. In Ant1 configuration of Ant is achieved either through the execution of OS
  342. dependent scripts by the launcher scripts or though properties files which have
  343. the limited capability to set properties.
  344. </p>
  345. <box>
  346. <p>
  347. Provide an XML based configuration system with rich capabilities to configure
  348. the operation of Ant.
  349. </p>
  350. </box>
  351. </subsection>
  352. <subsection name="Aspects">
  353. <p>
  354. In Ant1 there are many things which are common to a group of tasks but adding
  355. the capability to each task is repetitive and tedious. An example would be the
  356. failonerror attribute which controls whether a task will cause the build to stop
  357. when it fails. This started on just one task but has since been added to many
  358. other tasks as users want more fine control over when their builds stop. Aspects
  359. have been discussed as a mechanism for providing a single implementation of a
  360. concept or control that can then be applied to tasks independently.
  361. </p>
  362. <box>
  363. <p>
  364. Investigate the use of an Aspect approach to provide common functionality
  365. across tasks with a single implementation
  366. </p>
  367. </box>
  368. </subsection>
  369. </section>
  370. </body>
  371. </document>