Apache Myrmidon

Myrmidon

User Guide

Extending Ant

Container Design

Handling Files

Myrmidon includes a Virtual File System (VFS), which allows files from different sources to be treated identically. The VFS currently supports the following file types:

File System Description URL Format
Local Files Files on the local file system. Three different formats are currently supported for local file names:
  • file:// absolute-file-name
  • Absolute file names
  • Relative file names. These are resolved relative to the project's base directory.
Zip Files The contents of Zip files (and Jar, War, and Ear files). Currently, the VFS supports read-only access to Zip file contents. zip: zip-file-uri [!absolute-path]
FTP Files on an FTP server. ftp:// [[password:] username@] hostname [:port] [absolute-path]
SMB Files on a CFIS server, such as Samba or Windows shares. smb:// [[password:] username@] hostname [:port] [absolute-path]

Both forward or backward slashes can be used to separate the elements of a URL.

Here are some example URLs:

  • build/classes
  • c:\program files\ant\bin
  • file://C:/program files/ant
  • zip:build/lib/ant.jar!/org/apache/tools
  • ftp://adam@somehost/pub/downloads
  • smb://password:adam@somehost/home/adam

Currently, there are only a handful of VFS aware tasks. This will grow as more tasks are ported to the new API, and data types.

File Sets

A file set in Myrmidon is more general than Ant 1's concept of a file set. Firstly, there is more than one type of file set. Secondly, they are VFS enabled. File sets are automatically converted to a path, and so can be used anywhere that a path can.

<v-fileset>

This is the equivalent of Ant 1's <fileset> (The name is temporary, it will be changed to <fileset> once more porting work as been completed).

Rather than use a set of include and exclude patterns to choose the files that make up the file set, <v-fileset> takes zero or more file selectors. File selectors can be used to select files based on any attribute of the file, rather than just the name. You can use <name> selectors to achieve the same result as using includes or excludes.

A <v-fileset> element takes the following attributes:

Attribute Description Default Value
dir The base directory for the file set. This can be any URL that the VFS supports. Required

A <v-fileset> element takes any number of nested file selector elements. To be included in the file set, a file must be selected by all the file selectors. That is, the file selectors are implicitly AND-ed together. If no file selector is provided, all the files and directories are included in the set.

An example:


<v-fileset dir="src">
    <name pattern="org/apache/tools/ant/**"/>
    <is-file/>
</v-fileset>

<flat-fileset>

This file set takes a set of nested file sets and paths, and flattens them into a single directory. It can be used as a way of converting a path into a file set. It can also be used as a replacement for the flatten attribute for the copy and move tasks.

A <flat-fileset> element takes no attributes, and a set of nested paths or file sets.

An example:


<v-copy todir="dist/lib">
  <flat-fileset>
    <v-fileset dir="build/lib">
      <basename pattern="*.jar"/>
    <v-fileset>
    <v-path path="${classpath}"/>
  </flat-fileset>
</v-copy>

<mapped-fileset>

A fileset that applies a file name mapper to a nested fileset.

Paths

Paths are an ordered list of files.

<v-path>

This is the equivalent of Ant 1's <path>.

<filtered-path>

A path that applies file selectors to a set of nested file sets and paths.

File Selectors

File selectors are used to select files from file sets and paths.

<and>

Combines zero or more file selectors, using AND. An empty <and> selector accepts all files.

<basename>

Selects files whose base name matches an Ant 1 style pattern, or a regular expression.

<condition>

Takes a set of conditions. If the conditions evaluate to true, then select every file. Otherwise, select no files.

<exists>

Selects files that exist.

<is-empty-folder>

Selects empty folders, that is, folders that have no children.

<is-folder>

Selects folders, does not select regular files.

<is-file>

Selects regular files, does not select folders.

<name>

Selects files whose path in a file set matches an Ant 1 style pattern, or a regular expression.

<not>

Selects files that are not selected by a nested file selector.

<or>

Combines zero or more file selectors, using OR. An empty <or> selector accepts all files.

<url>

Selects files whose URL matches an Ant 1 style pattern, or a regular expression.


Copyright © 2000-2002, Apache Software Foundation