You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Graham Lea <gr...@alumni.uts.edu.au> on 2005/04/09 00:39:27 UTC
How to Write A Custom Path / Fileset
I want to write a custom Fileset type that reads input from a file.
I don't want to support any nested elements, I just want to be able to
do something like this:
<libraryset id="myLibraries" file="libraries.txt"/>
and have a custom class create a fileset based on the content of
libraries.txt.
So, I have two questions:
1. Is it possible for me to do this (i.e. define a new DataType and use
it in a build file)?
[Or do I have to write a custom Task that creates the fileset?]
2. If the answer to 1. is 'Yes', where/what should I be extending?
[Or, if the answer is 'No', what sort of FileSet should my task be
creating?]
org.apache.tools.ant.ProjectComponent?
org.apache.tools.ant.types.DataType?
org.apache.tools.ant.types.AbstractFileSet?
org.apache.tools.ant.types.FileSet?
Thanks very much,
Graham.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to Write A Custom Path / Fileset
Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello Graham,
> I want to write a custom Fileset type that reads input from a file.
> I don't want to support any nested elements, I just want to be able to
> do something like this:
>
> <libraryset id="myLibraries" file="libraries.txt"/>
>
> and have a custom class create a fileset based on the content of
> libraries.txt.
>
> So, I have two questions:
>
> 1. Is it possible for me to do this (i.e. define a new DataType and use
> it in a build file)?
> [Or do I have to write a custom Task that creates the fileset?]
>
It is perfectly possible to create a new datatype.
To make your datatype known to ant, you need to use the
<typedef/> task (see the manual).
> 2. If the answer to 1. is 'Yes', where/what should I be extending?
> [Or, if the answer is 'No', what sort of FileSet should my task be
> creating?]
> org.apache.tools.ant.ProjectComponent?
> org.apache.tools.ant.types.DataType?
> org.apache.tools.ant.types.AbstractFileSet?
> org.apache.tools.ant.types.FileSet?
>
I am not too sure. I would extend DataType or AbstractFileSet.
Probably rather DataType, since I understand your library set is something
quite specific.
Note that you might also have to create a special "Scanner" class (like
DirectoryScanner) to make the list of the files/dirs included in your
libraryset.
Antoine
> Thanks very much,
>
> Graham.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org