Here is example source code for a condition:
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.condition.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);
if(!file.exists())
return(true);
long now = System.currentTimeMillis();
long fileAge = file.lastModified();
float testAge = _age * 1000.0F;
boolean retVal;
if(_olderThan)
retVal = (now - fileAge) > testAge;
else
retVal = (now - fileAge) < testAge;
return(retVal);
}
public void setFile(String file)
{
_file = file;
}
public void setAge(float age)
{
_age = age;
}
}
---
Shawn Castrianni
-----Original Message-----
From: Francis GALIEGUE [mailto:[email protected]]
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
<[email protected]> 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
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
[email protected]
40 avenue Raymond Poincaré
75116 Paris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
----------------------------------------------------------------------
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.