ant contrib - ant - if doesn't support the "name" attribute -
i have requirement follows. have .properties file (with name=value pair) reading couple of properties. want check particular property exist or not. getting error if doesn't support "name" attribute following code. javaprojectname,projdir names getting .properties file.
<if name="${javaprojectname}" exists="true"> <property name="importjavaproject" value="${projdir}/${javaprojectname}"/> </if> can please tell me doing wrong.
read the document of <if> task first. doesn't support way wrote.
it should be:
<if> <isset property="javaprojectname" /> <then> <property name="importjavaproject" value="${projdir}/${javaprojectname}"/> </then> </if> however, want set property importjavaproject when property javaprojectname has been set before (in build file or in properties file imported). so, if javaprojectname has not been set?
you should either think of <else> part, or fail build.
if want check existence , fail build when not exist, use <fail>:
<fail unless="javaprojectname"/> also check condition task , "supported conditions".
addition:
also read question posted manmohan in comment more carefully. "check property existence in .properties file", accepted answer of question checks both "whether property has been set" , "whether value empty".
Comments
Post a Comment