ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject ProjectHelper (was Re: EasyAnt project)
Date Wed, 29 Oct 2008 16:56:04 GMT
hijacking a thread.

On Wed, 29 Oct 2008, Matt Benson <gudnabrsam@yahoo.com> wrote:

> I see; however let me ask you this: which is more straightforward,
> creating a custom ProjectHelper or extending Project and/or Target?
> I guess the answer depends on how comfortable you are with the SAX
> APIs.

Who said I was using SAX?  I'm not even using XML.  The main reason to
write it is to show that Ant doesn't need XML at all.

My "build file" is going to look like this (I'm making up half of it):

@Project(Name="example", DefaultTarget="echo")
public class BuildFile extends JavaFrontBuildFile {
    public BuildFile(Project p) {
        super(p);
    }

    @Target
    public void echo() {
        getProject().log("Hello world");
    }

    @Target(Name="-setproperty")
    public void setProperty() {
        taskBuilder().newProperty().withName("world").andValue("world")
          .execute();
    }

    @Target(Depends="-setproperty")
    public void moreComplexExample() {
        taskBuilder().newEcho().withMessage("Hello ${world}").execute();
    }
}

My Target class extends Target and gets a Runnable in its constructor
which is then run in execute() (it completely ignores nested tasks).

Stefan

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


Mime
View raw message