Skip to Main Content
Ant: The Definitive Guide, 2nd Edition
book

Ant: The Definitive Guide, 2nd Edition

by Steve Holzner
April 2005
Intermediate to advanced content levelIntermediate to advanced
336 pages
7h 20m
English
O'Reilly Media, Inc.
Content preview from Ant: The Definitive Guide, 2nd Edition

Preparing to Deploy

Ant supports several tasks for setting up a deployment environment, such as delete and mkdir. Both these tasks can be used locally or on a network to set up the directory structure you need to deploy applications.

Tip

If you want to create and delete directories remotely, take a look at the ftp task, coming up later in this chapter.

Deleting Existing Files

When deploying, delete is great to clean up a previous installation or to clean deployment directories before installing. This task deletes a single file, a directory and all its files and subdirectories, or a set of files specified by one or more FileSets.

Using this task, you can delete a single file:

<delete file="/lib/Project.jar"/>

Or you can delete an entire directory, including all files and subdirectories:

<delete dir="${dist}"/>

You can use filesets:

<delete includeEmptyDirs="true">
    <fileset dir="${dist}"/>
</delete>

You've seen delete at work in various places throughout the book, as in the build file in the input folder for Chapter 3s code (repeated in Example 4-2), where the user is asked for confirmation before deleting anything.

Example 4-2. Using the delete task (ch03/input/build.xml)

<?xml version="1.0" ?> <project default="main"> <property name="message" value="Building the .jar file." /> <property name="src" location="source" /> <property name="output" location="bin" /> <target name="main" depends="init, compile, compress"> <echo> ${message} </echo> </target> <target name="init"> <input message="Deleting ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ant: The Definitive Guide

Ant: The Definitive Guide

Eric M. Burke, Jesse Tilly
Tomcat: The Definitive Guide, 2nd Edition

Tomcat: The Definitive Guide, 2nd Edition

Jason Brittain, Ian F. Darwin
Ant in Action

Ant in Action

Erik Hatcher, Steve Loughran
CMake Cookbook

CMake Cookbook

Radovan Bast, Roberto Di Remigio

Publisher Resources

ISBN: 0596006098Supplemental ContentErrata Page