我正在尝试检查文件夹的名称,如果它包含某个字符串,我希望更改该文件夹路径。
到目前为止,我提出了这个问题:
<property name="component.release.dir" value="${install.dir}/${component.name}" />
<!-- Check if the component is a part of projectL -->
<condition property="projectLFolderSpotted">
<matches pattern="projectL" string="${component.release.dir}"/>
<!-- if so, put the component in an appropriate folder -->
<property name="component.release.dir" value="${install.dir}/projectL/${component.name}" />
<echo message="projectL component has been detected, and moved accordingly!"/>
</condition>
但是我收到以下错误:
condition doesn't support the nested "property" element.
有没有办法实现这个目标?
提前致谢。
答案 0 :(得分:0)
ANT中的属性是不可变的,一旦他们被分配了一个它不会改变的值。
我建议你这样做:
<project name="demo" default="build">
<property name="release.dir.seed" location="build/helloworld"/>
<condition property="release.dir" value="build/found/helloworld" else="build/notfound/helloworld">
<contains string="${release.dir.seed}" substring="helloworld"/>
</condition>
<target name="build">
<echo message="Result: ${release.dir}"/>
</target>
</project>