从xml读取的绝对路径的ant复制
我的问题是,我必须从xml文件读取复制作业的源路径,然后将该目录中的所有文件从xml文件复制到另一个目录 因为代码不仅仅是文字:从xml读取的绝对路径的ant复制,ant,Ant,我的问题是,我必须从xml文件读取复制作业的源路径,然后将该目录中的所有文件从xml文件复制到另一个目录 因为代码不仅仅是文字: <xmltask source="${projectfile}"> <copy path="Project/RecentResultsInfo/ResultsDirectoryOfRecentLoadTest/text()" property="recentdir" attrValue="true"/> </xmltask> &
<xmltask source="${projectfile}">
<copy path="Project/RecentResultsInfo/ResultsDirectoryOfRecentLoadTest/text()" property="recentdir" attrValue="true"/>
</xmltask>
<copy todir="${targetdirectory}">
<fileset dir="${recentdir}"/>
</copy>
运行此目标时的输出为:
C:\develope\build.xml:44:警告:找不到要复制的资源文件“C:\develope\C:\program\tool\test\u 90\”
在文件集中,它似乎无法识别,recentdir
在其中保存了完整的路径。从应用程序写入的xml在xml文件中的路径前后都有一个换行符,该路径随路径一起读取。所以蚂蚁无法识别路径,因为前面有一条新线
蚂蚁有类似修剪的东西吗
有人能帮我让ant接受这个路径吗?现在使用ant Contrib完成了,但是这个项目中还是使用了它
<xmltask source="${projectfile}">
<copy path="Project/RecentResultsInfo/ResultsDirectoryOfRecentLoadTest/text()" property="recentdirraw" attrValue="true"/>
</xmltask>
<!-- replace newlines and whitespace from read path -->
<propertyregex property="recentdir" input="${recentdirraw}" regexp="^[ \t\n]+|[ \t\n]+$" replace="" casesensitive="false" />
<copy todir="${targetdirectory}">
<fileset dir="${recentdir}"/>
</copy>
只需使用正则表达式修改属性,通过分隔空白和换行来修剪文本。就我所见,中的copy元素提供了trim属性
trims leading/trailing spaces when writing to properties
这样行吗