0
votes

So I have a bunch of Jars in a directory that look like this:


library_2.4.3.jar   2/3/2012
library_3.0.1.jar   9/1/2012
api.lib_10.3.jar    3/2/2011
api.lib_12.4.5.jar  6/9/2012
    

I have already written the following using Ant 1.7 to copy the jars to where I want them and strip away the version number from the file

<copy todir="${lib.dir}" overwrite="true">
    <fileset dir="${plugins.dir}">              
        <include name="library*.jar" />
        <include name="api.lib*.jar" />
    </fileset>
    <regexpmapper from="(.*)_(.*).jar" to="\1.jar"/>
</copy>

The problem I'm running into is that I want it to copy the newer version of the file. Right now it seems to be copying only the older files. I have looked into the <sort> and <TimestampSelector> tasks but those are not supported under the copy task.

What can I do to copy the newer versions of the file?

1
I tried that but I get a copy doesn't support the nested "last" element errorSpacebob
What version of ant are you using?Vishal
it is working for me on Ant 1.8..Vishal

1 Answers

0
votes

Do not put them under the copy task directly... Create the property and use the property in the copy tag...

<timestampselector property="latest.modified">
  <path>
    <fileset dir="${my-directory.dir}">
      <include name="file-*" />
    </fileset>
  </path>
</timestampselector>

<copy todir="." file="${latest.modified}">

Hope, it works.