ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: Custom Path/FileSet types
Date Tue, 03 Jun 2003 15:24:59 GMT
I'll attempt to answer some of these.

First there is a big difference beween path and fileset.
Path is a lot nicer to use, and can hold more
files but fileset is used by more
tasks that path.

Second, do not do things in the constructor - an empty
constructor is best. Use set/add methods to set/add things.


On Tuesday 03 June 2003 15:25, Adam Jack wrote:
> I have a custom task that is currently implemented to generate
> named/referencable Path & FileSet elements as it's output. The "user" of
> the task is expected to know the refid's of the constructs this task
> creates. This works, but seems a bit tad convoluted. The idea has arisen to
> re-work this task as Path and/or FileSets.
>
> [Basically the task (or soon to be type) takes a "project name" as input,
> and downloads/returns the latest list of JARs for that project. The user
> might wish to compile against those JARs, or copy them to a distribution,
> or ...]
>
> Looking at the ant source code FileSet (with AbstractFileSet) seems quite
> doable [clearly it is already subclassed], and Path.PathElement appear
> either simpler, or figureoutable. That said, I don't know the concepts
> behind "custom types" and http://ant.apache.org/manual/developlist.html
> doesn't seem to have guidance for types.
>
> Some questions:
>
> 1) Does what I am doing make sense as types verses tasks? What are the pros
> and cons of each?

It depends....,  It may be usefull to be both. In your case it looks like
it should be a datatype.

> 2) Can one construct a Path from a FileSet? [Meaning, do I need to write
> code for both, or ought
> I suspect I need a singleton factory to create my types,

one can use addFileSet() to a path.

> 3) I suspect I'll have a singleton factory (of sorts) to create my
> constructs. That entity will probably want some per VM or per project
> configuration (or perhaps not a real singleton). I see I can access the
> project, so  I can access properties, but are there helpers for per project
> instances? Do I need to roll my own?

You should not use a singleton factory. A number of <typedefs/> should
be enough.

> 4) How ought I handle logging? Can types log? Logging seems attached to the
> Task, not ProjectComponent. If not, how might user tasks report debugging
> information for types?

A project componet has a setProject(Project) method that gets called when ant
creates the object. Use project#log() for logging.

> 5) If I create a custom FileSet (say) can I add it to anything that takes a
> FileSet (because I am a sub-class) or does the "container" need to
> understand the XML tag? I.e. can I add <mypathelement to <classpath?

There is work ongoing that will allow you to do this. In fact in the current
nightly build there is initial support for adding custom paths to the path.

>
> Some deeper ones (which I might just have to figure out from the code,
> unless somebody is feeling overly generous w/ insight):
>
> 1) How do I figure out what introspection can do for me, in terms of
> constructors? Looking at ZipFileSet I see a bunch of constructors, but I
> don't really know how they map to the XML users can provide.

The introspection does some work on constructors - but it is FAR better
to use the empty constructor.

> 2) How do I get inside FileSet and AbstractFileSet? How can I determine
> what methods I must provide, and what ones I can call? How do I select
> between the two?
> 3) I see a bunch of helper methods that are getX(Project p) where a
> ProjectComponent resolves answers based on itself within a project.
> 4) If I don't want PatternSets, do I need FileList not FileSet? Does this
> limit what users can pass this to? Why do these two exist, what is the
> reason for them not being able to be the same thing?
>
> Thanks in advance for you assistance.
>
> regards,
>
> Adam

Peter.

Mime
View raw message