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

Scheduling Automatic Builds

It's time to add some automation to the build process. When you're working alone, you probably won't need to automate nightly builds, but as part of a team, it's a good idea. Larger projects typically have nightly builds posted to a web site, and using various automation tools and tasks like ftp, that's no problem. I'll take a look at various options here.

Unix

You can schedule recurring builds with Unix utilies like crontab, which you use to configure the cron daemon. For example, say you have a shell script that runs your nightly build, dobuild.sh, something like this:

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/local/jdk1.4
export PATH=${PATH}:${ANT_HOME}/bin
cd /home/work
ant -f nightlybuild.xml

You can schedule that build to happen at various times with crontab by starting its editing mode:

-bash-2.05b$ crontab -e

Edit the crontab file to include this line:

run at 00:01 every day 30 0 * * * $HOME/work/dobuild.sh

That makes your build run every night at 12:01 A.M. Easy enough.

Windows

The Windows at command schedules commands to run in Windows at specific times. For example, say you had a batch file, dobuild.bat, which runs your nightly build:

set ANT_HOME=C:\ant\apache-ant-1.6.1
set JAVA_HOME=C:\jdk1.4 
set PATH=%PATH%;%ANT_HOME%\bin
cd C:\work
call %ANT_HOME%\bin\ant.bat -f nightlybuild.xml

You can schedule that build for every night with the Windows at command:

C:\ant>at 00:01 /every:M,T,W,Th,F "C:\work\dobuild.bat" Added a new job with job ID ...
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