简体   繁体   中英

Ant resource exists check

I have problem testing file existence with ant. I want to check if files exist in target test , and if not, I want download files in target download . But the download target will be executed always (if files exist or not). 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 . Similarly, a <target> with an unless attribute will execute if the property in the unless attribute doesn't exist . 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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