tags:

views:

44

answers:

1

I have a directory structure like this

client/lib
a.jar
b-4.3.jar
c-1.2.jar
d-4.3.jar
e.jar

I need to copy some jars without version and some with version. The only information that i have is version number, and that is stored in a variable.

Problem is version number that i have in variable is 4.3.1 and version that jars have is just first two digits from the variable value (i.e. 4.3 in my case). I need all the jars that has starting two digits that my variable has and some of the jars without version. For e.g. from above directory structure i need:

b-4.3.jar
d-4.3.jar
e.jar

Can somebody please help?

A: 

You might consider using the antcontrib propertyregex task. Perhaps something like this:

<property name="version" value="4.3.1" />
<propertyregex override="yes" property="version2" input="${version}"
               regexp="(.*).([^.]+)"
               replace="\1" />

<fileset id="my_jars" dir="client/lib">
    <include name="*${version2}.jar" />
    <include name="e.jar" />
</fileset>

<copy todir="to_dir">
    <fileset refid="my_jars" />
</copy>
martin clayton