I want to change the base directory of a FileList
when referencing it later in my buildfile.
I define the following FileList
:
<filelist dir="./dev" id="sourceFiles">
<file name="files/file.php" />
<file name="files/class.php" />
<file name="files/functions.php" />
</filelist>
And my targets are the following
<target name="fetch">
<copy todir="./src/files">
<filelist refid="sourceFiles" />
</copy>
</target>
<target name="build" depends="fetch">
<replaceregexp match="(\d+.\d+.\d+)(.\d+)?" replace="\1.${build.number}">
<filelist refid="sourceFiles" />
</replaceregexp>
</target>
So, when using the replaceregexp
task, it will use the files located in ./dev
- but I want the task to replace in the files copied earlier that are now located in ./src
.
Of course, I could copy the file list and use another dir
, but I'd very much like to only hold the list of files once in my buildfile.
How can I achieve this?
I think what you're looking for is a mapper within the copy command as follows:
<project name="demo" default="copy">
<property name="build.number" value="1.0.1"/>
<target name="copy">
<copy todir="build">
<fileset dir="src"/>
<regexpmapper from="^(.*)\.txt$" to="\1.${build.number}"/>
</copy>
</target>
<target name="clean">
<delete dir="build"/>
</target>
</project>
Here's my test files
|-- build
| `-- files
| |-- one
| | |-- file1.1.0.1
| | `-- file2.1.0.1
| `-- two
| `-- file3.1.0.1
|-- build.xml
`-- src
`-- files
|-- one
| |-- file1.txt
| `-- file2.txt
`-- two
`-- file3.txt