The JWare/AntX build-core(mktemp) package contains helper tasks that create file system entities like simple files and scratch directories.

The main script-facing components in this package are: TempLocator(<tempdir>), MkTempFile(<newtempfile>), MkTempDirectory(<newtempdir>), MkFileTask(<newfile>), ParentDirTask(<parentdir>), TruncateFileTask(<truncatefile>), ListDirTask(<listdir>), and MkdirsTask(<mkdirs>).

The TempLocator class is both a utility and a standalone task that lets you locate the system defined temporary directory from within Ant. The other creation tasks, all derived from MkNewObject, use the TempLocator class to create scratch objects.

The various "MkTemp" tasks (subclassed from MkTempObject) enable script authors to create scratch and temporary file system objects; this functionality is particularly useful in test scripts. Temporary files (and optionally directories) are marked for auto-deletion when the Ant runtime exits.

The MkFileTask (<newfile>) task lets you create simple text files directly from either test scripts or regular build scripts. This functionality complements the standard Ant <copy> task as it allows you to copy the contents of resource-based information as well as regular files. You can also specify the file's contents inlined (using the nested <line>) parameters.

The ParentDirTask (<parentdir>) is an extension of the standard <dirname> task that handles file urls, resources, and multi-level pops (to obtain (great) grand-parent directories). ParentDirTask also helps you to maneuver around temp directory based subtrees using relative positioning.

The TruncateFileTask lets you set the size of an existing file or set of files to zero without deleting that file or creating an unwanted newline (as for example with the standard <echo> task). You would most likely need the truncate task to clear quickly a collection of disparately located files.

The ListDirTask is a utility task that lets you copy the contents of a directory (or directory tree) into the active project as an AntX string list. You can then iterate over this string list using one of the many AntX flow control tasks. See the AntX item list value URI handler; it lets you read various bits of information from a dynamically generated string list.

The MkdirsTask is a utility task that lets you create a disparate collection of directory trees in one step. Most useful for constructing build directory structures for new projects and distribution and/or deployment builds.

[More Learning Materials]   [Documentation Problems]
( Updated: Apr 13 2005, 09:30 AM, -0400 )