Kei*_*rup 3 ant command-line build-process
我是ant的新手,如果使用默认目标以外的东西,我想要一个文件名,所以调用语法是这样的:
ant specifictarget -Dfile=myfile
Run Code Online (Sandbox Code Playgroud)
我正在使用ant contrib包给我额外的功能,所以我有这个:
<if>
<equals arg1="${file}" arg2="" />
<then>
<!-- fail here -->
</then>
</if>
Run Code Online (Sandbox Code Playgroud)
我的想法是,如果没有指定文件,它可能等于空字符串.显然,这不起作用,我没有在谷歌或手册中的正确语法中找到任何示例.
那么我应该使用什么语法?
小智 6
你真的不需要contrib包.使用内置的ant功能(如if/unless和depends)可以更方便地完成此操作.见下文:
<target name="check" unless="file" description="check that the file property is set" >
<fail message="set file property in the command line (e.g. -Dfile=someval)"/>
</target>
<target name="specifictarget" if="file" depends="check" description=" " >
<echo message="do something ${file}"/>
</target>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2809 次 |
| 最近记录: |