tags:

views:

39

answers:

2

I am using Ant to build a fileset. I only want to include files in the file set that have been modified after a specific date. (See below)

Ideally I would like the below datetime value to be some sort of property that is equal to the create date of the build file. E.g. I only want files included in the fileset that where modified after the build file was created I cant use a static string because this build file will be checked out from subversion by multiple developers.

<fileset dir="some-files">
    <date datetime="07/12/2010 12:00 AM" when="after"/>
</fileset>
+1  A: 

You could use the Date svn keyword in one of your property files, so your property would look like:

file.mod.date=$LastChangedDate$

once you have set the svn:keywords property on your property file (see the svn propset command), commited your changes checking out the property file will result in your property looking something like:

file.mod.date=$LastChangedDate: 2006-07-22 21:42:37 -0700 (Sat, 22 Jul 2006) $

Now you have an ant property with a date inside of it, there are a couple of ways to substring the property so you can use the raw date.

krock
I wonder if I could use this technique to add the date directly into the build file?
tinny
@tinny, there is nothing stopping you from doing that `<property name="file.mod.date" value="$LastChangedDate$">`. Just make sure to add the appropriate `svn propset` on the file you want svn keyword replacement on.
krock
+1  A: 

Sorry, I can't test this at the moment, but it seems like you could do something like:

<fileset dir="${some-dir}">
    <depend targetdir="${basedir}">
        <mergemapper to="${ant.file}"/>
    </depend>
</fileset>

Without testing, I'm not sure what the exact interaction is between depend and mergemapper, but hopefully you get the idea...

kschneid
Just noticed that the original question stated: "...only want files included in the fileset that where modified after the build file was created..." The `depend` selector uses modification time, not creation time.
kschneid