You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Anderson, Rob (Global Trade)" <Ro...@nike.com> on 2006/03/23 19:02:48 UTC

Get the modification time of a file into a property.

I have a custom Ant task that I am using to extract documents from a
document management system based on modification time. I plan to touch a
file (lastrun.txt) at the end of the process to capture the time that
the process ran, then during the next run somehow get the modification
time of that file into a property for use in my custom task. Here is the
sequence...
 
1. If lastrun.txt exists, get the modification time into a property.
2. Extract the documents based on the property if it exists. If property
does not exist, just get everything.
3. Touch the file lastrun.txt
 
I don't know how to accomplish step 1. I could write a wrapper script to
get the value and pass it into Ant, but I would prefer to do this within
Ant.
 
Thanks in advance.
 
 

______________________
Robert Anderson
Sr. System Engineer
Nike - Global Trade IT
503-532-6803

Never let me slip, cuz if I slip, then I'm slippin. - Dr. Dre

 

Re: Get the modification time of a file into a property.

Posted by Dale Anson <da...@grafidog.com>.
If you're not opposed to more custom tasks, there is a FileUtil task in 
Antelope (antelope.tigris.org) that will get the last modified time.

Dale


On Thu, 23 Mar 2006, Anderson, Rob (Global Trade) wrote:

> I have a custom Ant task that I am using to extract documents from a
> document management system based on modification time. I plan to touch a
> file (lastrun.txt) at the end of the process to capture the time that
> the process ran, then during the next run somehow get the modification
> time of that file into a property for use in my custom task. Here is the
> sequence...
>
> 1. If lastrun.txt exists, get the modification time into a property.
> 2. Extract the documents based on the property if it exists. If property
> does not exist, just get everything.
> 3. Touch the file lastrun.txt
>
> I don't know how to accomplish step 1. I could write a wrapper script to
> get the value and pass it into Ant, but I would prefer to do this within
> Ant.
>
> Thanks in advance.
>
>
>
> ______________________
> Robert Anderson
> Sr. System Engineer
> Nike - Global Trade IT
> 503-532-6803
>
> Never let me slip, cuz if I slip, then I'm slippin. - Dr. Dre
>
>
>

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


Re: Get the modification time of a file into a property.

Posted by Dominique Devienne <dd...@gmail.com>.
> 1. If lastrun.txt exists, get the modification time into a property.
> 2. Extract the documents based on the property if it exists. If property
> does not exist, just get everything.
> 3. Touch the file lastrun.txt
>
> I don't know how to accomplish step 1. I could write a wrapper script to
> get the value and pass it into Ant, but I would prefer to do this within
> Ant.

In your shoes, I'd write a little <script>, and access directly
java.io.File#lastModified. All you need is a script engine, like
rhino.jar, in ANT_HOME/lib or in CLASSPATH. See at the dependencies
section of the manual for the <script> task. --DD

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