ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject [HOWTO] from a filename to a <fileset>
Date Mon, 22 Jul 2002 16:25:26 GMT
I wanted to run <antdoc> on the current build file (whose absolute filename
is in ${ant.file}), but <antdoc> doesn't have a 'file' attribute, only a
<fileset> subelement. How not to hardcode the build filename in the task so
the task is re-usable as-is in another build file? Must found a generic way
to convert a filename into a <fileset> that resolve to only that file. In
1.5, is would be trivial to use <dirname> and <basename>, but I need it for
1.4.1 too? Here's a little convoluted way to do that using <pathconvert>,
assuming you know a directory this file belongs to (and hopefully it's not
the root directory):

    <!-- Just so we can specify ${ant.file} as a <fileset> -->
    <pathconvert property="buildfile.pattern"
      <path><pathelement path="${ant.file}" /></path>
      <map from="${basedir}${file.separator}" to="" />
    <echo message="buildfile.pattern = ${buildfile.pattern}" />

    <fileset dir="${basedir}">
      <include name="${buildfile.pattern}" />

If you know of a better way to do this, thanks to let me know. Otherwise,
maybe this will be useful to someone. --DD

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message