Targets, macros, and built-ins

Inside the project tag, we're defining a number of target nodes and one macro node. The target nodes define tasks that we can run with the Ant runtime. For instance, we can run ant checkoutFromGit to pull our code and metadata from a git repository. Similarly, this build.xml file defines: retrieve, cleanSourceDirectory, deploy, retrieveAndDeploy, and checkoutFromGitAndDeploy. Any of these can be specified on the Ant command line to fire off that task. Tasks can have dependencies, and if you look closely at the retrieveAndDeploy task, you'll see that it defines the dependencies on retrieve and deploy. Dependencies are run in the order they're defined in and provide you with an easy way to combine several tasks into a more useful task. With our retrieveAndDeploy task, we specify the retrieve task and then the deploy task as dependencies. Nothing else is defined, however, meaning that when we run retrieve and deploy, we're actually running Ant retrieve followed by ant deploy. Astute readers will also notice nodes, such as <echo> and <delete>, which are ant built ins that help manipulate files and echo information back to the screen. Lastly, look at the macrodef node. Macros are Ant's way of allowing you to create your own custom shell commands as new tags. Our macrodef tag establishes an ordered list (<sequential>) of executable shell commands to be called. In this case, git with the three command-line flags specifying the origin, branch, and git command pull. You can just as easily specify pulling from a Subversion, perforce, or Mercurial repository. The Macrodef nodes like this one help make the ant migration toolkit best suited for automated, CI-type deployments.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.141.75