2014-06-11 2 views
0
<target name="build"> 
<for list="${platform}" param="platform" trim="true"> 
<sequential> 
<if> 
<equals arg1="${platform}" arg2="${project.SuppoortedPlatforms}" /> 
<then> 
<antcall target="package.${platform}" /> 
</then> 
</if> 
</sequential> 
</for> 
</target> 

런타임에서 값을 가져 오는 플랫폼 (예 : windows, ios) 및 project.SuppoortedPlatforms는 build.properties (예 : android, ios)에서 선언됩니다. 문자열 목록을 어떻게 비교할 수 있습니까? 누구든지이 문제를 해결할 수 있습니까?개미 - 어떻게 문자열 목록을 비교할 수 있습니까?

감사합니다, sandhiya

답변

1

당신은 플랫폼의 쉼표로 구분 된 목록을 통해 반복되며,이 project.SuppoortedPlatforms에 지원되는 플랫폼 목록에 포함되는 경우 각각에 대해 당신이 확인하고 있습니다. 이 같이 가야한다 : 루프에서

<for list="${platform}" param="platformParam" trim="true"> 
    <sequential> 
    <if> 
     <contains string="${project.SuppoortedPlatforms}" substring="@{platformParam}" /> 
     <then> 
      <antcall target="[email protected]{platformParam}" /> 
     </then> 
     </if> 
     </sequential> 
    </for> 

매개 변수는 @ 대신 $에 액세스 할 수 있어야합니다. 또한 가독성을 위해 매개 변수의 이름을 바꾸는 것이 좋습니다 (platform 대신 platformParam).

+0

감사합니다. manouti, 이제 코드가 올바르게 작동합니다. – jass

+0

답이 맞으면 대답을 수락하십시오. 아마 upvote. FAQ : http://stackoverflow.com/tour – Jayan

0
Instead of using contains task, i myself tried with the nested for loop, its cool working fine. 


    <for list="${platforms}" param="platformparam" trim="true"> 
<sequential> 
    <for list="${project.SupportedPlatforms}" param="supplatformparam" trim="true"> 
    <sequential> 
     <if> 
     <equals arg1="@{platformparam}" arg2="@{supplatformparam}" /> 
     <then> 
      <antcall target="[email protected]{platformParam}" /> 
     </then> 
     </if> 
    </sequential> 
    </for> 
</sequential> 
</for> 
+0

을 참조하십시오.이 도구도 잘 작동합니다. 시도해보십시오. – jass

관련 문제