比较目录时设置ant属性
我有两个目录,我需要比较有相同的文件。我成功地做到了以下几点:比较目录时设置ant属性,ant,Ant,我有两个目录,我需要比较有相同的文件。我成功地做到了以下几点: <fileset dir="d:\test" id="onlyinbar"> <not> <present targetdir="A_DIR"/> </not> </fileset> <echo>these files are only in bar : ${toString:onlyinbar}</echo> <
<fileset dir="d:\test" id="onlyinbar">
<not>
<present targetdir="A_DIR"/>
</not>
</fileset>
<echo>these files are only in bar : ${toString:onlyinbar}</echo>
<fileset dir="A_DIR" id="differentbarfoo">
<different targetdir="d:\test" ignoreFileTimes="true"/>
</fileset>
<echo>these files are different in bar compared to foo : ${toString:differentbarfoo}</echo>
这些文件仅在bar:${toString:onlyinbar}中
与foo:${toString:differentbarfoo}相比,这些文件在bar中是不同的
但是,如果其中任何一个是真的,我需要发出另一个任务。只要
标记似乎只支持文件到文件的比较,我就看不到如何在
标记中分配属性。非常感谢您的帮助。将多个集合中的资源分组到一个集合中
同样,请看一下
和
您提到了“if”,我假设它指的是来自第三方Ant Contrib库的
任务。下面是一个示例,如果由
组合的文件集与任何文件匹配,则会重复此示例:
<if>
<resourcecount when="gt" count="0">
<union id="Check">
<resources refid="onlyinbar"/>
<resources refid="differentbarfoo"/>
</union>
</resourcecount>
<then>
<echo>There are differences: ${toString:Check}</echo>
</then>
</if>
存在差异:${toString:Check}
将多个集合中的资源分组到一个集合中
同样,请看一下
和
您提到了“if”,我假设它指的是来自第三方Ant Contrib库的
任务。下面是一个示例,如果由
组合的文件集与任何文件匹配,则会重复此示例:
<if>
<resourcecount when="gt" count="0">
<union id="Check">
<resources refid="onlyinbar"/>
<resources refid="differentbarfoo"/>
</union>
</resourcecount>
<then>
<echo>There are differences: ${toString:Check}</echo>
</then>
</if>
存在差异:${toString:Check}
将多个集合中的资源分组到一个集合中
同样,请看一下
和
您提到了“if”,我假设它指的是来自第三方Ant Contrib库的
任务。下面是一个示例,如果由
组合的文件集与任何文件匹配,则会重复此示例:
<if>
<resourcecount when="gt" count="0">
<union id="Check">
<resources refid="onlyinbar"/>
<resources refid="differentbarfoo"/>
</union>
</resourcecount>
<then>
<echo>There are differences: ${toString:Check}</echo>
</then>
</if>
存在差异:${toString:Check}
将多个集合中的资源分组到一个集合中
同样,请看一下
和
您提到了“if”,我假设它指的是来自第三方Ant Contrib库的
任务。下面是一个示例,如果由
组合的文件集与任何文件匹配,则会重复此示例:
<if>
<resourcecount when="gt" count="0">
<union id="Check">
<resources refid="onlyinbar"/>
<resources refid="differentbarfoo"/>
</union>
</resourcecount>
<then>
<echo>There are differences: ${toString:Check}</echo>
</then>
</if>
存在差异:${toString:Check}
我们需要避免任何第三方参与此解决方案。我的主要问题是标签的组合。我们知道我们的“测试”,即文件集标记必须处于该状态,但不知道如何进行。resourcecount解决了以下问题:
<target name="export-report-icons" description="A description">
<condition property="test2" else="false">
<or>
<resourcecount when="gt" count="0" property="flength">
<fileset dir="d:\test" id="onlyinbar">
<present targetdir="DIRs_A" present="srconly"/>
</fileset>
</resourcecount>
<resourcecount when="gt" count="0" property="flength">
<fileset dir="DIR_A" id="differentbarfoo">
<different targetdir="d:\test" ignoreFileTimes="true"/>
</fileset>
</resourcecount>
</or>
</condition>
</target>
<target name="copyThis" depends="export-report-icons" if="${test2}">
....
</target>
....
因此,这将设置一个OR。对于两个文件集中的一个成功的情况,计数器包装文件集资源,以便它可以在条件下托管,并且条件根据OR计数具有属性true或false。如果${test2}为true,则执行“copythis”目标。请注意,如果设置id=test2,它将始终限定为true,因为在本例中它检查值是否存在 我们需要避免任何第三方参与此解决方案。我的主要问题是标签的组合。我们知道我们的“测试”,即文件集标记必须处于该状态,但不知道如何进行。resourcecount解决了以下问题:
<target name="export-report-icons" description="A description">
<condition property="test2" else="false">
<or>
<resourcecount when="gt" count="0" property="flength">
<fileset dir="d:\test" id="onlyinbar">
<present targetdir="DIRs_A" present="srconly"/>
</fileset>
</resourcecount>
<resourcecount when="gt" count="0" property="flength">
<fileset dir="DIR_A" id="differentbarfoo">
<different targetdir="d:\test" ignoreFileTimes="true"/>
</fileset>
</resourcecount>
</or>
</condition>
</target>
<target name="copyThis" depends="export-report-icons" if="${test2}">
....
</target>
....
因此,这将设置一个OR。对于两个文件集中的一个成功的情况,计数器包装文件集资源,以便它可以在条件下托管,并且条件根据OR计数具有属性true或false。如果${test2}为true,则执行“copythis”目标。请注意,如果设置id=test2,它将始终限定为true,因为在本例中它检查值是否存在 我们需要避免任何第三方参与此解决方案。我的主要问题是标签的组合。我们知道我们的“测试”,即文件集标记必须处于该状态,但不知道如何进行。resourcecount解决了以下问题:
<target name="export-report-icons" description="A description">
<condition property="test2" else="false">
<or>
<resourcecount when="gt" count="0" property="flength">
<fileset dir="d:\test" id="onlyinbar">
<present targetdir="DIRs_A" present="srconly"/>
</fileset>
</resourcecount>
<resourcecount when="gt" count="0" property="flength">
<fileset dir="DIR_A" id="differentbarfoo">
<different targetdir="d:\test" ignoreFileTimes="true"/>
</fileset>
</resourcecount>
</or>
</condition>
</target>
<target name="copyThis" depends="export-report-icons" if="${test2}">
....
</target>
....
因此,这将设置一个OR。对于两个文件集中的一个成功的情况,计数器包装文件集资源,以便它可以在条件下托管,并且条件根据OR计数具有属性true或false。如果${test2}为true,则执行“copythis”目标。请注意,如果设置id=test2,它将始终限定为true,因为在本例中它检查值是否存在 我们需要避免任何第三方参与此解决方案。我的主要问题是标签的组合。我们知道我们的“测试”,即文件集标记必须处于该状态,但不知道如何进行。resourcecount解决了以下问题:
<target name="export-report-icons" description="A description">
<condition property="test2" else="false">
<or>
<resourcecount when="gt" count="0" property="flength">
<fileset dir="d:\test" id="onlyinbar">
<present targetdir="DIRs_A" present="srconly"/>
</fileset>
</resourcecount>
<resourcecount when="gt" count="0" property="flength">
<fileset dir="DIR_A" id="differentbarfoo">
<different targetdir="d:\test" ignoreFileTimes="true"/>
</fileset>
</resourcecount>
</or>
</condition>
</target>
<target name="copyThis" depends="export-report-icons" if="${test2}">
....
</target>
....
因此,这将设置一个OR。对于两个文件集中的一个成功的情况,计数器包装文件集资源,以便它可以在条件下托管,并且条件根据OR计数具有属性true或false。如果${test2}为true,则执行“copythis”目标。请注意,如果设置id=test2,它将始终限定为true,因为在本例中它检查值是否存在。