ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Rosenberg" ...@tabbysplace.org>
Subject RE: Set property using part of a filename
Date Thu, 12 Aug 2010 22:00:25 GMT
I would use the <propertyregex/> task from ant-contrib:

--
Jonathan Rosenberg
Founder & Executive Director, Tabby's Place
http://www.tabbysplace.org/



-----Original Message-----
From: Bailey, Darragh [mailto:dbailey@hp.com] 
Sent: Thursday, August 12, 2010 2:32 PM
To: Ant Users List
Subject: Set property using part of a filename



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@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message