ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Castrianni <>
Subject RE: Checking whether a file is executable
Date Sat, 24 Oct 2009 18:24:09 GMT
Here is example source code for a condition:



public class FileAgeCondition implements Condition {
  protected String _file = null;
  protected float _age = -999.25F;  //In seconds
  protected boolean _olderThan = true;

  public boolean eval() throws BuildException
    if((_file == null) || (_file.length() == 0))
      throw new BuildException("file must be set");
    if(_age == -999.25F)
      throw new BuildException("age must be set");
    File file = new File(_file);
    long now = System.currentTimeMillis();
    long fileAge = file.lastModified();
    float testAge = _age * 1000.0F;
    boolean retVal;
      retVal = (now - fileAge) > testAge;
      retVal = (now - fileAge) < testAge;

  public void setFile(String file)
    _file = file;

  public void setAge(float age)
    _age = age;

Shawn Castrianni

-----Original Message-----
From: Francis GALIEGUE [] 
Sent: Friday, October 23, 2009 4:54 PM
To: Ant Users List
Subject: Re: Checking whether a file is executable

On Fri, Oct 23, 2009 at 23:50, Shawn Castrianni
<> wrote:
> I run ANT with 1.6 all the time.  Therefore, you could always write your own condition
or task with ANT API just as long as you run your ANT builds with 1.6.

Which kind of leads back to my original question somewhat, even if
this was far from being obvious in my first mail... By "Where should I
start to look if I want to create, say, a
<isexecutabe> condition", I meant where in the code should I start to
look. I have thrown an eye to the source, but without success so far.
Pointers appreciated ;)


Francis Galiegue
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
40 avenue Raymond Poincaré
75116 Paris

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

This e-mail, including any attached files, may contain confidential and privileged information
for the sole use of the intended recipient.  Any review, use, distribution, or disclosure
by others is strictly prohibited.  If you are not the intended recipient (or authorized to
receive information for the intended recipient), please contact the sender by reply e-mail
and delete all copies of this message.
View raw message