I need to compare two string args, from which I used to get one arg as runtime input (e.g. platform=windows,ios,mac
) and another one has list of values, defined under build.properties
(e.g. project.supportedplatforms=windows,mac
). If the condition matches, then it should return "true" else "fail" from one macrodef to some target.
<for list="${platform}" param="platformparam" trim="true">
<sequential>
<if>
<isItemExists retToProp="@{platformparam}" />
<then>
<antcall target="package.@{platformParam}" />
</then>
</if>
</sequential>
</for>
<macrodef name="isItemExists">
<attribute name="retToProp" />
<property name="itemtosearch" value="@{retToProp}" />
<for list="${project.supportedplatforms}" param="listparam" trim="true">
<if>
<equals arg1="@{listparam}" arg2="@{platformparam}" />
<then>
<!-- return true -->
</then>
<else>
<!-- return false -->
</else>
</if>
</for>
</macrodef>
When ${platforms}
and ${project.supportedplatforms}
having same value it should call the specified target. But in this snippets, the macrodef-for loop will executes for n times and at last what the value is assigned for @{returnproperty}
, is going to throw for target "build", if it happens like this with valid input, it will not do my stuff, because for loop will execute in sequential manner. (e.g. platforms=windows,mac,android
, project.supportedplatforms=ios,android,windows
, if my list looks like this means, is there any possible way to get my result).
<for list="${platforms}" param="platformparam" trim="true">
<sequential>
<isItemExists returnProperty="returnProp" platforms="@{platformparam}" />
<if>
<equals arg1="${returnProp}" arg2="true" />
<then>
<antcall target="package.@{platformparam}" />
</then>
</if>
</sequential>
</for>
<macrodef name="isItemExists">
<attribute name="platform" />
<attribute name="returnProperty" />
<sequential>
<var name="@{returnProperty}" unset="true" />
<for list="${project.supportedplatforms}" param="listparam" trim="true">
<if>
<equals arg1="@{listparam}" arg2="@{platform}" />
<then>
<property name="@{returnProperty}" value="true" />
</then>
<else>
<property name="@{returnProperty}" value="false" />
</else>
</if>
</sequential>
</macrodef>