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.

ant_in_anger.html 49 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <head>
  16. <title>
  17. Ant in Anger
  18. </title>
  19. </head>
  20. <body bgcolor="#FFFFFF" text="#000000">
  21. <h1 align="center">Ant in Anger:
  22. </h1>
  23. <h2 align="center">
  24. Using Apache Ant in a Production Development System
  25. </h2>
  26. <h4 align="center">
  27. Steve Loughran<br>
  28. Last updated 2005-03-16
  29. </h4>
  30. <a name="introduction">
  31. <h2>Introduction</h2>
  32. </a>
  33. <a href="http://ant.apache.org/">Apache Ant</a>
  34. can be an invaluable tool in a team development process - or it can
  35. be yet another source of problems in that ongoing crises we call
  36. development . This
  37. document contains some strategies and tactics for making the most of
  38. Ant. It is moderately frivolous in places, and lacks almost any actual
  39. examples of Ant XML. The lack of examples is entirely deliberate - it
  40. keeps document maintenance costs down. Most of the concepts covered
  41. don't need the detail provided by XML representations, as it is the processes we
  42. are concerned about, not the syntax. Finally, please be aware that the
  43. comments here are only suggestions which need to be customised to meet
  44. your own needs, not strict rules about what should and should not be
  45. done.
  46. <p>
  47. Firstly, here are some assumptions about the projects which this
  48. document covers:
  49. <ul>
  50. <li> Pretty much pure Java, maybe with some legacy cruft on the edges.
  51. <li> Team efforts, usually with the petulant prima-donnas all us Java
  52. programmers become once we realise how much in demand we are.
  53. <li> A fairly distributed development team - spread across locations and
  54. maybe time zones.
  55. <li> Separate sub projects - from separate beans in a big
  56. enterprise application to separate enterprise applications which need to
  57. be vaguely aware of each other.
  58. <li> Significant mismatch between expectations and time available to
  59. deliver. 'Last Week' is the ideal delivery date handed down from above,
  60. late next century the date coming up from below.
  61. <li> Everyone is struggling to keep up with platform and tool evolution.
  62. <li> Extensive use of external libraries, both open and closed source.
  63. </ul>
  64. What that all means is that there is no time to spend getting things
  65. right, you don't have that tight control on how the rest of the team
  66. works and the development process is often more one of chaos minimisation
  67. than anything else. The role of Ant in such projects is to ensure that
  68. the build, test and deploy processes run smoothly, leaving you with all
  69. the other problems.
  70. <a name="core">
  71. <h2>Core Practices</h2>
  72. </a>
  73. <h3>
  74. Clarify what you want Ant to do</h3>
  75. Ant is not a silver bullet. It is just another rusty bullet in the armory of
  76. development tools available at your disposal. Its primary purpose is to
  77. accelerate the construction and deployment of Java projects. You could certainly
  78. extend Ant to do anything Java makes possible: it is easy to imagine writing an
  79. image processing task to help in web site deployment by shrinking and
  80. recompressing jpeg files, for example. But that would be pushing the boundary of
  81. what Ant is really intended to do - so should be considered with care.
  82. <p>
  83. Ant is also a great adjunct to an IDE; a way of doing all the housekeeping of
  84. deployment and for clean, automated builds. But a good modern IDE is a
  85. productivity tool in its own right - one you should continue to use. Ant
  86. just lets you give the teams somewhat more freedom in IDE choice - &quot;you can
  87. use whatever you want in development, but Ant for the deployment
  88. builds&quot; Now that many modern open source and commercial IDEs
  89. include Ant support (including jEdit, Forte, Eclipse and IDEA),
  90. developers can use a great IDE, with Ant providing a rigorous and portable
  91. build process integrated into the tool.
  92. <h3>
  93. Define standard targets
  94. </h3>
  95. When you have multiple sub projects, define a standard set of targets.
  96. Projects with a split between interface and implementation jar files
  97. could consider <b>impl</b> and <b>intf</b> targets - with separate
  98. <b>debug-impl</b> and <b>debug-intf</b> targets for the debug version.
  99. And of course, the ubiquitous <b>clean</b> target.
  100. <p>
  101. With standard target names, it is easy to build encompassing Ant build
  102. files which just hand off the work to the classes below using the
  103. <a href="manual/CoreTasks/ant.html">ant</a>
  104. task. For example. the clean target could be handed down to the <tt>intf</tt> and
  105. <tt>impl</tt> subdirectories from a parent directory
  106. <pre>&lt;target name=&quot;clean&quot; depends=&quot;clean-intf, clean-impl&quot;&gt;
  107. &lt;/target&gt;
  108. &lt;target name=&quot;clean-intf&quot; &gt;
  109. &lt;ant dir=&quot;intf&quot; target=&quot;clean&quot; /&gt;
  110. &lt;/target&gt;
  111. &lt;target name=&quot;clean-impl&quot;&gt;
  112. &lt;ant dir=&quot;impl&quot; target=&quot;clean&quot; /&gt;
  113. &lt;/target&gt; </pre>
  114. If you give targets a <tt>description</tt> tag, then calling <tt>ant
  115. -projecthelp</tt> will list all tasks with their description as 'main targets', and
  116. all tasks without a description as subtargets. Describing all your
  117. entry points is therefore very useful, even before a project becomes big and complicated.
  118. <h3>
  119. Extend Ant through new tasks
  120. </h3>
  121. If Ant does not do what you want, you can use the
  122. <a href="manual/CoreTasks/exec.html">exec</a> and
  123. <a href="manual/CoreTasks/java.html">java</a> tasks or
  124. <a href="manual/OptionalTasks/script.html">inline scripting</a> to extend it. In a
  125. project with many <tt>build.xml</tt> files, you soon find that having a single
  126. central place for implementing the functionality keeps maintenance
  127. overhead down. Implementing task extensions through Java code seems
  128. extra effort at first, but gives extra benefits:-
  129. <ul>
  130. <li>Cross platform support can be added later without changing any
  131. <tt>build.xml</tt> files</li>
  132. <li>The code can be submitted to the Ant project itself, for other
  133. people to use and maintain</li>
  134. <li>It keeps the build files simpler</li>
  135. </ul>
  136. In a way, it is this decoupling of functionality, "the tasks", from
  137. the declaration of use, "the build file", that has helped Ant succeed.
  138. If you have to get something complex done in Make or an IDE, you have a
  139. hairy makefile that everyone is scared of, or an IDE configuration that
  140. is invariably very brittle. But an Ant task is reusable and shareable
  141. among all Ant users. Many of the core and optional tasks in Ant today,
  142. tasks you do or will come to depend on, were written by people trying to
  143. solve their own pressing problems.
  144. <h3>
  145. Embrace Automated Testing
  146. </h3>
  147. <b>(alternatively "recriminate early, recriminate often")</b>
  148. <p>
  149. Ant lets you call <a href="manual/OptionalTasks/junit.html">JUnit</a>
  150. tasks, which unit test the code your team has written. Automated testing
  151. may seem like extra work at first, but JUnit makes writing unit tests so
  152. easy that you have almost no reason not to. Invest the time in learning
  153. how to use JUnit, write the test cases, and integrate them in a 'test'
  154. target from Ant so that your daily or hourly team build can have the
  155. tests applied automatically. One of the free to download chapters of
  156. <a href="http://manning.com/hatcher">Java Development with Ant</a>
  157. shows you how to use JUnit from inside Ant.
  158. <p>
  159. Once you add a way to fetch code from the SCM system, either as an Ant
  160. task, in some shell script or batch file or via some continuous
  161. integration tool. the integration test code can be a pure Ant task run
  162. on any box dedicated to the task. This is ideal for verifying that the
  163. build and unit tests work on different targets from the usual
  164. development machines. For example, a Win95/Java1.1 combination could be
  165. used even though no developer would willingly use that configuration
  166. given the choice.
  167. <p>
  168. System tests are harder to automate than unit tests, but if you can
  169. write java code to stress large portions of the system - even if the code
  170. can not run as JUnit tasks - then the <a href= "manual/CoreTasks/java.html">java</a>
  171. task can be used to invoke them. It is best to specify that you want a
  172. new JVM for these tests, so that a significant crash does not break the
  173. full build. The Junit extensions such as
  174. <a href="http://httpunit.sourceforge.net/">HttpUnit</a> for web pages, and
  175. <a href="http://jakarta.apache.org/cactus/">Cactus</a> for J2EE and servlet
  176. testing help to expand the testing framework. To test properly you will still
  177. need to invest a lot of effort in getting these to work with your project, and
  178. deriving great unit, system and regression tests - but your customers will love
  179. you for shipping software that works.
  180. <h3>Learn to Use and love the add-ons to Ant</h3>
  181. The Ant distribution is not the limit of the Ant universe, it is only
  182. the beginning. Look at the
  183. <a href="http://ant.apache.org/external.html">
  184. External Tools and Tasks page
  185. </a> for an up to date list. Here are some of them that .
  186. <ul>
  187. <li>
  188. <a href="http://checkstyle.sourceforge.net/">Checkstyle</a><br>
  189. This tool audits your code and generates HTML reports of wherever any
  190. style rule gets broken. Nobody can hide from the code police now! tip:
  191. start using this early, so there's less to correct.</li>
  192. <li>
  193. <a href="http://ant-contrib.sf.net/">Ant-contrib</a><br>
  194. This sourceforge project contains helper tasks that are kept separate
  195. from core Ant for ideological purity; the foreach and trycatch tasks in
  196. particular. These give you iteration and extra error handling. Also on
  197. the site is the &lt;cc&gt; task suite, that compile and link native code
  198. on a variety of platforms.</li>
  199. <li>
  200. <a href="http://xdoclet.sourceforge.net/">XDoclet</a>
  201. XDoclet adds attributed oriented programming to Java. By adding javadoc
  202. tags to your code you can have XDoclet automatically generate <tt>web.xml</tt>
  203. descriptors, taglib descriptors, EJB interfaces, JMX interface classes,
  204. Castor XML/SQL bindings, and many more. The key here is that all those
  205. fiddly little XML files you need to create, and those interfaces EJB and
  206. JMX requires to implement, all can be autogenerated from your Java
  207. code with a few helper attributes. This reduces
  208. errors and means you can change your code and have the rest of the app
  209. take its cue from the source. Never do EJB, JMX or webapps without it!
  210. </li>
  211. </ul>
  212. <a name="crossplatform">
  213. <h2>
  214. Cross Platform Ant
  215. </h2>
  216. </a>
  217. Ant is the best foundation for cross platform Java development and
  218. testing to date. But if you are not paying attention, it is possible to
  219. produce build files which only work on one platform - or indeed, one
  220. single workstation.
  221. <p>
  222. The common barriers to cross-platform Ant are the use of command line
  223. tools (exec tasks) which are not portable, path issues, and hard coding
  224. in the location of things.
  225. <h3>Command Line apps: <a href="manual/CoreTasks/exec.html">Exec</a> /
  226. <a href= "manual/CoreTasks/apply.html">Apply</a></h3>
  227. The trouble with external invocation is that not all functions are found
  228. cross platform, and those that are often have different names - DOS
  229. descendants often expect <tt>.exe</tt> or <tt>.bat</tt> at the end of files. That can be
  230. bad if you explicitly include the extension in the naming of the command
  231. (don't!), good when it lets you keep the unix and DOS versions of an
  232. executable in the same bin directory of the project without name
  233. clashes arising.
  234. <p>
  235. Both the command line invocation tasks let you specify which platform
  236. you want the code to run on, so you could write different tasks for each
  237. platform you are targeting. Alternatively, the platform differences
  238. could be handled inside some external code which Ant calls. This can be
  239. some compiled down java in a new task, or an external script file.
  240. <h3>Cross platform paths</h3>
  241. Unix paths use forward slashes between directories and a colon to
  242. split entries. Thus
  243. <i>"/bin/java/lib/xerces.jar:/bin/java/lib/ant.jar"</i> is
  244. a path in unix. In Windows the path must use semicolon separators,
  245. colons being used to specify disk drives, and backslash separators
  246. <i>"c:\bin\java\lib\xerces.jar;c:\bin\java\lib\ant.jar"</i>.
  247. <p>
  248. This difference between platforms (indeed, the whole java classpath
  249. paradigm) can cause hours of fun.
  250. <p>
  251. Ant reduces path problems; but does not eliminate them entirely. You
  252. need to put in some effort too. The rules for handling path names are
  253. that 'DOS-like pathnames are handled', 'Unix like paths are handled'.
  254. Disk drives -'C:'- are handled on DOS-based boxes, but placing them in
  255. the <tt>build.xml</tt> file ruins all chances of portability. Relative file paths
  256. are much more portable. Semicolons work as path separators - a fact which
  257. is useful if your Ant invocation wrapper includes a list of jars as a
  258. defined property in the command line. In the build files you may find it
  259. better to build a classpath by listing individual files (using location=
  260. attributes), or by including a fileset of <tt>*.jar</tt> in the classpath
  261. definition.
  262. <p>
  263. There is also the <a
  264. href="manual/CoreTasks/pathconvert.html">PathConvert</a> task which
  265. can put a fully resolved path into a property. Why do that? Because then
  266. you can use that path in other ways - such as pass it as a parameter to
  267. some application you are calling, or use the replace task to patch it
  268. into a localised shell script or batch file.
  269. <p>
  270. Note that DOS descended file systems are case insensitive (apart from
  271. the obscure aberration of the WinNT POSIX subsystem run against NTFS),
  272. and that Windows pretends that all file extensions with four or more
  273. letters are also three letter extensions (try <tt>DELETE *.jav</tt> in your java
  274. directories to see a disastrous example of this).
  275. <p>
  276. Ant's policy on case sensitivity is whatever the underlying file system
  277. implements, and its handling of file extensions is that <tt>*.jav</tt> does not
  278. find any <tt>.java</tt> files. The Java compiler is of course case sensitive - you can
  279. not have a class 'ExampleThree' implemented in "examplethree.java".
  280. <p>
  281. Some tasks only work on one platform - <a href= "manual/CoreTasks/chmod.html">
  282. Chmod</a> being a classic example. These tasks usually result in just a
  283. warning message on an unsupported platform - the rest of the target's
  284. tasks will still be called. Other tasks degrade their functionality on
  285. platforms or Java versions. In particular, any task which adjusts the
  286. timestamp of files can not do so properly on Java 1.1. Tasks which can
  287. do that - <a href="manual/CoreTasks/get.html">Get</a>, <a
  288. href="manual/CoreTasks/touch.html">Touch</a> and <A href="manual/CoreTasks/unzip.html">
  289. Unjar/Unwar/Unzip</a> for example, degrade their functionality on
  290. Java1.1, usually resorting to the current timestamp instead.
  291. <p>
  292. Finally, Perl makes a good place to wrap up Java invocations cross
  293. platform, rather than batch files. It is included in most Unix
  294. distributions, and is a simple download for <a href=
  295. "http://www.activestate.com/Products/ActivePerl/">Win32 platforms from
  296. ActiveState</a>. A Perl file with <tt>.pl</tt> extension, the usual Unix
  297. path to perl on the line 1 comment and marked as executable can be run
  298. on Windows, OS/2 and Unix and hence called from Ant without issues. The
  299. perl code can be left to resolve its own platform issues. Don't forget to
  300. set the line endings of the file to the appropriate platform when you
  301. redistribute Perl code; <a
  302. href="manual/CoreTasks/fixcrlf.html">fixCRLF</a>
  303. can do that for you.
  304. <a name="team">
  305. <h2>Team Development Processes</h2>
  306. </a>
  307. Even if each team member is allowed their choice of IDE/editor, or even
  308. OS, you need to set a baseline of functionality on each box. In
  309. particular, the JDKs and jars need to be in perfect sync. Ideally pick
  310. the latest stable Java/JDK version available on all developer/target
  311. systems and stick with it for a while. Consider assigning one person to
  312. be the contact point for all tools coming in - particularly open source
  313. tools when a new build is available on a nightly basis. Unless needed,
  314. these tools should only really be updated monthly, or when a formal
  315. release is made.
  316. <p>
  317. Another good tactic is to use a unified directory tree, and add on extra
  318. tools inside that tree. All references can be made relative to the tree.
  319. If team members are expected to add a directory in the project to their
  320. path, then command line tools can be included there - including those
  321. invoked by Ant exec tasks. Put everything under source code control and
  322. you have a one stop shop for getting a build/execute environment purely
  323. from CVS or your equivalent.
  324. <a name="deploying">
  325. <h2>Deploying with Ant</h2>
  326. </a>
  327. One big difference between Ant and older tools such as Make is that the
  328. processes for deploying Java to remote sites are reasonably well
  329. evolved in Ant. That is because we all have to do it these days, so
  330. many people have put in the effort to make the tasks easier.
  331. <p>
  332. Ant can <a href="manual/CoreTasks/jar.html">Jar</a>, <a href=
  333. "manual/CoreTasks/tar.html">Tar</a> or <a
  334. href="manual/CoreTasks/zip.html">Zip</a> files for deployment, while the
  335. <a href="manual/CoreTasks/war.html">War</a> task extends the jar task
  336. for better servlet deployment.
  337. <a href ="manual/OptionalTasks/jlink.html">Jlink</a> is a
  338. jar generation file which lets you merge multiple sub jars. This is
  339. ideal for a build process in which separate jars are generated by sub
  340. projects, yet the final output is a merged jar. <a href=
  341. "manual/OptionalTasks/cab.html">Cab</a> can be used on Win32 boxes to
  342. build a cab file which is useful if you still have to target IE deployment.
  343. <p>
  344. The <a href="index.html#ftp">ftp</a> task lets you move stuff up to a
  345. server. Beware of putting the ftp password in the build file - a property
  346. file with tight access control is slightly better. The <a href=
  347. "manual/CoreTasks/fixcrlf.html">FixCRLF</a> task is often a useful interim step if
  348. you need to to adjust the line endings of files. A
  349. WebDav task has long been discussed, which would provide a more secure
  350. upload to web servers, but it is still in the todo list. Rumour has it
  351. that there is such a task in the jakarta-slide libraries. With MacOS X,
  352. Linux and Windows XP all supporting WebDAV file systems, you may even be able
  353. to use <a href="manual/CoreTasks/copy.html">copy</a> to deploy
  354. though a firewall.
  355. <p>
  356. EJB deployment is aided by the <a href="manual/OptionalTasks/ejb.html">ejb</a> tasks,
  357. while the
  358. <a
  359. href="manual/OptionalTasks/serverdeploy.html">serverdeploy</a>
  360. suite can deploy to multiple servers. The popularity of Ant has
  361. encouraged vendors to produce their own deployment tasks which they
  362. redistribute with their servers. For example, the Tomcat4.1 installation
  363. includes tasks to deploy, undeploy and reload web applications.
  364. <p>
  365. Finally, there are of course the fallbacks of just copying files to a
  366. destination using <a href="manual/CoreTasks/copy.html">Copy</a> and <a href="index.html#copydir">Copydir</a> , or just sending them to a person or
  367. process using <a href="manual/CoreTasks/mail.html">Mail</a> or the attachment
  368. aware <a href= "manual/OptionalTasks/mimemail.html">MimeMail</a>.
  369. In one project our team even used Ant to build CD images through a build followed
  370. by a long set of Copy tasks, which worked surprisingly well, certainly
  371. easier than when we mailed them to the free email service on
  372. myrealbox.com, then pulled them down from the far end's web browser, which we
  373. were running over WinNT remote desktop connection, that being tunneled
  374. through SSH.
  375. <a name="directories">
  376. <h2> Directory Structures</h2>
  377. </a>
  378. How you structure your directory tree is very dependent upon the
  379. project. Here are some directory layout patterns which can be used as
  380. starting points. All the jakarta projects follow a roughly similar
  381. style, which makes it easy to navigate around one from one project to
  382. another, and easy to clean up when desired.
  383. <h3>Simple Project</h3>
  384. The project contains sub directories
  385. <table width="100%">
  386. <tr>
  387. <td><b>bin</b>
  388. </td>
  389. <td>common binaries, scripts - put this on the path.
  390. </td>
  391. </tr>
  392. <tr>
  393. <td><b>build</b>
  394. </td>
  395. <td>This is the tree for building; Ant creates it and can empty it
  396. in the 'clean' project.
  397. </td>
  398. </tr>
  399. <tr>
  400. <td><b>dist</b>
  401. </td>
  402. <td>Distribution outputs go in here; the directory is created in Ant
  403. and clean empties it out
  404. </td>
  405. </tr>
  406. <tr>
  407. <td><b>doc</b>
  408. </td>
  409. <td>Hand crafted documentation
  410. </td>
  411. </tr>
  412. <tr>
  413. <td><b>lib</b>
  414. </td>
  415. <td>Imported Java libraries go in to this directory
  416. </td>
  417. </tr>
  418. <tr>
  419. <td><b>src</b>
  420. </td>
  421. <td>source goes in under this tree <i>in a hierarchy which matches
  422. the package names<i>. The dependency rules of &lt;javac&gt; requires this.
  423. </td>
  424. </tr>
  425. </table>
  426. The bin, lib, doc and src directories should be under source code control.
  427. Slight variations include an extra tree of content to be included in the
  428. distribution jars - inf files, images, etc. These can go under source
  429. too, with a <tt>metadata</tt> directory for <tt>web.xml</tt> and similar
  430. manifests, and a <tt>web</tt> folder for web content - JSP, html, images
  431. and so on. Keeping the content in this folder (or sub hierarchy)
  432. together makes it easier to test links before deployment. The actual
  433. production of a deployment image, such as a war file, can be left to the
  434. appropriate Ant task: there is no need to completely model your source tree
  435. upon the deployment hierarchy.
  436. <p>
  437. Javadoc output can be
  438. directed to a <tt>doc/</tt> folder beneath <tt>build/</tt>, or to <tt>doc/javadoc</tt>.
  439. <h3>Interface and Implementation split</h3>
  440. If the interface is split from the implementation code then this can be
  441. supported with minor changes just by having a separate build path for
  442. the interface directory - or better still just in the jar construction:
  443. one jar for interface and one jar for implementation.
  444. <h3>Loosely Coupled Sub Projects</h3>
  445. In the loosely coupled approach multiple projects can have their own
  446. copy of the tree, with their own source code access rights.
  447. One difference to consider is only having one instance of the bin and
  448. lib directories across all projects. This is sometimes good - it helps
  449. keep copies of xerces.jar in sync, and sometimes bad - it can update
  450. foundational jar files before unit testing is complete.
  451. <p>
  452. To still have a single build across the sub projects, use parent
  453. <tt>build.xml</tt> files which call down into the sub projects.
  454. <p>
  455. This style works well if different teams have different code
  456. access/commitment rights. The risk is that by giving extra leeway to the
  457. sub projects, you can end up with incompatible source, libraries, build
  458. processes and just increase your workload and integration grief all round.
  459. <p>
  460. The only way to retain control over a fairly loosely integrated
  461. collection of projects is to have a fully automated build
  462. and test process which verifies that everything is still compatible. Sam
  463. Ruby runs one for all the apache java libraries and emails everyone when
  464. something breaks; your own project may be able to make use of
  465. <A href="http://cruisecontrol.sourceforge.net/">Cruise Control</a> for
  466. an automated, continuous, background build process.
  467. <h3>Integrated sub projects</h3>
  468. Tightly coupled projects have all the source in the same tree; different
  469. projects own different subdirectories. Build files can be moved down to
  470. those subdirectories (say <tt>src/com/iseran/core</tt> and <tt>src/com/iseran/extras</tt>),
  471. or kept at the top - with independent build files named <tt>core.xml</tt> and
  472. <tt>extras.xml</tt>.
  473. <p>
  474. This project style works well if everyone trusts each other and the
  475. sub projects are not too huge or complex. The risk is that a split to a
  476. more loosely coupled design will become a requirement as the projects
  477. progress - but by the time this is realised schedule pressure and
  478. intertwined build files make executing the split well nigh impossible.
  479. If that happens then just keep with it until there is the time to
  480. refactor the project directory structures.
  481. <a name="antupdate">
  482. <h2>
  483. Ant Update Policies
  484. </h2>
  485. </a>
  486. Once you start using Ant, you should have a policy on when and how the
  487. team updates their copies. A simple policy is &quot;every official release
  488. after whatever high stress milestone has pushed all unimportant tasks
  489. (like sleep and seeing daylight) on the back burner&quot;. This insulates you
  490. from the changes and occasional instabilities that Ant goes through
  491. during development. Its main disadvantage is that it isolates you from
  492. the new tasks and features that Ant is constantly adding.
  493. <p>
  494. Often an update will require changes to the <tt>build.xml</tt> files. Most
  495. changes are intended to be backwards compatible, but sometimes an
  496. incompatible change turns out to be
  497. necessary. That is why doing the update in the lull after a big
  498. milestone is important. It is also why including <tt>ant.jar</tt> and related
  499. files in the CVS tree helps ensure that old versions of your software
  500. can be still be built.
  501. <p>
  502. The most aggressive strategy is to get a weekly or daily snapshot of the
  503. ant source, build it up and use it. This forces you to tweak the
  504. <tt>build.xml</tt> files more regularly, as new tasks and attributes can take
  505. while to stabilise. You really have to want the new features, enjoy
  506. gratuitous extra work or take pleasure in upsetting your colleagues to
  507. take this approach.
  508. <p>
  509. Once you start extending Ant with new tasks, it suddenly becomes much
  510. more tempting to pull down regular builds. The most recent Ant builds
  511. are invariably the best platform for writing your extensions, as you
  512. can take advantage of the regular enhancements to the foundational
  513. classes. It also prevents you from wasting time working on something
  514. which has already been done. A newly submitted task to do something
  515. complex such as talk to EJB engines, SOAP servers or just convert a text
  516. file to uppercase may be almost exactly what you need - so take it,
  517. enhance it and offer up the enhancements to the rest of the world. This
  518. is certainly better than starting work on your 'text case converter'
  519. task on Ant 0.8 in isolation, announcing its existence six months later
  520. and discovering that instead of adulation all you get are helpful
  521. pointers to the existing implementation. The final benefit of being
  522. involved with the process is that it makes it easier for your tasks to
  523. be added with the Ant CVS tree, bringing forward the date when Ant has
  524. taken on all the changes you needed to make to get your project to work.
  525. If that happens you can revert to an official Ant release, and get on
  526. with all the other crises.
  527. <p>
  528. You should also get on the <a href =
  529. "mailto:dev-subscribe@ant.apache.org">dev mailing list
  530. </a>, as it is where the other developers post their work, problems and
  531. experience. The volume can be quite high: 40+ messages a day, so
  532. consider routing it to an email address you don't use for much else. And
  533. don't make everyone on the team subscribe; it can be too much of a
  534. distraction.
  535. <a name="install">
  536. <h2>
  537. Installing with Ant.
  538. </h2>
  539. </a>
  540. Because Ant can read environment variables, copy, unzip and delete files
  541. and make java and OS calls, it can be used for simple installation
  542. tasks. For example, an installer for tomcat could extract the
  543. environment variable <tt>TOMCAT_HOME</tt>, stop tomcat running, and copy a war
  544. file to <tt>TOMCAT_HOME/webapps</tt>. It could even start tomcat again, but the
  545. build wouldn't complete until tomcat exited, which is probably not what
  546. was wanted.
  547. <p>
  548. The advantage of using Ant is firstly that the same install targets
  549. can be used from your local build files (via an <tt>ant</tt> invocation
  550. of the <tt>install.xml</tt> file), and secondly that a basic install target is
  551. quite easy to write. The disadvantages of this approach are that the
  552. destination must have an up to date version of Ant correctly
  553. pre-installed, and Ant doesn't allow you to handle failures well - and a
  554. good installer is all about handling when things go wrong, from files
  555. being in use to jar versions being different. This means that Ant is not
  556. suited for shrink wrapped software, but it does work for deployment and
  557. installation to your local servers.
  558. <p>
  559. One major build project I was involved in had an Ant install build file
  560. for the bluestone application server, which would shutdown all four
  561. instances of the app server on a single machine, copy the new version of
  562. the war file (with datestamp and buildstamp) to an archive directory,
  563. clean up the current deployed version of the war and then install the
  564. new version. Because bluestone restarted JVMs on demand, this script was
  565. all you needed for web service deployment. On the systems behind the
  566. firewall, we upped the ante in the deployment process by using the ftp
  567. task to copy out the war and build files, then the telnet task to
  568. remotely invoke the build file. The result was we had automated
  569. recompile and redeploy to local servers from inside our IDE (Jedit) or
  570. the command line, which was simply invaluable. Imagine pressing a button
  571. on your IDE toolbar to build, unit test, deploy and then functional test
  572. your webapp.
  573. <p>
  574. One extra trick I added later was a junit test case to run through the
  575. install check list. With tests to verify access permissions on network
  576. drives, approximate clock synchronisation between servers, DNS
  577. functionality, ability to spawn executables and all the other trouble
  578. spots, the install script could automatically do a system health test
  579. during install time and report problems. [The same tests could also be
  580. invoked from a JMX MBean, but that's another story].
  581. <p>
  582. So, Ant is not a substitute for a real installer tool, except in the
  583. special case of servers you control, but in that context it does let
  584. you integrate remote installation with your build.
  585. <a name="tips">
  586. <h2>
  587. Tips and Tricks</h2>
  588. </a>
  589. <dl>
  590. <dt><b>
  591. get
  592. </b><dd>
  593. The <a href="manual/CoreTasks/get.html">get</a> task can fetch any URL, so be used
  594. to trigger remote server side code during the build process, from remote
  595. server restarts to sending SMS/pager messages to the developer
  596. cellphones.
  597. <dt><b>
  598. i18n
  599. </b><dd>
  600. Internationalisation is always trouble. Ant helps here with the <a href=
  601. "manual/OptionalTasks/native2ascii.html">native2ascii</a> task which can escape out all non
  602. ascii characters into unicode. You can use this to write java files
  603. which include strings (and indeed comments) in your own non-ASCII
  604. language and then use native2ascii to convert to ascii prior to feeding
  605. through javac. The rest of i18n and l12n is left to you...
  606. <dt><b>
  607. Use Property Files
  608. </b><dd>
  609. Use external property files to keep per-user settings out the build
  610. files - especially passwords. Property files can also be used to
  611. dynamically set a number of properties based on the value of a single
  612. property, simply by dynamically generating the property filename from the
  613. source property. They can also be used as a source of constants across
  614. multiple build files.
  615. <dt><b>
  616. Faster compiles with Jikes
  617. </b><dd>
  618. The <a href="http://jikes.sourceforge.net/">jikes compiler</a> is usually much
  619. faster than javac, does dependency checking and has better error
  620. messages (usually). Get it. Then set
  621. <tt>build.compiler</tt> to "jikes" for it to be used in your build files.
  622. Doing this explicitly in your build files is a bit dubious as it requires the
  623. whole team (and sub projects) to be using jikes too - something you can only
  624. control in small, closed source projects. But if you set
  625. <tt>ANT_OPTS&nbsp;=&nbsp;-Dbuild.compiler=jikes</tt>
  626. in your environment, then all your builds on your system will use
  627. Jikes automatically, while others can choose their own compiler, or let
  628. ant choose whichever is appropriate for the current version of Java.
  629. <dt><b>
  630. #include targets to simplify multi <tt>build.xml</tt> projects
  631. </b><dd>
  632. You can import XML files into a build file using the XML parser itself.
  633. This lets a multi-project development program share code through reference,
  634. rather than cut and paste re-use. It also lets one build up a file of
  635. standard tasks which can be reused over time. Because the import
  636. mechanism is at a level below which Ant is aware, treat it as
  637. equivalent to the #include mechanism of the 'legacy' languages C and
  638. C++.
  639. <p>
  640. There are two inclusion mechanisms, an ugly one for all parsers and a
  641. clean one. The ugly method is the only one that was available on Ant1.5 and
  642. earlier:-
  643. <pre>
  644. &lt;!DOCTYPE project [
  645. &lt;!ENTITY propertiesAndPaths SYSTEM &quot;propertiesAndPaths.xml&quot;&gt;
  646. &lt;!ENTITY taskdefs SYSTEM &quot;taskdefs.xml&quot;&gt;
  647. ]&gt;
  648. &amp;propertiesAndPaths;
  649. &amp;taskdefs;
  650. </pre>
  651. The cleaner method in Ant1.6 is the <tt>&lt;import&gt;</tt> task that imports
  652. whole build files into other projects. The entity inclusion example
  653. could <i>almost</i> be replaced by two import statements:-
  654. <pre>
  655. &lt;import file="propertiesAndPaths.xml"&gt;
  656. &lt;import file="taskdefs.xml"&gt;
  657. </pre>
  658. We say almost as top level declarations (properties and taskdefs)
  659. do not get inserted into the XML file exactly where the import statement
  660. goes, but added to the end of the file. This is because the import process
  661. takes place after the main build file is parsed, during execution, whereas
  662. XML entity expansion is handled during the parsing process.
  663. <p>
  664. The <tt>&lt;import&gt;</tt> task does powerful things, such as let you override targets,
  665. and use ant properties to name the location of the file to import. Consult the
  666. <a href="manual/CoreTasks/import.html">documentation</a> for the specifics of
  667. these features.
  668. <p>
  669. Before you go overboard with using XML inclusion, note that the
  670. <tt>ant</tt> task lets you call any target in any other build
  671. file - with all your property settings propagating down to that target.
  672. So you can actually have a suite of utility targets
  673. - "<tt>deploy-to-stack-a</tt>", "<tt>email-to-team</tt>", "<tt>cleanup-installation</tt>" which can
  674. be called from any of your main build files, perhaps with subtly changed
  675. parameters. Indeed, after a couple of projects you may be able to create
  676. a re-usable core build file which contains the core targets of a basic
  677. Java development project - compile, debug, deploy - which project specific
  678. build files call with their own settings. If you can achieve this then
  679. you are definitely making your way up the software maturity ladder. With
  680. a bit of work you may progress from being a SEI CMM Level 0 organisation
  681. &quot;Individual Heroics are not enough&quot; to SEI CMM Level 1, &quot;Projects only
  682. succeed due to individual heroics&quot;
  683. <p>
  684. NB, <tt>ant</tt> copies all your properties unless the
  685. <i>inheritall</i> attribute is set to false. Before that attribute
  686. existed you had to carefully name all property definitions in all build
  687. files to prevent unintentional overwriting of the invoked property by
  688. that of the caller, now you just have to remember to set
  689. <tt>inheritall="false"</tt> on all uses of the &lt;ant&gt; task.
  690. <dt><b>
  691. Implement complex Ant builds through XSL
  692. </b><dd>
  693. XSLT can be used to dynamically generate build.xml files from a source
  694. xml file, with the <a href="manual/CoreTasks/style.html">xslt</a> task controlling
  695. the transform. This is the current recommended strategy for creating
  696. complex build files dynamically. However, its use is still apparently
  697. quite rare - which means you will be on the bleeding edge of technology.
  698. <dt><b>
  699. Change the invocation scripts
  700. </b><dd>
  701. By writing your own invocation script - using the DOS, Unix or Perl
  702. script as a starting point - you can modify Ant's settings and behavior for an
  703. individual project. For example, you can use an alternate variable to
  704. <tt>ANT_HOME</tt> as the base, extend the classpath differently, or dynamically
  705. create a new command line property &quot;<tt>project.interfaces</tt>&quot; from all <tt>.jar</tt>
  706. files in an interfaces directory.
  707. <p>
  708. Having a custom invocation script which runs off a CVS controlled
  709. library tree under <tt>PROJECT_HOME</tt> also lets you control Ant versions
  710. across the team - developers can have other copies of Ant if they want,
  711. but the CVS tree always contains the jar set used to build your project.
  712. <p>
  713. You can also write wrapper scripts which invoke the existing Ant
  714. scripts. This is an easy way to extend them. The wrapper scripts can add
  715. extra definitions and name explicit targets, redefine <tt>ANT_HOME</tt> and
  716. generally make development easier. Note that &quot;ant&quot; in Windows is really
  717. &quot;ant.bat&quot;, so should be invoked from another batch file with a "CALL
  718. ant" statement - otherwise it never returns to your wrapper.
  719. <dt><b>
  720. Write all code so that it can be called from Ant
  721. </b><dd>
  722. This seems a bit strange and idealistic, but what it means is that you should
  723. write all your java code as if it may be called as a library at some point in
  724. future. So do not place calls to <tt>System.exit()</tt> deep in the code - if you
  725. want to exit a few functions in, raise an exception instead and have
  726. <tt>main()</tt> deal with it.
  727. <p>
  728. Moving one step further, consider proving an Ant Task interface to the
  729. code as a secondary, primary or even sole interface to the
  730. functionality. Ant actually makes a great bootloader for Java apps as it
  731. handles classpath setup, and you can re-use all the built in tasks for
  732. preamble and postamble work. Some projects, such as
  733. <a href="http://xdoclet.sf.net">XDoclet</a> only run under Ant, because
  734. that is the right place to be.
  735. <dt><b>
  736. Use the replace task to programmatic modify text files in your project.
  737. </b><dd>
  738. Imagine your project has some source files - BAT files, ASPX pages(!), anything
  739. which needs to be statically customised at compile time for particular
  740. installations, such driven from some properties of the project such as JVM options, or the URL
  741. to direct errors too. The replace task can be used to modify files, substituting text and creating
  742. versions customised for that build or destination. Of course, per-destination customisation
  743. should be delayed until installation, but if you are using Ant for the remote installation
  744. that suddenly becomes feasible.
  745. <dt><b>
  746. Use the mailing lists
  747. </b><dd>
  748. There are two
  749. <a href="http://ant.apache.org/mail.html">mailing lists</a>
  750. related to Ant, user and developer. Ant user is where <i>all</i>
  751. questions related to using Ant should go. Installation, syntax, code
  752. samples, etc - post your questions there or search the archives for
  753. whether the query has been posted and answered before. Ant-developer
  754. is where Ant development takes place - so it is <i>not</i> the place to
  755. post things like &quot;I get a compilation error when I build my project&quot; or
  756. &quot;how do I make a zip file&quot;. If you are actually extending Ant, on the other
  757. hand, it is the ideal place to ask questions about how to add new tasks, make
  758. changes to existing ones - and to post the results of your work, if you want them
  759. incorporated into the Ant source tree.
  760. </dl>
  761. <a name="puttingtogether">
  762. <h2>
  763. Putting it all together
  764. </h2>
  765. </a>
  766. What does an Ant build process look like in this world? Assuming a
  767. single directory structure for simplicity, the build file
  768. should contain a number of top level targets
  769. <ul>
  770. <li>build - do an (incremental) build
  771. <li>test - run the junit tests
  772. <li>clean - clean out the output directories
  773. <li>deploy - ship the jars, wars, whatever to the execution system
  774. <li>publish - output the source and binaries to any distribution site
  775. <li>fetch - get the latest source from the cvs tree
  776. <li>docs/javadocs - do the documentation
  777. <li>all - clean, fetch, build, test, docs, deploy
  778. <li>main - the default build process (usually build or build &amp; test)
  779. </ul>
  780. Sub projects &quot;web&quot;, &quot;bean-1&quot;, &quot;bean-2&quot; can be given their own build
  781. files - <tt>web.xml</tt>, <tt>bean-1.xml</tt>, <tt>bean-2.xml</tt> - with the same entry points.
  782. Extra toplevel tasks related to databases, web site images and the like
  783. should be considered if they are part of the process.
  784. <p>
  785. Debug/release switching can be handled with separate initialisation
  786. targets called before the compile tasks which define the appropriate
  787. properties. Antcall is the trick here, as it allows you to have two paths
  788. of property initialisation in a build file.
  789. <p>
  790. Internal targets should be used to structure the process
  791. <ul>
  792. <li> init - initialise properties, extra-tasks, read in per-user
  793. property files.
  794. <li> init-release - initialise release properties
  795. <li> compile - do the actual compilation
  796. <li> link/jar - make the jars or equivalent
  797. <li> staging - any pre-deployment process in which the output is dropped
  798. off then tested before being moved to the production site.
  799. </ul>
  800. The switching between debug and release can be done by making
  801. init-release conditional on a property, such as <tt>release.build</tt>
  802. being set :-
  803. <pre>&lt;target name=&quot;init-release&quot; if=&quot;release.build&quot;&gt;
  804. &lt;property name=&quot;build.debuglevel&quot; value=&quot;lines,source&quot;/&gt;
  805. &lt;/target&gt;
  806. </pre>
  807. You then have dependent targets, such as &quot;compile&quot;, depend on this
  808. conditional target; there the &quot;default&quot; properties are set, and then the
  809. property is actually used. Because Ant properties are <i>immutable</i>,
  810. if the release target was executed its settings will override the
  811. default values:
  812. <pre>&lt;target name=&quot;compile&quot; depends=&quot;init,init-release&quot;&gt;
  813. &lt;property name=&quot;build.debuglevel&quot; value=&quot;lines,vars,source&quot;/&gt;
  814. &lt;echo&gt;debug level=${build.debuglevel}&lt;/echo&gt;
  815. &lt;javac destdir=&quot;${build.classes.dir}&quot;
  816. debug=&quot;true&quot;
  817. debuglevel=&quot;${build.debuglevel}&quot;
  818. includeAntRuntime=&quot;false&quot;
  819. srcdir=&quot;src&quot;&gt;
  820. &lt;classpath refid=&quot;compile.classpath&quot;/&gt;
  821. &lt;/javac&gt;
  822. &lt;/target&gt;
  823. </pre>
  824. As a result, we now have a build where the release mode only includes
  825. the filename and line debug information (useful for bug reports), while
  826. the development system included variables too.
  827. <p>
  828. It is useful to define a project name property which can be echoed in
  829. the init task. This lets you work out which Ant file is breaking in a
  830. multi file build.
  831. <p>
  832. What goes in to the internal Ant tasks depends on your own projects. One
  833. very important tactic is &quot;keep path redefinition down through
  834. references&quot; - you can reuse paths by giving them an ID and then
  835. referring to them via the &quot;refid&quot; attribute you should only need to
  836. define a shared classpath once in the file; filesets can be reused
  837. similarly.
  838. <p>
  839. Once you have set up the directory structures, and defined the Ant tasks
  840. it is time to start coding. An early priority must be to set up the
  841. automated test process, as that not only helps ensures that the code
  842. works, it verifies that the build process is working.
  843. <p>
  844. And that's it. The build file shouldn't need changing as new source
  845. files get added, only when you want to change the deliverables or part
  846. of the build process. At some point you may want to massively
  847. restructure the entire build process, restructuring projects and the
  848. like, but even then the build file you have should act as a foundation
  849. for a split build file process -just pull out the common properties into
  850. a properties file all build files read in, keep the target names unified
  851. and keep going with the project. Restructuring the source code control
  852. system is often much harder work.
  853. <h2>The Limits of Ant</h2>
  854. Before you start adopting Ant as the sole mechanism for the build
  855. process, you need to be aware of what it doesn't do.
  856. <p>
  857. <h3>It's not a scripting language</h3>
  858. Ant lets you declare what you want done, with a bit of testing of the
  859. platform and class libraries first to enable some platform specific
  860. builds to take place. It does not let you specify how to handle things
  861. going wrong (a listener class can do that), or support complex
  862. conditional statements.
  863. <p>
  864. If your build needs to handle exceptions then look at the sound listener
  865. as a simple example of how to write your own listener class. Complex
  866. conditional statements can be handled by having something else do the
  867. tests and then build the appropriate Ant task. XSLT can be used for
  868. this.
  869. <h3>It's not Make</h3>
  870. Some of the features of make, specifically inference rules and
  871. dependency checking are not included in Ant. That's because they are
  872. &quot;different&quot; ways of doing a build. Make requires you to state
  873. dependencies and the build steps, Ant wants you to state tasks and the
  874. order between them, the tasks themselves can do dependency checking or
  875. not. A full java build using Jikes is so fast that dependency checking
  876. is relatively moot, while many of the other tasks (but not all), compare
  877. the timestamp of the source file with that of the destination file
  878. before acting.
  879. <h3>It's not meant to be a nice language for humans</h3>
  880. XML isn't a nice representation of information for humans. It's a
  881. reasonable representation for programs, and text editors and source code
  882. management systems can all handle it nicely. But a complex Ant file can
  883. get ugly because XML is a bit ugly, and a complex build is, well,
  884. complicated. Use XML comments so that the file you wrote last month
  885. still makes sense when you get back to it, and use proper xml editors to edit the
  886. files if you prefer it.
  887. <h3>Big projects still get complicated fast</h3>
  888. Large software projects create their own complexity, with inter-dependent
  889. libraries, long test cycles, hard deployment processes and a multitude of
  890. people each working on their own bit of the solution. That's even before
  891. the deadlines loom close, the integration problems become insurmountable,
  892. weekends become indistinguishable from weekdays in terms of workload and
  893. half the team stops talking to the other half. Ant may simplify the
  894. build and test process, and can eliminate the full time &quot;makefile engineer&quot;
  895. role, but that doesn't mean that someone can stop &quot;owning the build&quot;.
  896. Being in charge of the build has to mean more than they type &quot;<tt>ant all</tt>&quot; on
  897. their system, it means they need to set the standards of what build tools to
  898. use, what the common targets, what property names and files should be
  899. and generally oversee the sub projects build processes. On a small project,
  900. you don't need to do that - but remember: small projects become big projects
  901. when you aren't looking. If you start off with a little bit of process, then
  902. you can scale it if needed. If you start with none, by the time you need
  903. it will be too late.
  904. <h3>You still need all the other foundational bits of a software
  905. project</h3>
  906. If you don't have an source code management system, you are going to end
  907. up hosed. If you don't have everything under SCM, including web pages,
  908. dependent jars, installation files, you are still going to end up hosed,
  909. it's just a question of when it's going to happen.
  910. CVS is effectively free and works well with Ant, but Sourcesafe, Perforce,
  911. Clearcase and StarTeam also have Ant tasks. These tasks
  912. let you have auto-incrementing build counters, and automated file
  913. update processes.
  914. <p>
  915. You also need some kind of change control process, to resist
  916. uncontrolled feature creep. Bugzilla is a simple and low cost tool for
  917. this, using Ant and a continuous test process enables a rapid evolution of code
  918. to adapt to those changes which are inevitable.
  919. <h2>End piece</h2>
  920. Software development is meant to be fun. Being in the maelstrom of a
  921. tight project with the stress of integration and trying to code
  922. everything up for an insane deadline can be fun - it is certainly
  923. exhilarating. Adding a bit of automation to the process may make things
  924. less chaotic, and bit less entertaining, but it is a start to putting
  925. you in control of your development process. You can still have fun, you
  926. should just have less to worry about, a shorter build/test/deploy cycle
  927. and more time to spend on feature creep or important things like skiing.
  928. So get out there and have fun!
  929. <a name="reading">
  930. <h2>Further Reading</h2>
  931. </a>
  932. <ul>
  933. <li>
  934. <a
  935. href="http://www.martinfowler.com/articles/continuousIntegration.html">
  936. <i>Continuous Integration</i></a>; Martin Fowler. <br>
  937. A paper on using Ant within a software project
  938. running a continuous integration/testing process.
  939. <li><i> Refactoring</i>; Martin Fowler, ISBN: 0201485672 <br>
  940. Covers JUnit as well as tactics for making some headway with the mess of
  941. code you will soon have.
  942. <li><a href="http://manning.com/hatcher"><i>Java Development with
  943. Ant</i></a>;
  944. Erik Hatcher and Steve Loughran.
  945. <li>
  946. <a href="http://www.iseran.com/Steve/papers/when_web_services_go_bad.html">
  947. <i>When Web Services Go Bad</i></a>; Steve Loughran.<br>
  948. One of the projects this paper is based on.
  949. </ul>
  950. <a name="author">
  951. <h3>About the Author</h3>
  952. </a>
  953. Steve Loughran is a research scientist at a corporate R&amp;D lab,
  954. currently on a sabbatical building production web services against
  955. implausible deadlines for the fun of it. He is also a committer on
  956. Apache Ant and Apache Axis, and co-author of
  957. <a href="http://manning.com/hatcher"><i>Java Development with Ant</i></a>.
  958. He thinks that if you liked this document you'll love that book because
  959. it doesn't just explain Ant, it goes into processes, deployment and best practices
  960. and other corners of stuff that really make Ant useful. (It would
  961. have been easier to just rehash the manual, but that wouldn't have been
  962. so useful or as much fun).
  963. <p>
  964. For questions related to this document, use the Ant mailing list.
  965. </body>
  966. </html>