adammurdoch 02/02/27 20:49:32
Modified: proposal/myrmidon/docs user.html
proposal/myrmidon/src/java/org/apache/antlib/vfile
DefaultFileSet.java FilteredFileList.java
SingletonFileList.java
proposal/myrmidon/src/xdocs user.xml
Added: proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors
AbstractNameFileSelector.java AndFileSelector.java
BaseNameFileSelector.java
ExistenceFileSelector.java
IsEmptyFolderSelector.java IsFileSelector.java
IsFolderSelector.java NameFileSelector.java
NotFileSelector.java OrFileSelector.java
UrlFileSelector.java
Removed: proposal/myrmidon/src/java/org/apache/antlib/vfile
AbstractNameFileSelector.java AndFileSelector.java
BaseNameFileSelector.java
ExistenceFileSelector.java IsDirectorySelector.java
IsFileSelector.java NameFileSelector.java
NotFileSelector.java OrFileSelector.java
UrlFileSelector.java
Log:
* Started writing up the VFS and the data types.
* Moved selectors into their own package.
* Added <is-empty> selector.
Revision Changes Path
1.2 +390 -0 jakarta-ant/proposal/myrmidon/docs/user.html
Index: user.html
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/docs/user.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- user.html 27 Feb 2002 01:24:11 -0000 1.1
+++ user.html 28 Feb 2002 04:49:32 -0000 1.2
@@ -65,6 +65,70 @@
into the <code>dist</code> directory. The distribution is a ready-to-run
installation of Myrmidon.
</p>
+ <p>There are a number features that are not
built unless the appropriate optional Jar
+files are found in the <code>lib</code> directory:</p>
+ <table>
+ <tr>
+ <td bgcolor="#039acc" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Feature
+ </font>
+ </td>
+ <td bgcolor="#039acc" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Jar File
+ </font>
+ </td>
+ <td bgcolor="#039acc" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Download From
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ SMB VFS support (Samba, Windows shares)
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ jcifs.jar
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ <a href="http://jcifs.samba.org">jcifs.samba.org</a>
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ FTP VFS support
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ netcomponents.jar
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ <a
href="http://www.savarese.org/oro/software/NetComponents.html">www.savarese.org</a>
+ </font>
+ </td>
+ </tr>
+ </table>
</blockquote>
</td></tr>
</table>
@@ -726,6 +790,332 @@
</td>
</tr>
</table>
+ </blockquote>
+ </td></tr>
+ </table>
+ </blockquote>
+ </td></tr>
+ </table>
+ <table border="0" cellspacing="0" cellpadding="2" width="100%">
+ <tr><td bgcolor="#525D76">
+ <font color="#ffffff" face="arial,helvetica,sanserif">
+ <a name="Handling Files"><strong>Handling Files</strong></a>
+ </font>
+ </td></tr>
+ <tr><td>
+ <blockquote>
+ <p>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:</p>
+ <table>
+ <tr>
+ <td bgcolor="#039acc" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ File System
+ </font>
+ </td>
+ <td bgcolor="#039acc" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Description
+ </font>
+ </td>
+ <td bgcolor="#039acc" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ URL Format
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Local Files
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Files on the local file system.
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Three different formats are currently supported for local file
names:
+ <ul>
+ <li><code>file://</code> <i>absolute-file-name</i></li>
+ <li>Absolute file names</li>
+ <li>Relative file names. These are resolved relative to the
+ project's base directory.
+ </li>
+ </ul>
+
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Zip Files
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ The contents of Zip files (and Jar, War, and Ear files).
+ Currently, the VFS supports read-only access to Zip file contents,
+ and only for local Zip files.
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ <code>zip://</code> <i>zip-file-path</i>
[<code>!</code><i>absolute-path</i>]
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ FTP
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Files on an FTP server.
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ <code>ftp://</code> [[<i>password</i><code>:</code>]
<i>username</i><code>@</code>] <i>hostname</i> [<code>:</code><i>port</i>]
[<i>absolute-path</i>]
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ SMB
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Files on a CFIS server, such as Samba or Windows shares.
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ <code>smb://</code> [[<i>password</i><code>:</code>]
<i>username</i><code>@</code>] <i>hostname</i> [<code>:</code><i>port</i>]
[<i>absolute-path</i>]
+ </font>
+ </td>
+ </tr>
+ </table>
+ <p>Here are some example URLs:</p>
+ <ul>
+ <li><code>build/classes</code></li>
+ <li><code>c:\program files\ant\bin</code></li>
+ <li><code>file://C:/program files/ant</code></li>
+ <li><code>zip://build/lib/ant.jar!/org/apache/tools</code></li>
+ <li><code>ftp://[EMAIL PROTECTED]/pub/downloads</code></li>
+ <li><code>smb://password:[EMAIL PROTECTED]/home/adam</code></li>
+</ul>
+ <p>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.</p>
+ <table border="0" cellspacing="0"
cellpadding="2" width="100%">
+ <tr><td bgcolor="#828DA6">
+ <font color="#ffffff" face="arial,helvetica,sanserif">
+ <a name="File Sets"><strong>File Sets</strong></a>
+ </font>
+ </td></tr>
+ <tr><td>
+ <blockquote>
+ <p>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 <a href="#Paths">path</a>, and so
+can be used anywhere that a path can.</p>
+ <h3><code><v-fileset></code></h3>
+ <p>This is the equivalent of Ant 1's
<code><fileset></code> (The name
+is temporary, it will be changed to <code><fileset></code> once more
+porting work as been completed).</p>
+ <p>Rather than use a set of include and
exclude patterns to choose the files
+that make up the file set, <code><v-fileset></code> takes zero or more
+<a href="#File Selectors">file selectors</a>. File selectors can be used to
+select files based on any attribute of the file, rather than just the name.
+You can use <code><name></code> selectors to achieve the same result
+as using includes or excludes.</p>
+ <p>A <code><v-fileset></code> element
takes the following attributes:</p>
+ <table>
+ <tr>
+ <td bgcolor="#039acc" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Attribute
+ </font>
+ </td>
+ <td bgcolor="#039acc" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Description
+ </font>
+ </td>
+ <td bgcolor="#039acc" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Default Value
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ dir
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ The base directory for the file set. This can be any URL that the
+ VFS supports.
+ </font>
+ </td>
+ <td bgcolor="#a0ddf0" colspan="" rowspan=""
+ valign="top" align="left">
+ <font color="#000000" size="-1" face="arial,helvetica,sanserif">
+ Required
+ </font>
+ </td>
+ </tr>
+ </table>
+ <p>A <code><v-fileset></code> element
takes any number of nested
+<a href="#File Selectors">file selector</a> 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.</p>
+ <p>An example:</p>
+ <div align="left">
+ <table cellspacing="4" cellpadding="0" border="0">
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img
src="/images/void.gif" width="1" height="1" vspace="0" hspace="0"
border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img
src="/images/void.gif" width="1" height="1" vspace="0" hspace="0"
border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#ffffff"><pre>
+
+<v-fileset dir="src">
+ <name pattern="org/apache/tools/ant/**"/>
+ <is-file/>
+</v-fileset>
+</pre></td>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img
src="/images/void.gif" width="1" height="1" vspace="0" hspace="0"
border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img
src="/images/void.gif" width="1" height="1" vspace="0" hspace="0"
border="0"/></td>
+ </tr>
+ </table>
+ </div>
+ <h3><code><flat-fileset></code></h3>
+ <p>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 <code>flatten</code>
+attribute for the copy and move tasks.</p>
+ <p>A <code><flat-fileset></code>
element takes no attributes, and a set
+of nested paths or file sets.</p>
+ <p>An example:</p>
+ <div align="left">
+ <table cellspacing="4" cellpadding="0" border="0">
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img
src="/images/void.gif" width="1" height="1" vspace="0" hspace="0"
border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img
src="/images/void.gif" width="1" height="1" vspace="0" hspace="0"
border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#ffffff"><pre>
+
+<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>
+</pre></td>
+ <td bgcolor="#023264" width="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ </tr>
+ <tr>
+ <td bgcolor="#023264" width="1" height="1"><img
src="/images/void.gif" width="1" height="1" vspace="0" hspace="0"
border="0"/></td>
+ <td bgcolor="#023264" height="1"><img src="/images/void.gif"
width="1" height="1" vspace="0" hspace="0" border="0"/></td>
+ <td bgcolor="#023264" width="1" height="1"><img
src="/images/void.gif" width="1" height="1" vspace="0" hspace="0"
border="0"/></td>
+ </tr>
+ </table>
+ </div>
+ </blockquote>
+ </td></tr>
+ </table>
+ <table border="0" cellspacing="0"
cellpadding="2" width="100%">
+ <tr><td bgcolor="#828DA6">
+ <font color="#ffffff" face="arial,helvetica,sanserif">
+ <a name="Paths"><strong>Paths</strong></a>
+ </font>
+ </td></tr>
+ <tr><td>
+ <blockquote>
+ <p>Paths are an ordered list of files.</p>
+ <h3><code><v-path></code></h3>
+ <p>This is the equivalent of Ant 1's
<code><path></code>.</p>
+ <h3><code><filtered-path></code></h3>
+ <p>A path that applies file selectors to a
set of nested file sets and paths.</p>
+ </blockquote>
+ </td></tr>
+ </table>
+ <table border="0" cellspacing="0"
cellpadding="2" width="100%">
+ <tr><td bgcolor="#828DA6">
+ <font color="#ffffff" face="arial,helvetica,sanserif">
+ <a name="File Selectors"><strong>File Selectors</strong></a>
+ </font>
+ </td></tr>
+ <tr><td>
+ <blockquote>
+ <p>File selectors are used to select files from file
sets and paths.</p>
+ <h3><code><and></code></h3>
+ <p>Combines zero or more file selectors,
using AND. An empty <code><and></code>
+selector accepts all files.</p>
+ <h3><code><basename></code></h3>
+ <p>Selects files whose base name matches an
Ant 1 style pattern, or a regular
+expression.</p>
+ <h3><code><exists></code></h3>
+ <p>Selects files that exist.</p>
+ <h3><code><is-empty></code></h3>
+ <p>Selects empty folders, that is, folders
that have no children.</p>
+ <h3><code><is-folder></code></h3>
+ <p>Selects folders, does not select regular
files.</p>
+ <h3><code><is-file></code></h3>
+ <p>Selects regular files, does not select
folders.</p>
+ <h3><code><name></code></h3>
+ <p>Selects files whose path in a file set
matches an Ant 1 style pattern, or
+a regular expression.</p>
+ <h3><code><not></code></h3>
+ <p>Selects files that are not selected by a
nested file selector.</p>
+ <h3><code><or></code></h3>
+ <p>Combines zero or more file selectors,
using OR. An empty <code><or></code>
+selector accepts all files.</p>
+ <h3><code><url></code></h3>
+ <p>Selects files whose URL matches an Ant 1
style pattern, or a regular expression.</p>
</blockquote>
</td></tr>
</table>
1.2 +1 -0
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileSet.java
Index: DefaultFileSet.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/DefaultFileSet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultFileSet.java 27 Feb 2002 12:05:36 -0000 1.1
+++ DefaultFileSet.java 28 Feb 2002 04:49:32 -0000 1.2
@@ -15,6 +15,7 @@
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
+import org.apache.antlib.vfile.selectors.AndFileSelector;
/**
* A file set, that contains those files under a directory that match
1.2 +2 -1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/FilteredFileList.java
Index: FilteredFileList.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/FilteredFileList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FilteredFileList.java 27 Feb 2002 12:05:36 -0000 1.1
+++ FilteredFileList.java 28 Feb 2002 04:49:32 -0000 1.2
@@ -11,12 +11,13 @@
import org.apache.aut.vfs.FileObject;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
+import org.apache.antlib.vfile.selectors.AndFileSelector;
/**
* A file-list which filters another.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
- * @version $Revision: 1.1 $ $Date: 2002/02/27 12:05:36 $
+ * @version $Revision: 1.2 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="filtered-path"
* @ant:type type="v-path" name="filtered-path"
1.3 +0 -2
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/SingletonFileList.java
Index: SingletonFileList.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/SingletonFileList.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SingletonFileList.java 27 Feb 2002 12:05:36 -0000 1.2
+++ SingletonFileList.java 28 Feb 2002 04:49:32 -0000 1.3
@@ -16,8 +16,6 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
*
- * @ant:data-type name="v-file"
- * @ant:type type="v-path" name="v-file"
*/
public class SingletonFileList
implements FileList
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/AbstractNameFileSelector.java
Index: AbstractNameFileSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import org.apache.aut.vfs.FileObject;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.oro.text.GlobCompiler;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.antlib.vfile.FileSelector;
/**
* An abstract file selector that selects files based on name.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*/
public abstract class AbstractNameFileSelector
implements FileSelector
{
private final static Resources REZ
= ResourceManager.getPackageResources( AbstractNameFileSelector.class
);
private Object m_type;
private String m_pattern;
private static final Object TYPE_GLOB = "glob";
private static final Object TYPE_REGEXP = "regexp";
/**
* Sets the GLOB pattern to match the name against.
*/
public void setPattern( final String pattern )
throws TaskException
{
setPattern( TYPE_GLOB, pattern );
}
/**
* Sets the Regexp pattern to match the file basename against.
*/
public void setRegexp( final String pattern )
throws TaskException
{
setPattern( TYPE_REGEXP, pattern );
}
/**
* Sets the pattern and type to match
*/
private void setPattern( final Object type, final String pattern )
throws TaskException
{
if( m_type != null )
{
final String message = REZ.getString(
"nameselector.too-many-patterns.error" );
throw new TaskException( message );
}
m_type = type;
m_pattern = pattern;
}
/**
* Accepts the file.
*/
public boolean accept( final FileObject file,
final String path,
final TaskContext context )
throws TaskException
{
if( m_type == null )
{
final String message = REZ.getString(
"nameselector.no-pattern.error" );
throw new TaskException( message );
}
// Create the pattern to match against
final Pattern pattern;
try
{
if( m_type == TYPE_GLOB )
{
pattern = createGlobPattern( m_pattern );
}
else
{
pattern = createRegexpPattern( m_pattern );
}
}
catch( MalformedPatternException e )
{
final String message = REZ.getString(
"nameselector.bad-pattern.error", m_pattern );
throw new TaskException( message );
}
// Get the name to match against
final String name = getNameForMatch( path, file );
// Compare the name against the pattern
return new Perl5Matcher().matches( name, pattern );
}
/**
* Creates a GLOB pattern for matching the name against.
*/
protected Pattern createGlobPattern( final String pattern )
throws MalformedPatternException
{
// TODO - need to implement Ant-style patterns
return new GlobCompiler().compile( pattern );
}
/**
* Creates a Regexp pattern for matching the name against.
*/
protected Pattern createRegexpPattern( final String pattern )
throws MalformedPatternException
{
return new Perl5Compiler().compile( pattern );
}
/**
* Returns the name to match against.
*/
protected abstract String getNameForMatch( final String path,
final FileObject file );
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/AndFileSelector.java
Index: AndFileSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import java.util.ArrayList;
import org.apache.aut.vfs.FileObject;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.antlib.vfile.FileSelector;
/**
* A file selector that performs an AND of nested selectors. Performs
* lazy evaluation. Returns true when no nested elements are supplied.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="and-selector"
* @ant:type type="v-file-selector" name="and"
*/
public class AndFileSelector
implements FileSelector
{
private final ArrayList m_selectors = new ArrayList();
/**
* Adds a nested selector.
*/
public void add( final FileSelector selector )
{
m_selectors.add( selector );
}
/**
* Accepts a file.
*/
public boolean accept( final FileObject file,
final String path,
final TaskContext context )
throws TaskException
{
for( int i = 0; i < m_selectors.size(); i++ )
{
final FileSelector fileSelector = (FileSelector)m_selectors.get(i
);
if( ! fileSelector.accept( file, path, context ) )
{
return false;
}
}
return true;
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/BaseNameFileSelector.java
Index: BaseNameFileSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import org.apache.aut.vfs.FileObject;
import org.apache.antlib.vfile.selectors.AbstractNameFileSelector;
/**
* A file selector that selects files based on their base-name.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="basename-selector"
* @ant:type type="v-file-selector" name="basename"
*/
public class BaseNameFileSelector
extends AbstractNameFileSelector
{
/**
* Returns the name to match against.
*/
protected String getNameForMatch( final String path,
final FileObject file )
{
return file.getName().getBaseName();
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/ExistenceFileSelector.java
Index: ExistenceFileSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import org.apache.aut.vfs.FileObject;
import org.apache.aut.vfs.FileSystemException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.antlib.vfile.FileSelector;
/**
* A file selector that only selects files that exist.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="exists-selector"
* @ant:type type="v-file-selector" name="exists"
*/
public class ExistenceFileSelector
implements FileSelector
{
/**
* Accepts a file.
*/
public boolean accept( final FileObject file,
final String path,
final TaskContext context )
throws TaskException
{
try
{
return file.exists();
}
catch( FileSystemException e )
{
throw new TaskException( e.getMessage(), e );
}
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsEmptyFolderSelector.java
Index: IsEmptyFolderSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import org.apache.antlib.vfile.FileSelector;
import org.apache.aut.vfs.FileObject;
import org.apache.aut.vfs.FileType;
import org.apache.aut.vfs.FileSystemException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
/**
* A file selector that selects empty directories.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="is-empty-folder-selector"
* @ant:type type="v-file-selector" name="is-empty"
*/
public class IsEmptyFolderSelector
implements FileSelector
{
/**
* Accepts a file.
*/
public boolean accept( final FileObject file,
final String path,
final TaskContext context )
throws TaskException
{
try
{
return ( file.exists()
&& file.getType() == FileType.FOLDER
&& file.getChildren().length == 0 );
}
catch( FileSystemException e )
{
throw new TaskException( e.getMessage(), e );
}
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsFileSelector.java
Index: IsFileSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import org.apache.aut.vfs.FileObject;
import org.apache.aut.vfs.FileSystemException;
import org.apache.aut.vfs.FileType;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.antlib.vfile.FileSelector;
/**
* A file selector which only selects files, not folders.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="is-file-selector"
* @ant:type type="v-file-selector" name="is-file"
*/
public class IsFileSelector
implements FileSelector
{
/**
* Accepts a file.
*/
public boolean accept( final FileObject file,
final String path,
final TaskContext context )
throws TaskException
{
try
{
return ( file.exists() && file.getType() == FileType.FILE );
}
catch( FileSystemException e )
{
throw new TaskException( e.getMessage(), e );
}
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/IsFolderSelector.java
Index: IsFolderSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import org.apache.aut.vfs.FileObject;
import org.apache.aut.vfs.FileSystemException;
import org.apache.aut.vfs.FileType;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.antlib.vfile.FileSelector;
/**
* A file selector which only selects folders, not files.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="is-folder-selector"
* @ant:type type="v-file-selector" name="is-folder"
*/
public class IsFolderSelector
implements FileSelector
{
/**
* Accepts a file.
*/
public boolean accept( final FileObject file,
final String path,
final TaskContext context )
throws TaskException
{
try
{
return ( file.exists() && file.getType() == FileType.FOLDER );
}
catch( FileSystemException e )
{
throw new TaskException( e.getMessage(), e );
}
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/NameFileSelector.java
Index: NameFileSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import org.apache.aut.vfs.FileObject;
import org.apache.antlib.vfile.selectors.AbstractNameFileSelector;
/**
* A file selector that selects files based on their name.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="name-selector"
* @ant:type type="v-file-selector" name="name"
*/
public class NameFileSelector
extends AbstractNameFileSelector
{
/**
* Returns the name to match against.
*/
protected String getNameForMatch( final String path,
final FileObject file )
{
return path;
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/NotFileSelector.java
Index: NotFileSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import org.apache.aut.vfs.FileObject;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.antlib.vfile.FileSelector;
/**
* A file selector that negates a nested file selector.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="not-selector"
* @ant:type type="v-file-selector" name="not"
*/
public class NotFileSelector
implements FileSelector
{
private FileSelector m_selector;
/**
* Sets the nested selector.
*/
public void set( final FileSelector selector )
{
m_selector = selector;
}
/**
* Accepts a file.
*/
public boolean accept( final FileObject file,
final String path,
final TaskContext context )
throws TaskException
{
if( m_selector == null )
{
throw new TaskException( "notfileselector.no-selector.error" );
}
return ! m_selector.accept( file, path, context );
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/OrFileSelector.java
Index: OrFileSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import java.util.ArrayList;
import org.apache.aut.vfs.FileObject;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.antlib.vfile.FileSelector;
/**
* A file selector that performs an OR of nested selectors. Performs
* lazy evaluation. Returns true when no nested elements are supplied.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="or-selector"
* @ant:type type="v-file-selector" name="or"
*/
public class OrFileSelector
implements FileSelector
{
private final ArrayList m_selectors = new ArrayList();
/**
* Adds a nested selector.
*/
public void add( final FileSelector selector )
{
m_selectors.add( selector );
}
/**
* Accepts a file.
*/
public boolean accept( final FileObject file,
final String path,
final TaskContext context )
throws TaskException
{
for( int i = 0; i < m_selectors.size(); i++ )
{
final FileSelector fileSelector = (FileSelector)m_selectors.get(i
);
if( fileSelector.accept( file, path, context ) )
{
return true;
}
}
// Return true if there are no selectors, false if there are
return (m_selectors.size() == 0);
}
}
1.1
jakarta-ant/proposal/myrmidon/src/java/org/apache/antlib/vfile/selectors/UrlFileSelector.java
Index: UrlFileSelector.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.antlib.vfile.selectors;
import org.apache.aut.vfs.FileObject;
import org.apache.antlib.vfile.selectors.AbstractNameFileSelector;
/**
* A file selector that selects files based on their URL.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Adam Murdoch</a>
* @version $Revision: 1.1 $ $Date: 2002/02/28 04:49:32 $
*
* @ant:data-type name="url-selector"
* @ant:type type="v-file-selector" name="url"
*/
public class UrlFileSelector
extends AbstractNameFileSelector
{
/**
* Returns the name to match against.
*/
protected String getNameForMatch( final String path,
final FileObject file )
{
return file.getName().getURI();
}
}
1.2 +210 -0 jakarta-ant/proposal/myrmidon/src/xdocs/user.xml
Index: user.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/xdocs/user.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- user.xml 27 Feb 2002 01:24:12 -0000 1.1
+++ user.xml 28 Feb 2002 04:49:32 -0000 1.2
@@ -24,6 +24,23 @@
installation of Myrmidon.
</p>
+<p>There are a number features that are not built unless the appropriate
optional Jar
+files are found in the <code>lib</code> directory:</p>
+
+<table>
+ <tr><th>Feature</th><th>Jar File</th><th>Download From</th></tr>
+ <tr>
+ <td>SMB VFS support (Samba, Windows shares)</td>
+ <td>jcifs.jar</td>
+ <td><a href="http://jcifs.samba.org">jcifs.samba.org</a></td>
+ </tr>
+ <tr>
+ <td>FTP VFS support</td>
+ <td>netcomponents.jar</td>
+ <td><a
href="http://www.savarese.org/oro/software/NetComponents.html">www.savarese.org</a></td>
+ </tr>
+</table>
+
</section>
<section name="Running Myrmidon">
@@ -291,6 +308,199 @@
</section>
+<section name="Handling Files">
+
+<p>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:</p>
+
+<table>
+ <tr><th>File System</th><th>Description</th><th>URL Format</th></tr>
+ <tr>
+ <td>Local Files</td>
+ <td>Files on the local file system.</td>
+ <td>Three different formats are currently supported for local file
names:
+ <ul>
+ <li><code>file://</code> <i>absolute-file-name</i></li>
+ <li>Absolute file names</li>
+ <li>Relative file names. These are resolved relative to the
+ project's base directory.
+ </li>
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td>Zip Files</td>
+ <td>The contents of Zip files (and Jar, War, and Ear files).
+ Currently, the VFS supports read-only access to Zip file contents,
+ and only for local Zip files.</td>
+ <td><code>zip://</code> <i>zip-file-path</i>
[<code>!</code><i>absolute-path</i>]</td>
+ </tr>
+ <tr>
+ <td>FTP</td>
+ <td>Files on an FTP server.</td>
+ <td><code>ftp://</code> [[<i>password</i><code>:</code>]
<i>username</i><code>@</code>] <i>hostname</i> [<code>:</code><i>port</i>]
[<i>absolute-path</i>]</td>
+ </tr>
+ <tr>
+ <td>SMB</td>
+ <td>Files on a CFIS server, such as Samba or Windows shares.</td>
+ <td><code>smb://</code> [[<i>password</i><code>:</code>]
<i>username</i><code>@</code>] <i>hostname</i> [<code>:</code><i>port</i>]
[<i>absolute-path</i>]</td>
+ </tr>
+</table>
+
+<p>Here are some example URLs:</p>
+
+<ul>
+ <li><code>build/classes</code></li>
+ <li><code>c:\program files\ant\bin</code></li>
+ <li><code>file://C:/program files/ant</code></li>
+ <li><code>zip://build/lib/ant.jar!/org/apache/tools</code></li>
+ <li><code>ftp://[EMAIL PROTECTED]/pub/downloads</code></li>
+ <li><code>smb://password:[EMAIL PROTECTED]/home/adam</code></li>
+</ul>
+
+<p>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.</p>
+
+<subsection name="File Sets">
+
+<p>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 <a href="#Paths">path</a>, and so
+can be used anywhere that a path can.</p>
+
+<h3><code><v-fileset></code></h3>
+
+<p>This is the equivalent of Ant 1's <code><fileset></code> (The name
+is temporary, it will be changed to <code><fileset></code> once more
+porting work as been completed).</p>
+
+<p>Rather than use a set of include and exclude patterns to choose the files
+that make up the file set, <code><v-fileset></code> takes zero or more
+<a href="#File Selectors">file selectors</a>. File selectors can be used to
+select files based on any attribute of the file, rather than just the name.
+You can use <code><name></code> selectors to achieve the same result
+as using includes or excludes.</p>
+
+<p>A <code><v-fileset></code> element takes the following
attributes:</p>
+
+<table>
+ <tr><th>Attribute</th><th>Description</th><th>Default Value</th></tr>
+ <tr>
+ <td>dir</td>
+ <td>The base directory for the file set. This can be any URL that
the
+ VFS supports.</td>
+ <td>Required</td>
+ </tr>
+</table>
+
+<p>A <code><v-fileset></code> element takes any number of nested
+<a href="#File Selectors">file selector</a> 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.</p>
+
+<p>An example:</p>
+
+<source><![CDATA[
+
+<v-fileset dir="src">
+ <name pattern="org/apache/tools/ant/**"/>
+ <is-file/>
+</v-fileset>
+]]></source>
+
+<h3><code><flat-fileset></code></h3>
+
+<p>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 <code>flatten</code>
+attribute for the copy and move tasks.</p>
+
+<p>A <code><flat-fileset></code> element takes no attributes, and a set
+of nested paths or file sets.</p>
+
+<p>An example:</p>
+
+<source><![CDATA[
+
+<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>
+]]></source>
+
+</subsection>
+
+<subsection name="Paths">
+
+<p>Paths are an ordered list of files.</p>
+
+<h3><code><v-path></code></h3>
+
+<p>This is the equivalent of Ant 1's <code><path></code>.</p>
+
+<h3><code><filtered-path></code></h3>
+
+<p>A path that applies file selectors to a set of nested file sets and
paths.</p>
+
+</subsection>
+
+<subsection name="File Selectors">
+
+<p>File selectors are used to select files from file sets and paths.</p>
+
+<h3><code><and></code></h3>
+
+<p>Combines zero or more file selectors, using AND. An empty
<code><and></code>
+selector accepts all files.</p>
+
+<h3><code><basename></code></h3>
+
+<p>Selects files whose base name matches an Ant 1 style pattern, or a regular
+expression.</p>
+
+<h3><code><exists></code></h3>
+
+<p>Selects files that exist.</p>
+
+<h3><code><is-empty></code></h3>
+
+<p>Selects empty folders, that is, folders that have no children.</p>
+
+<h3><code><is-folder></code></h3>
+
+<p>Selects folders, does not select regular files.</p>
+
+<h3><code><is-file></code></h3>
+
+<p>Selects regular files, does not select folders.</p>
+
+<h3><code><name></code></h3>
+
+<p>Selects files whose path in a file set matches an Ant 1 style pattern, or
+a regular expression.</p>
+
+<h3><code><not></code></h3>
+
+<p>Selects files that are not selected by a nested file selector.</p>
+
+<h3><code><or></code></h3>
+
+<p>Combines zero or more file selectors, using OR. An empty
<code><or></code>
+selector accepts all files.</p>
+
+<h3><code><url></code></h3>
+
+<p>Selects files whose URL matches an Ant 1 style pattern, or a regular
expression.</p>
+
+</subsection>
+
+</section>
<section name="Tasks">
<p>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>