You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Christopher BROWN <br...@reflexe.fr> on 2015/05/16 15:38:53 UTC

How should an Ant be created programmatically from another (custom) Ant task?

Hello,

I've developed a few custom Ant tasks over time, but I need a little help
doing something specific to Ant's data types.  I've created a task that
retrieves a set of files from a server, but the names aren't known in
advance, they're determine during execution of the task.  I'd like to
create a fileset that has an ID and can be referred to later on by other
tasks and targets in the build.

This is how I assumed I'd get started:

FileSet fs = new FileSet();
fs.setId("someid");
fs.setProject(_project_);
fs.setDir(_dir_);
fs.createInclude().setName("entry/within/dir1/containing/file.abc");
fs.createInclude().setName("entry/within/dir2/containing/file.xyz");

I've some doubts about the "createInclude" logic... but I haven't got that
far yet.  I'm stuck on the "setId()" part which just doesn't exist.

In a build script, I'd write:

<fileset id="someid" dir="somedir">
  <include name="relative/path/to/file" />
</fileset>

... then refer to it later with "refid".

How can I get this to work?

Thanks,
Christopher

Re: How should an Ant be created programmatically from another (custom) Ant task?

Posted by Christopher BROWN <br...@reflexe.fr>.
Hello Dominique,

Thanks, I gave it a try, and it helped!  Exactly what I was looking for...

--
Christopher



On 16 May 2015 at 16:49, Dominique Devienne <dd...@gmail.com> wrote:

> On Sat, May 16, 2015 at 3:38 PM, Christopher BROWN <br...@reflexe.fr>
> wrote:
>
> > I've some doubts about the "createInclude" logic... but I haven't got
> that
> > far yet.  I'm stuck on the "setId()" part which just doesn't exist.
> >
>
> You probably need to call this Project.addReference API. Give it try, and
> see if that helps. --DD
>
>
> http://api.dpml.net/ant/1.7.0/org/apache/tools/ant/Project.html#addReference(java.lang.String
> ,
> java.lang.Object)
>

Re: How should an Ant be created programmatically from another (custom) Ant task?

Posted by Dominique Devienne <dd...@gmail.com>.
On Sat, May 16, 2015 at 3:38 PM, Christopher BROWN <br...@reflexe.fr> wrote:

> I've some doubts about the "createInclude" logic... but I haven't got that
> far yet.  I'm stuck on the "setId()" part which just doesn't exist.
>

You probably need to call this Project.addReference API. Give it try, and
see if that helps. --DD

http://api.dpml.net/ant/1.7.0/org/apache/tools/ant/Project.html#addReference(java.lang.String,
java.lang.Object)