ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Jennings <>
Subject Re: new Task subclass
Date Tue, 20 Jul 2004 14:35:43 GMT
Thanks for the feedback!

I was thinking more along the lines of:

public abstract class IfUnlessTask extends Task {
  protected String ifCondition,unlessCondition;
  public void setIf(String ifc) ...
  public void setUnless(String unc) ...
  protected boolean conditionsAreValid()...

  public void execute() throws BuildException {
    if (conditionsAreValid()) {

 protected abstract void doExecute() throws BuildException;

So that subtasks only need to implement the doExecute() function. I was
thinking that
this subclass would make it easy to add if="" and unless="" attributes to
any task which
IMHO would be quite useful. For example, if I wanted to conditionally <echo>
to the console, I would have to make a separate target with a if=""
parameter and the <echo>
task embedded within that target.

I guess my question should have been "should more tasks have 'if' and
'unless' parameters?"

----- Original Message ----- 
From: <>
To: <>
Sent: Monday, July 19, 2004 10:49 PM
Subject: AW: new Task subclass

IMHO it doesnt make sense:
1. We have no real consense how we want handle conditional tasks
   - for all tasks / only for a few
   - via if/unless or via nested <condition>s or something new?
2. Havent count them but I think there arent so many tasks that we
   should introduce another hierarchy step. Especially an if/unless
   doesnt really do much complicated. Maybe a helper class could be
   useful - something like
       public class IfUnlessHelper {
           String if;     // getter, setter
           String unless; // getter, setter
           public boolean isValid() {
               // code from such a ProjectComponent, e.g. <target>
   Used inside the ProjectComponents like
       public class Target {
           IfUnlessHelper iuh = new...
           public void setIf(String s) { iuf.setIf(s); }
           public void setUnless ...
           public void execute() {
               if (!iuh.isValid) { return; }


> -----Urspr√ľngliche Nachricht-----
> Von: Mike Jennings []
> Gesendet am: Montag, 19. Juli 2004 15:30
> An:
> Betreff: new Task subclass
> Hi,
> I was thinking that all of the core tasks that have if= and
> unless= attributes
> could have a common ancestor which would be a subclass of
> Is there an obvious reason to not do this? If this makes
> sense I can code it up
> and submit it.
> -Mike
> ________________________
> Mike Jennings
> Southgate Software Ltd
> (250) 382-6851 tel
> (250) 818-5230 cel
> (250) 592-6851 fax

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message