I want to extract the version number from a file name generated outside of my Ant script.
An external build tool (PDE build) creates a file of the form artifactid-1.2.3.201101010101.jar
in a well-known directory, but I can not tell the versioning information beforehand. I need to extract the version part (1.2.3.201101010101
) from that file name into an Ant property for further processing, e.g. variable substitution.
Using ant-contrib is acceptable, however I have not found a way to extract this information.
Here's a solution using the ant-contrib PropertyRegex task.
You could avoid ant-contrib by writing the property value to a temporary file and then using loadfile with a filterchain to extract the artifact id from it. See this answer for an example.
Output
A straight solution with Ant addon Flaka :
output