开发者

How can I match partial version strings when using the Ant 'copy' task?

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 the jars - some without version, and some with. The only information that I have is version number, and that is stored in a variable.

The version number I have is in a property, and has three fields - '4.3.1' The version that the jars have is just the first two fields from the property value (i.e. 4.3 in this case). I need all jars that starting with two digits that my property has, and some of the jars without version. For example, from above directory structure I need:开发者_StackOverflow中文版

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

How can I do that?


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜