ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <ddevie...@gmail.com>
Subject Re: Getting the name of the only file in a directory
Date Thu, 07 Jan 2010 22:40:18 GMT
On Thu, Jan 7, 2010 at 4:02 PM, leroybrownbpj <tjcrouse@gmail.com> wrote:
> I'm working on a project currently where we need to deploy an artifact to a
> server via an ant task which takes the fully qualified file path and name.
> When this script runs the artifact will be in a directory like this:
>
> location/deployable-artifact-1.0.3.9.war
>
> My problem is that in order to keep track of our builds the artifact's name
> will contain the build number (as above) and therefor I won't know before
> deployment time what the file's name will be. The containing directory will
> hold only this file, and be empty otherwise and the filename's prefix
> ("deployable-artifact-" here) will be constant as well so I would not think
> that it would be incredibly difficult to get the name of the file in that
> directory but I'm not sure how to go about this.
>
> Any suggestions are appreciated.

There are likely several ways to do that, a <fileset id="foo"> with
the magic ${toString:foo} conversion, or a <path> with <pathconvert>,
and I'm likely forgetting others. In any case, it relies on a type
that accepts "wildcards", and then converting that type to a string
you put into a <property>. Something that might look like

<fileset id="thefile" dir="location" includes="deployable-artifact-*.war" />
<property name="thefile" value="${toString:thefile}" />

(not tested). --DD

PS: properties and references are in separate "namespaces" so I used
the same name for the id and the property name.

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


Mime
View raw message