ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: [PATCH] Use EnumeratedAttribute in <zip whenempty="..."/>
Date Fri, 09 Mar 2001 14:59:39 GMT
Jesse Glick <Jesse.Glick@netbeans.com> wrote:

> Ideally I would like to be able to use a simple interface akin to
> IntrospectionHelper, e.g.:
> 
> public void execute() throws BuildException {
>     IndirectTask t = project.createTaskIndirectly("zip");
>     t.set("whenempty", "ignore");
>     t.set("zipfile", "${foo}/foo.zip");
>     IndirectElement e = t.create("fileset");
>     e.set("dir", "src");
>     // one step to configure it, initialize,
>     // set location & parent, & execute:
>     t.execute(this);
> }
> 
> So that the code only relies on the XML-like structure of the tasks,
> not the Java-level API.

This should already be possible using IntrospectionHelper, something
like

    Task t = project.createTask("zip");
    IntrospectionHelper ih = IntrospectionHelper.getHelper(t.getClass());
    ih.setAttribute(project, t, "whenempty", "ignore");
    ih.setAttribute(project, t, "zipfile",
                    ProjectHelper.replaceProperties(project, 
                                                    "${foo}/foo.zip", 
                                                    project.getProperties());

    Object fileset = ih.createElement(t, "fileset");
    IntrospectionHelper ih2 = IntrospectionHelper.getHelper(fileset.getClass());
    ih2.setAttribute(project, fileset, "dir", "src");
    t.execute();

should work. 

This is just saying, that it is possible right now, not that some
syntactic sugar like IndirectTask or IndirectElement wouldn't be nice.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: ant-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: ant-dev-help@jakarta.apache.org


Mime
View raw message