Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Developers List »

ProjectHelper (was Re: EasyAnt project)

Stefan Bodewig

2008-10-29

Replies: Find Java Web Hosting

Author LoginPost Reply
hijacking a thread.

On Wed, 29 Oct 2008, Matt Benson <gudnabrsam@(protected):

> 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@(protected)
For additional commands, e-mail: dev-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.