View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Julian Onions > PANT-0.09 > PANT



Annotate this POD

View/Report Bugs
Module Version: 0.09   Source   Latest Release: PANT-0.17


PANT - Perl extension for ANT/NANT like build environments


  perl -output buildlog

  use PANT;
  Phase(1, "Update");
  Task(Command("cvs update"), "Fetch the latest code");
  Phase(2, "Build");
         qr/(#define\s*VERSION\s+)(\d+)/=>q{"$1" . ($2+1)"},
         "Version file updated");
  Task(Command("make all"), "Built distribution");
  Phase(3, "Deploy");
  Task(Command("make distribution"), "Distribution built");
  if (NewerThan(sources=>["myexe"], targets=>["/usr/bin/myexe"])) {
     CopyFiles("myexe", "/usr/bin");


  This is a module to help construct automated build environments.
  The inspiration came from the ANT/NANT build environments which use
  XML to describe a make like syntax of dependencies. For various
  reasons none of these were suitable for my purposes, and I suspect
  that eventually you will end up writing something pretty similar to
  perl in XML to cater for all the things you want to do.  Also a
  module named PANT was just too good a name to miss!

  This module draws on some of the ideas in ANT/NANT, and also in the
  Test::Mode module for ways to do things.  This module is therefore a
  collection of tools to help automate processes, and provide a build
  log of what happened, so remote builds can be observed.


This module provides various useful functions to help in the automated build of a project and to produce a build log. It is still in development, and may well change shape in the light of experience.



This call should be the first call into the module. It does some intialisation, and parses command line arguments in @ARGV. It takes one optional argument which is a string used to title the HTML build log. If not present it will be called "Build Log".

Supported command line options are

-output file

Write the output to the given file.


Simulate a run without actually doing anything.


This function finishes up the run, and should be the last call into the module. It completes the build log in a tidy way.

CallPant(name, options)

This function allows you to call a subsidiary pant build. The build will be run and waited for. A reference in the current log will be made to the new log. It is assumed that the subsidiary build is also using PANT as it passes some command line arguments to sort out the logging.

Options include


Change to the given directory to run the subsidiary build. The log path should be modified so it fits.


This function is purely for help in dividing up the build log. It inserts a heading into the log allowing you to divide the build up into a variety of parts. You might have a pre-build cvs checkput phase, a build phase, and followed up by a test and deployment phase.


This function returns a datestamp in a common format. Its is intended for use in logging output, and also in CVS/SVN type retrievals.

NewerThan(sources=>[qw(f1 f2*.txt)], targets=>[build], ...)

This function provides a make like dependency checker. It has the following arguments,


A list of wildcard (glob'able) files that are the source.


A list of wildcard directories that are descended for source files. Currently all files in the tree are considered possibilities.


A list of wildcard (glob'able) files that are the target

The function will return true if any of the sources are newer than the oldest of the targets.

Task(result, message)

This command evaluates the first argument to see if it is true, and prints the second argument into the log. If the first argument is false, the build will abort.


This function aborts the build and is called internally when thigns go wrong.

Command(cmd, options)

This function runs the given external command, capturing the output for the log, and evaluating the return code to see if it worked.

Currently there is only one option


This will cause the command to run in the given directory, rather than being where you happen to be currently.

CopyFiles(source, destdir)

This function copies all the files that match the source glob pattern to the given directory. The names will remain the same.

CopyFile(source, dest)

This function copies an individual file from the source to the destination. It allows for renaming.

MoveFiles(source, destdir)

This function moves all the files that match the source glob pattern to the given directory. The names will remain the same.

MoveFile(source, dest)

This function moves an individual file from the source to the destination. It allows for renaming.


This function removes the entire tree starting at the given directory. Obviuosly be careful!


Create a given directory, and an required intermediate paths.

UpdateFileVersion(file, patterns)

This functions name will probably change. It allows for updating files contents based on the given set of patterns. Some care is needed to get the patterns and the replacements correct. The replacement text is subject to double evaluation.


This allows additional commentary to be added to the output stream.


This allows additional constructs to be added to the output, such a href references and so on. It is passed onto XML::Writer::dataElement directly and takes the same syntax.


Run the list of perl style test files, and capture the result in the output of the log.


This function returns a PANT::Zip object to help construct the given zip file. See PANT::Zip for more details.


This function returns a PANT::Cvs object to help with running Cvs commands. See PANT::Cvs for more details.

FileCompare(F1, F2, [alg])

This function compares two files for equality using the given hash algorithm. If no algorithm is given, it will use MD5. Returns true if they are the same.


Makes use of XML::Writer to construct the build log.


Julian Onions, <>


Copyright 2005 by Julian Onions

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Don't get caught with your PANT's down.

Don't get your PANT's in a wad.

syntax highlighting: