Ant 在引用文件列表时更改其目录
我想在以后的构建文件中引用Ant 在引用文件列表时更改其目录,ant,build,directory,copy,filelist,Ant,Build,Directory,Copy,Filelist,我想在以后的构建文件中引用文件列表时更改其基本目录 我定义了以下文件列表: <filelist dir="./dev" id="sourceFiles"> <file name="files/file.php" /> <file name="files/class.php" /> <file name="files/functions.php" /> </filelist> 我的目标如下 <targe
文件列表时更改其基本目录
我定义了以下文件列表
:
<filelist dir="./dev" id="sourceFiles">
<file name="files/file.php" />
<file name="files/class.php" />
<file name="files/functions.php" />
</filelist>
我的目标如下
<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>
因此,当使用replaceregexp
任务时,它将使用位于/dev
中的文件,但我希望任务替换先前复制的位于/src
中的文件
当然,我可以复制文件列表并使用另一个目录
,但我非常希望在构建文件中只保存一次文件列表
如何实现这一点?我认为您需要的是copy命令中的映射器,如下所示:
<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>
patternset()可以帮助您创建具有不同“顶级目录”的多个文件集。
|-- 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