Ant in Action

Paperback
from $0.00

Author: Steve Loughran

ISBN-10: 193239480X

ISBN-13: 9781932394801

Category: Programming Languages

This second edition of a Manning bestseller has been revised and re-titled to fit the 'In Action' Series by Steve Loughran, an Ant project committer. Ant in Action introduces Ant and how to use it for test-driven Java application development. Ant itself is moving to v1.7, a major revision, at the end of 2006 so the timing for the book is right. A single application of increasing complexity, followed throughout the book, shows how an application evolves and how to handle the problems of...

Search in google:

This second and completely updated edition introduces Ant and how to use it for test-driven Java application development. A single application of increasing complexity, followed throughout the book, shows how an application evolves and how to handle the problems of building and testing.

Preface to the second edition     xixForeword to the first edition     xxiPreface to the first edition     xxiiiAcknowledgments     xxvAbout this book     xxviiAbout the authors     xxxiAbout the cover illustration     xxxiiIntroduction to the Second Edition     1Learning Ant     3Introducing Ant     5What is Ant?     5The core concepts of Ant     6Ant in action: an example project     8What makes Ant so special?     11When to use Ant     12When not to use Ant     13Alternatives to Ant     13IDEs     13Make     14Maven     16The ongoing-evolution of Ant     16Summary     17A first Ant build     19Defining our first project     19Step zero: creating the project directory     20Step one: verifying the tools are in place     20Step two: writing your first Ant build file     21Examining the build file     21Step three: running your first build     23If the buildfails     23Looking at the build in more detail     25Step four: imposing structure     27Laying out the source directories     28Laying out the build directories     29Laying out the distribution directories     29Creating the build file     31Target dependencies     32Running the new build file     33Incremental builds     34Running multiple targets on the command line     35Step five: running our program     36Why execute from inside Ant?     36Adding an "execute" target     37Running the new target     38Ant command-line options     39Specifying which build file to run     40Controlling the amount of information provided     41Coping with failure     42Getting information about a project     42Examining the final build file     43Running the build under an IDE     44Summary     45Understanding Ant datatypes and properties     47Preliminaries     48What is an Ant datatype?     48Property overview     48Introducing datatypes and properties with [left angle bracket]javac[right angle bracket]     49Paths     52How to use a path     53Filesets     53Patternsets     54Selectors     58Additional Ant datatypes     59Properties     61Setting properties with the [left angle bracket]property[right angle bracket] task     62Checking for the availability of files: [left angle bracket]available[right angle bracket]     66Testing conditions with [left angle bracket]condition[right angle bracket]     67Creating a build timestamp with [left angle bracket]tstamp[right angle bracket]     69Setting properties from the command line     70Controlling Ant with properties     70Conditional target execution     71Conditional build failure     72Conditional patternset inclusion/exclusion     72References     73Viewing datatypes     73Managing library dependencies     75Resources: Ant's secret data model     76Best practices     76Summary     77Testing with JUnit     79What is testing, and why do it?     80Introducing our application     81The application: a diary     81How to test a program     83Introducing JUnit     84Writing a test case     86Running a test case     86Asserting desired results     87Adding JUnit to Ant     90Writing the code     92The JUnit task: [left angle bracket]junit[right angle bracket]     93Fitting JUnit into the build process     94Halting the build when tests fail     96Viewing test results     96Running multiple tests with [left angle bracket]batchtest[right angle bracket]     98Generating HTML test reports     99Halting the builds after generating reports     101Advanced [left angle bracket]junit[right angle bracket] techniques     102Best practices     106The future of JUnit     107Summary     108Packaging projects     110Working with files     111Deleting files     112Copying files     113Moving and renaming files     114Introducing mappers     114Modifying files as you go     119Preparing to package      120Adding data files to the classpath     121Generating documentation     122Patching line endings for target platforms     124Creating JAR files     126Testing the JAR file     128Creating JAR manifests     129Adding extra metadata on the JAR     131JAR file best practices     132Signing JAR files     132Testing with JAR files     135Creating Zip files     136Creating a binary Zip distribution     137Creating a source distribution     138Zip file best practices     139Packaging for Unix     139Tar files     139Generating RPM packages     143Working with resources     143A formal definition of a resource     143What resources are there?     144Resource collections     145Summary     147Executing programs     149Running programs under Ant-an introduction     149Introducing the [left angle bracket]java[right angle bracket] task     151Setting the classpath     152Arguments     153Defining system properties      155Running the program in a new JVM     156JVM tuning     157Handling errors     158Executing JAR files     160Running native programs     161Running our diary as a native program     162Executing shell commands     162Running under different Operating Systems     163Probing for a program     166Advanced [left angle bracket]java[right angle bracket] and [left angle bracket]exec[right angle bracket]     167Setting environment variables     167Handling timeouts     168Running a program in the background     169Input and output     170Piped I/O with an I/O redirector     171FilterChains and FilterReaders     172Bulk operations with [left angle bracket]apply[right angle bracket]     174How it all works     176[left angle bracket]java[right angle bracket]     176[left angle bracket]exec[right angle bracket] and [left angle bracket]apply[right angle bracket]     177Best practices     177Summary     178Distributing our application     179Preparing for distribution     180Securing our distribution     181Server requirements     183FTP-based distribution of a packaged application     183Uploading to Unix     184Uploading to a Windows FTP server     185Uploading to SourceForge     186FTP dependency logic     187Email-based distribution of a packaged application     188Sending HTML messages     191Secure distribution with SSH and SCP     192Uploading files with SCP     193Downloading files with [left angle bracket]scp[right angle bracket]     195Remote execution with [left angle bracket]sshexec[right angle bracket]     197Troubleshooting the SSH tasks     197HTTP download     198How to probe for a server or web page     199Fetching remote files with [left angle bracket]get[right angle bracket]     200Performing the download     201Distribution over multiple channels     203Calling targets with [left angle bracket]antcall[right angle bracket]     203Distributing with [left angle bracket]antcall[right angle bracket]     206Summary     208Putting it all together     209How to write good build files      209Building the diary library     210Starting the project     210The public entry points     211Setting up the build     212Compiling and testing     216Packaging and creating a distribution     218Distribution     222Adopting Ant     225Building an existing project under Ant     228Summary     230Applying Ant     231Beyond Ant's core tasks     233The many different categories of Ant tasks     234Installing optional tasks     236Troubleshooting     238Optional tasks in action     239Manipulating property files     239Improving [left angle bracket]javac[right angle bracket] with dependency checking     241Software configuration management under Ant     243Using third-party tasks     245Defining tasks with [left angle bracket]taskdef[right angle bracket]     246Declaring tasks defined in property files     247Defining tasks into a unique namespace     248Defining tasks from an Antlib     249The Ant-contrib tasks     250The Ant-contrib tasks in action      253Code auditing with Checkstyle     259Summary     263Working with big projects     264Master builds: managing large projects     265Introducing the [left angle bracket]ant[right angle bracket] task     266Designing a scalable, flexible master build file     268Controlling child project builds     270Setting properties in child projects     270Passing down properties and references in [left angle bracket]ant[right angle bracket]     272Advanced delegation     275Getting data back     276Inheriting build files through [left angle bracket]import[right angle bracket]     277XML entity inclusion     277Importing build files with [left angle bracket]import[right angle bracket]     278How Ant overrides targets     279Calling overridden targets     280The special properties of [left angle bracket]import[right angle bracket]     281Applying [left angle bracket]import[right angle bracket]     283Extending an existing build file     283Creating a base build file for many projects     284Mixin build files     286Best practices with [left angle bracket]import[right angle bracket]      287Ant's macro facilities     288Redefining tasks with [left angle bracket]presetdef[right angle bracket]     288The hazards of [left angle bracket]presetdef[right angle bracket]     290Writing macros with [left angle bracket]macrodef[right angle bracket]     291Passing data to a macro     292Local variables     294Effective macro use     295Summary     296Managing dependencies     297Introducing Ivy     299The core concepts of Ivy     299Installing Ivy     301Configuring Ivy     302Resolving, reporting, and retrieving     304Creating a dependency report     305Retrieving artifacts     306Setting up the classpaths with Ivy     307Working across projects with Ivy     308Sharing artifacts between projects     308Using published artifacts in other projects     310Using Ivy to choreograph builds     313Other aspects of Ivy     315Managing file versions through Ivy variables     315Finding artifacts on the central repository     316Excluding unwanted dependencies     317Private repositories     317Moving to Ivy     318Summary     318Developing for the Web     320Developing a web application     321Writing a feed servlet     323Libraries in web applications     324Writing web pages     325Creating a web.xml file     327Building the WAR file     328Deployment     329Deployment by copy     330Post-deployment activities     331Probing for server availability     331Pausing the build with [left angle bracket]sleep[right angle bracket]     333Testing web applications with HttpUnit     333Writing HttpUnit tests     334Compiling the HttpUnit tests     337Running the HttpUnit tests     338Summary     339Working with XML     340Background: XML-processing libraries     341Writing XML     341Validating XML     343Validating documents using DTD files     345Validating documents with XML Schema     347Validating RelaxNG documents     349Reading XML data     352Transforming XML with XSLT     353Defining the structure of the constants file     354Creating the constants file     355Creating XSL style sheets     355Initializing the build file     358Summary     362Enterprise Java     363Evolving the diary application     364Making an Enterprise application     365Creating the beans     366Compiling Java EE-annotated classes     368Adding a session bean     369Extending the web application     371Building the Enterprise application     373Deploying to the application server     378Server-side testing with Apache Cactus     378Writing a Cactus test     379Building Cactus tests     380The Cactus Ant tasks     381Adding Cactus to an EAR file     382Running Cactus tests     383Diagnosing EJB deployment problems     384Summary     385Continuous integration     387Introducing continuous integration     388What do you need for continuous integration?     390Luntbuild     391Installing Luntbuild      393Running Luntbuild     393Configuring Luntbuild     394Luntbuild in action     400Review of Luntbuild     401Moving to continuous integration     402Summary     404Deployment     406How to survive deployment     407Deploying with Ant     410Database setup in Ant     411Creating and configuring a database from Ant     412Issuing database administration commands     413Deploying with SmartFrog     415SmartFrog: a new way of thinking about deployment     415The concepts in more detail     417The SmartFrog components     425Using SmartFrog with Ant     426Deploying with SmartFrog     428Deploying with the [left angle bracket]deploy[right angle bracket] task     433Summary of SmartFrog     435Embracing deployment     436Summary     438Extending Ant     441Writing Ant tasks     443What exactly is an Ant task?     444The life of a task     445Introducing Ant's Java API     446Ant's utility classes      451A useful task: [left angle bracket]filesize[right angle bracket]     453Writing the task     453How Ant configures tasks     455Configuring the [left angle bracket]filesize[right angle bracket] task     457Testing tasks with AntUnit     458Using AntUnit     458Testing the [left angle bracket]filesize[right angle bracket] task     460Running the tests     461More task attributes     463Enumerations     463User-defined types     465Supporting nested elements     465Working with resources     467Using a resource-enabled task     470Delegating to other tasks     471Setting up classpaths in a task     472Other task techniques     476Making an Antlib library     478Summary     481Extending Ant further     483Scripting within Ant     484Writing new tasks with [left angle bracket]scriptdef[right angle bracket]     486Scripting summary     489Conditions     490Writing a conditional task     492Writing a custom resource     493Using a custom resource      496How Ant datatypes handle references     496Selectors     497Scripted selectors     499Developing a custom mapper     499Implementing a custom filter     501Handling Ant's input and output     503Writing a custom listener     505Writing a custom logger     509Using loggers and listeners     511Handling user input with an InputHandler     512Embedding Ant     512Summary     514Installation     516Before you begin     516The steps to install Ant     517Setting up Ant on Windows     517Setting up Ant on Unix     518Installation configuration     520Troubleshooting installation     520XML Primer     525XML namespaces     529IDE Integration     531How IDEs use Ant     531Eclipse http://www.eclipse.org/     533Sun NetBeans http://www.netbeans.org/     539IntelliJ IDEA http://intellij.com/     543Building with Ant and an IDE     546Index     549