Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

Set property using part of a filename

Bailey, Darragh

2010-08-12

Replies: Find Java Web Hosting

Author LoginPost Reply


Basically I'm looking to extract the version of a package file from the filename. So far I've come up with the following, but I'm just wondering if this is the best way to accomplish what I want, given that it seems a bit of a kludge to use the pathconvert task to extract a string from filenames and put it in a property.

<pathconvert property="project.version.full" >
<path>
  <fileset dir="${src.dir}" >
   <include name="**/*.rpm" />
   <exclude name="**/*debuginfo*.rpm" />
  </fileset>
</path>
<chainedmapper>
  <flattenmapper/>
  <filtermapper>
   <replaceregex pattern="${ant.project.name}-(.+)\.(.+)\.rpm" replace="\1"/>
  </filtermapper>
</chainedmapper>
</pathconvert>


--
Regards,
Darragh Bailey



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.