简体   繁体   English

蚂蚁资源存在检查

[英]Ant resource exists check

I have problem testing file existence with ant. 我在使用ant测试文件是否存在问题。 I want to check if files exist in target test , and if not, I want download files in target download . 我想检查目标test是否存在文件,如果不存在,我想下载目标download文件。 But the download target will be executed always (if files exist or not). 但是download目标将始终执行(如果文件存在或不存在)。 Can anybody show what is wrong? 有人可以证明出什么问题了吗?

<!-- Test lib files if exist -->
<target name="test">
    <condition property="is.resource.exists" value="true" else="false">
        <and>
            <resourceexists>
                <file file="${lib}/jdom-2.0.5.jar" />
            </resourceexists>
            <resourceexists>
                <file file="${lib}/miglayout-4.0-swing.jar" />
            </resourceexists>
        </and>
    </condition>
</target>

<!-- Download lib files if not exist -->
<target name="download" if="is.resource.exists" depends="test">
    <exec dir="${lib}" executable="${lib}/get-libs.sh" />
</target>

A <target> with an if attribute will execute if the property in the if attribute exists . <target>if如果在属性属性将执行if属性存在 Similarly, a <target> with an unless attribute will execute if the property in the unless attribute doesn't exist . 类似地,如果unless属性中的属性不存在,则将执行带有unless属性的<target> It doesn't matter what the value of the property is: true, false, kumquat, or whatever. 属性的值是什么无关紧要:真,假,金橘等。

Replace the if="is.resource.exists" with unless="is.resource.exists" and you should be good. 替换if="is.resource.exists"unless="is.resource.exists" ,你应该是不错的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM