简体   繁体   中英

How to get property count in ant file?

Is there any way to get number of properties defined or provided through command line option?

I couldn't find any way till now.

Basically I have to check if command line properties are less than or greater than a specified number of properties, build should fail using

Instead of counting numbers you can check the required properties are set and fail the build if it is not set.

<project name="check" default="build">

<condition property="params.set">
    <and>
        <isset property="one"/>
        <isset property="two"/>
    </and>
</condition>

<target name="check">
    <fail unless="params.set">
    Must specify the parameters: one, two
    </fail>
</target> 
<target name="build" depends="check">
        <echo>
        one = ${one}
        two = ${two}
        </echo>
    </target>
</project>

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