用纯ANT根据病情来搜索是否存在文件列表,并采取行动 [英] Use Pure ANT to Search if list of files exists and take action based on condition
问题描述
用户传递的文件的列表中的XML文件,下面将样品
<财产包名称=ABC>
<作用>洁净LT; /作用>
<目标-地点> / VST /属性/ POG /< /目标地点>
<文件名称>&test1.props LT; /文件名称>
<文件名称>&test2.props LT; /文件名称>
<文件名称>&test3.props LT; /文件名称>
< /产权束>
现在根据该动作删除,我必须引入逻辑build.xml中删除该目录中的文件,但我想执行验证只在文件存在然后删除,否则抛出构建失败错误。我能够读取用户输入的XML值,并采取这些文件到文件列表属性
<属性名=的File.ListVALUE =test1.props,test2.props,test3.props/>
<目标名称=干净>
<删除>
<文件集DIR =$ {} target.location包括=$ {}的File.List/>
< /删除>
< /目标与GT;
但用干净的目标,只验证是否存在该目录,因为它是文件集,但如果文件存在没有做验证,我读的文件列表并进行文件验证存在,但文件列表可以删除工作。
由于我们使用ANT 1.6.5在我们的环境,我不能使用antcontrib,这需要大量的全过程,并批准立即升级ANT,能否请您指导我如何将它与纯ANT来实现。
<目标名称=removeUnwantedFiles描述=删除构建目标树,以确保它仅包含什么明确需要构建和仅什么旨在是释放过夜。;
<删除>
<文件集DIR =$ {项目HOME}>
< includesfile NAME =$ {}脚本/excludeJavaFilesForV1.txt/>
< /文件集>
< /删除>
< /目标与GT;
这对我的作品..希望这会有所帮助。
User passes a list of files in an XML file, below will be the sample:
<property-bundle name = "abc">
<action>clean</action>
<target-location>/vst/property/pog/</target-location>
<file-name>test1.props</file-name>
<file-name>test2.props</file-name>
<file-name>test3.props</file-name>
</property-bundle>
Now based on that action remove, I have to incorporate logic in build.xml to delete the files in the directory , but for that I want to perform a validation only if the file exists then remove or else throw the build failure error. I was able to read the values from the user input XML and takes those files into a file list property
<property name="file.list" value="test1.props,test2.props,test3.props"/>
<target name = "clean">
<delete>
<fileset dir="${target.location}" includes = "${file.list}"/>
</delete>
</target>
but with the clean target it only validates if the directory exists since it is fileset but does not do the validation if file exists , I read that filelist does validation for file exists but filelist can work with delete.
since we are using ANT 1.6.5 in our environment I can not use antcontrib , It takes whole lot of process and approvals to upgrade ANT now , Can you please guide me on how it can be achieved with the pure ANT.
<target name="removeUnwantedFiles" description="delete the build destination tree to ensure that it will contain ONLY what is explicitly needed for a build and ONLY what is intended to be release.">
<delete>
<fileset dir="${project-home}">
<includesfile name="${scripts}/excludeJavaFilesForV1.txt"/>
</fileset>
</delete>
</target>
This works for me.. hope this helps..
这篇关于用纯ANT根据病情来搜索是否存在文件列表,并采取行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!