Table of contents : Java Development with Ant.pdf......Page 0 brief contents......Page 8 contents......Page 10 preface......Page 24 acknowledgments......Page 26 about this book......Page 28 about the authors......Page 33 about the cover illustration......Page 34 foreword......Page 22 1.1 What is Ant?......Page 38 1.1.2 Why do we think Ant makes a great build tool?......Page 39 1.2 The core concepts of Ant......Page 40 1.2.1 An example project......Page 42 1.3.1 Integrated development environments......Page 45 1.3.2 Make......Page 46 1.3.3 Other build tools......Page 48 1.4 The evolution of Ant......Page 49 1.5.1 eXtreme Programming......Page 51 1.6 Our example project......Page 52 1.6.1 Documentation search engine—example Ant project......Page 53 1.7 Yeah, but can Ant…......Page 54 1.8.3 Microsoft .NET and other languages......Page 56 1.9 Summary......Page 57 2.1 Defining our first project......Page 58 2.3 Step two: writing your first Ant build file......Page 59 2.3.1 Examining the build file......Page 60 2.4 Step three: running your first build......Page 61 2.4.1 If the build fails......Page 62 2.4.2 Looking at the build in more detail......Page 64 2.5 Step four: imposing structure......Page 66 2.5.1 Laying out the source directories......Page 67 2.5.2 Laying out the build directories......Page 68 2.5.3 Laying out the dist directories......Page 69 2.5.5 Target dependencies......Page 70 2.5.6 Running the new build file......Page 71 2.5.7 Rerunning the build......Page 72 2.5.8 How Ant handles multiple targets on the command line......Page 73 2.6.1 Why execute from inside Ant......Page 74 2.6.3 Running the new target......Page 75 2.7 Ant command line options......Page 76 2.7.2 Controlling the amount of information provided......Page 77 2.8 The final build file......Page 79 2.9 Summary......Page 81 chapter3......Page 82 3.1.2 Property overview......Page 83 3.2 Introducing datatypes and properties with ......Page 84 3.3 Paths......Page 86 3.4 Filesets......Page 87 3.4.2 Default excludes......Page 88 3.5 Patternsets......Page 89 3.6 Selectors......Page 91 3.7 Datatype element naming......Page 92 3.8.1 Inserting date stamps in files at build-time......Page 93 3.9 FilterChains and FilterReaders......Page 94 3.10.1 Identity mappe r......Page 96 3.10.3 Merge mapper......Page 97 3.10.5 Regexp mapper......Page 98 3.10.6 Package mapper......Page 99 3.11.3 Filelist......Page 100 3.12 Properties......Page 101 3.12.1 Setting properties with the task......Page 102 3.12.3 Checking for the availability of resources: ......Page 105 3.12.5 Testing conditions with ......Page 107 3.12.6 Setting properties from the command-line......Page 109 3.12.7 Creating a build timestamp with ......Page 110 3.12.8 Loading properties from an XML file......Page 111 3.13.1 Conditional target execution......Page 112 3.13.3 Conditional build failure......Page 113 3.14 References......Page 114 3.14.1 Properties and references......Page 115 3.14.2 Using references for nested patternsets......Page 116 3.15 Best practices......Page 117 3.16 Summary......Page 118 chapter4......Page 120 4.2 Java main() testing......Page 121 4.3 JUnit primer......Page 122 4.3.3 Asserting desired results......Page 123 4.3.5 Writing a TestSuite......Page 125 4.3.7 Extensions to JUnit......Page 126 4.4.1 Writing the test first......Page 127 4.4.2 Dealing with external resources during testing......Page 128 4.5.1 Structure directories to accommodate testing......Page 129 4.5.2 Fitting JUnit into the build process......Page 130 4.6.1 Capturing test results......Page 132 4.6.2 Running multiple tests......Page 134 4.7 Generating test result reports......Page 135 4.7.1 Generate reports and allow test failures to fail the build......Page 137 4.7.3 Initializing the test environment......Page 138 4.7.4 Other test issues......Page 139 4.8 Short-circuiting tests......Page 140 4.8.1 Dealing with large number of tests......Page 143 4.9 Best practices......Page 144 4.10 Summary......Page 145 5.1 Why you need to run externalprograms......Page 146 5.2 Running Java programs......Page 147 5.2.1 Introducing the task......Page 148 5.2.2 Setting the classpath......Page 149 5.2.3 Arguments......Page 150 5.2.4 Defining system properties......Page 151 5.2.5 Running the program in a new JVM......Page 152 5.2.7 Controlling the new JVM......Page 153 5.2.8 Handling errors with failonerror......Page 154 5.2.9 Executing JAR files......Page 155 5.2.10 Calling third-party programs......Page 156 5.2.11 Probing for a Java program before calling it......Page 158 5.3 Starting native programs with......Page 159 5.3.2 Handling errors......Page 161 5.3.4 Making and executing shell commands......Page 162 5.3.5 Probing for a program before calling it......Page 164 5.4 Bulk execution with ......Page 165 5.5 Processing output......Page 166 5.7 Best practices......Page 167 5.8 Summary......Page 168 chapter6......Page 169 6.1.1 How to delete files......Page 170 6.1.2 How to copy files......Page 171 6.1.3 How to move files......Page 172 6.1.4 Filtering......Page 173 6.2.1 Building and documenting release code......Page 174 6.2.2 Adding data files......Page 176 6.2.3 Preparing documentation......Page 177 6.2.4 Preparing install scripts and documents......Page 178 6.2.5 Preparing libraries for redistribution......Page 180 6.3 Creating archive files......Page 181 6.3.2 Creating a JAR file......Page 183 6.3.3 Testing the JAR file......Page 184 6.3.4 Creating JAR manifests......Page 185 6.3.7 Signing JAR files......Page 187 6.4.1 Creating a binary distribution......Page 189 6.4.2 Creating a source distribution......Page 191 6.4.4 Zip file best practices......Page 192 6.5 Creating tar files......Page 193 6.6 Creating web applications with WARfiles......Page 195 6.7 Testing packaging......Page 196 6.8 Summary......Page 197 chapter7......Page 198 7.1.2 Tools for deployment......Page 199 7.2 Tasks for deployment......Page 200 7.2.2 Probing for server availability......Page 201 7.2.3 Inserting pauses into the build with ......Page 203 7.2.4 Ant’s email task......Page 204 7.2.5 Fetching remote files with ......Page 205 7.3 FTP-based distribution of apackagedapplication......Page 206 7.3.1 Asking for information with the task......Page 207 7.4 Email-based distribution of apackagedapplication......Page 208 7.5 Local deployment to Tomcat4.x......Page 209 7.5.1 The Tomcat management servlet API......Page 210 7.5.2 Deploying to Tomcat with Ant......Page 211 7.6 Remote deployment to Tomcat......Page 216 7.6.1 Interlude: calling targets with ......Page 217 7.6.2 Using in deployment......Page 220 7.8 Summary......Page 222 8.1 Our application thus far......Page 223 8.2 Building the custom Ant task library......Page 224 8.3 Loading common properties across multipleprojects......Page 229 8.4 Handling versioned dependencies......Page 231 8.4.1 Installing a new library version......Page 233 8.5.4 Make it portable......Page 235 8.6 Summary......Page 236 chapter9......Page 240 9.1.1 Analyzing your project......Page 241 9.1.3 Evolve the build file......Page 243 9.2 Migrating to Ant......Page 244 9.3 The ten steps of migration......Page 245 9.3.2 Migrating from IDE-based projects......Page 246 9.4.1 Refactoring build files......Page 247 9.4.3 Example: a basic master build file......Page 248 9.4.4 Designing a scalable, flexible master build file......Page 250 9.5.1 How to control properties of child projects......Page 256 9.5.2 Inheriting properties and references from a master build file......Page 258 9.5.3 Declaring properties and references in ......Page 259 9.5.4 Sharing properties via XML file fragments......Page 260 9.5.5 Sharing targets with XML file fragments......Page 262 9.6 Creating reusable library build files......Page 263 9.7 Looking ahead: large project support evolution......Page 265 9.8 Ant project best practices......Page 266 9.8.2 Implementing processes......Page 267 9.9 Summary......Page 268 chapter10......Page 269 10.1.1 So, what is an “optional” task?......Page 270 10.1.2 Ant’s major optional tasks......Page 271 10.2.1 Manipulating property files......Page 272 10.2.2 Adding audio and visual feedback during a build......Page 274 10.2.3 Adding dependency checks......Page 276 10.2.4 Grammar parsing with JavaCC......Page 278 10.2.5 Regular expression replacement......Page 279 10.3.1 CVS......Page 280 10.3.2 ClearCase......Page 281 10.4.1 Defining tasks with ......Page 282 10.5.1 Checkstyle......Page 283 10.5.2 Torque–object-relational mapping......Page 285 10.6 The ant-contrib tasks......Page 288 10.8 Best practices......Page 293 10.9 Summary......Page 294 chapter11......Page 295 11.2 To-do list generation......Page 296 11.3 XDoclet architecture......Page 297 11.3.1 XDoclet’s Ant tasks......Page 298 11.3.2 Templating......Page 299 11.4 Writing your own XDoclet template......Page 300 11.4.1 Code generation......Page 302 11.4.2 Per-class versus single-file generation......Page 307 11.5 Advanced XDoclet......Page 308 11.5.2 Creating a custom tag handler......Page 309 11.6.1 XDoclet versus C#......Page 310 11.7.1 Dependency checking......Page 311 11.8 Summary......Page 312 chapter12......Page 313 12.1 How are web applications different?......Page 314 12.2.1 Creating a tag library......Page 315 12.2.2 Integrating tag libraries......Page 321 12.2.3 Summary of taglib development with Ant......Page 322 12.3 Compiling JSP pages......Page 323 12.3.2 Using the task......Page 324 12.3.3 JSP compilation for deployment......Page 326 12.4.1 Filterset-based customization......Page 327 12.4.2 Customizing deployment descriptors with XDoclet......Page 329 12.5.1 Generating new content......Page 332 12.5.2 Creating new files......Page 333 12.6 Testing web applications with HttpUnit......Page 334 12.6.1 Writing HttpUnit tests......Page 335 12.6.2 Compiling the tests......Page 337 12.6.4 Running the HttpUnit tests......Page 338 12.6.5 Integrating the tests......Page 339 12.6.7 Canoo WebTest......Page 341 12.7 Server-side testing with Cactus......Page 345 12.7.1 Cactus from Ant’s perspective......Page 346 12.7.2 How Cactus works......Page 348 12.7.4 Cactus summary......Page 349 12.8 Summary......Page 350 chapter13......Page 352 13.1 Preamble: all about XML libraries......Page 353 13.2 Validating XML......Page 354 13.2.1 When a file isn’t validated......Page 355 13.2.2 Resolving XML DTDs......Page 356 13.2.3 Supporting alternative XML validation mechanisms......Page 357 13.3 Transforming XML with XSLT......Page 358 13.3.1 Using the XMLCatalog datatype......Page 360 13.4 Generating an XML build log......Page 362 13.4.1 Stylesheets......Page 363 13.4.2 Output files......Page 364 13.4.3 Postprocessing the build log......Page 365 13.5 Loading XML data into Antproperties......Page 366 13.7 Summary......Page 367 14.1 EJB overview......Page 368 14.1.2 EJB JAR......Page 369 14.2 A simple EJB build......Page 370 14.3 Using Ant’s EJB tasks......Page 371 14.4 Using ......Page 372 14.4.1 Vendor-specific processing......Page 374 14.5 Using XDoclet for EJB development......Page 375 14.5.1 XDoclet subtasks......Page 376 14.5.2 XDoclet’s @tags......Page 377 14.5.4 Ant property substitution......Page 378 14.6 Middlegen......Page 380 14.7 Deploying to J2EE application servers......Page 383 14.8 A complete EJB example......Page 384 14.10 Summary......Page 389 chapter15......Page 390 15.1 What are web services and what is SOAP?......Page 391 15.2 Creating a SOAP client application with Ant......Page 392 15.2.1 Preparing our build file......Page 393 15.2.2 Creating the proxy classes......Page 394 15.2.4 Compiling the SOAP client......Page 396 15.2.5 Running the SOAP service......Page 397 15.3 Creating a SOAP service with Axisand Ant......Page 398 15.3.1 The simple way to build a web service......Page 399 15.4.1 Configuring the web application......Page 402 15.4.3 Including SOAP services in the build......Page 403 15.4.4 Testing the server for needed classes......Page 404 15.4.6 Deploying our web service......Page 405 15.5.1 Importing the WSDL......Page 406 15.5.2 Implementing the tests......Page 407 15.5.3 Writing the Java client......Page 410 15.7 Building a C# client......Page 411 15.7.1 Probing for the classes......Page 412 15.7.2 Importing the WSDL in C#......Page 413 15.7.4 Building the C# client......Page 414 15.7.5 Running the C# client......Page 415 15.8 The rigorous way to build a webservice......Page 416 15.9 Reviewing web service development......Page 417 15.10 Calling Ant via SOAP......Page 418 15.11 Summary......Page 419 chapter16......Page 421 16.1.1 The Windows way......Page 422 16.2 CruiseControl......Page 423 16.2.2 It’s all about the cruise—getting the build runner working......Page 424 16.2.3 Build log reporting......Page 430 16.2.7 Pros and cons to CruiseControl......Page 431 16.3 Anthill......Page 432 16.3.1 Getting Anthill working......Page 433 16.3.2 How Anthill works......Page 434 16.3.3 Anthill summary......Page 435 16.4.1 Installing and running Gump......Page 436 16.4.2 How Gump works......Page 438 16.4.3 Summary of Gump......Page 439 16.5 Comparison of continuous integration tools......Page 440 16.6 Summary......Page 441 17.1 The challenge of native code......Page 442 17.2.1 Delegating to an IDE......Page 443 17.2.2 Using Make......Page 444 17.3.1 Installing the tasks......Page 445 17.3.3 A quick introduction to the task......Page 446 17.4 Building a JNI library in Ant......Page 447 17.4.1 Steps to building a JNI library......Page 448 17.4.2 Writing the Java stub......Page 449 17.4.3 Writing the C++ class......Page 450 17.4.4 Compiling the C++ source......Page 451 17.4.5 Deploying and testing the library......Page 454 17.5.1 Migrating the C++ source......Page 457 17.5.2 Extending the build file......Page 458 17.5.4 Porting the code......Page 459 17.6.1 Defining preprocessor macros......Page 460 17.6.2 Linking to libraries with ......Page 461 17.6.3 Configuring compilers and linkers......Page 462 17.6.4 Customizing linkers......Page 463 17.7 Distributing native libraries......Page 464 17.8 Summary......Page 465 chapter18......Page 466 18.1.1 Fundamentally different underlying behaviors......Page 467 18.1.2 Different Java run-time behavior......Page 468 18.1.3 Coping with different API implementations......Page 469 18.1.7 Server-specific management......Page 471 18.2.2 Operations tests......Page 472 18.2.4 Integrating operations with the build process......Page 473 18.3.2 Have a unified target for creating the archive files......Page 475 18.3.3 Run Ant server-side to deploy......Page 476 18.4.1 The task......Page 477 18.4.3 Remote control with ......Page 478 18.5.1 The plan......Page 481 18.5.5 The remote build.xml build file......Page 482 18.5.6 Writing the build file for installing to a server......Page 484 18.5.7 Uploading to the remote server......Page 485 18.5.8 The remote deployment in action......Page 489 18.5.9 Reviewing the deployment process......Page 490 18.6.1 Tomcat 4.0 and 4.1......Page 491 18.6.3 HP Bluestone application server......Page 493 18.7 Verifying deployment......Page 494 18.7.2 Adding the timestamp file to the application......Page 495 18.8 Best practices......Page 497 18.9 Summary......Page 498 chapter19......Page 502 19.1.1 The world’s simplest Ant task......Page 503 19.1.3 Task lifecycle......Page 504 19.2.1 Task......Page 505 19.2.2 Project......Page 506 19.2.5 DirectoryScanner......Page 507 19.2.7 FileUtils......Page 508 19.3.1 Setting attributes......Page 509 19.3.2 Supporting nested elements......Page 515 19.3.3 Supporting datatypes......Page 516 19.3.4 Allowing free-form body text......Page 517 19.4.1 Adding an attribute to a task......Page 518 19.4.2 Handling element text......Page 519 19.5 Operating on a fileset......Page 520 19.6 Error handling......Page 521 19.8 Executing external programs......Page 522 19.9.1 Example task to execute a forked Java program......Page 525 19.10 Supporting arbitrarily named elements and attributes......Page 528 19.11 Building a task library......Page 530 19.13 Summary......Page 532 chapter20......Page 533 20.1 Scripting within Ant......Page 534 20.1.1 Implicit objects provided to ......Page 535 20.1.2 Scripting summary......Page 536 20.2 Listeners and loggers......Page 537 20.2.1 Writing a custom listener......Page 538 20.2.2 Using Log4j logging capabilities......Page 541 20.2.3 Writing a custom logger......Page 544 20.2.4 Using the MailLogger......Page 548 20.3 Developing a custom mapper......Page 549 20.4 Creating custom selectors......Page 550 20.4.1 Using a custom selector in a build......Page 551 20.5 Implementing a custom filter......Page 552 20.5.1 Coding a custom filter reader......Page 554 20.6 Summary......Page 555 appendixa......Page 558 appendixb......Page 567 appendixc......Page 571 appendixd......Page 579 appendixe......Page 596 index......Page 660 Resources......Page 656