title: ANT: How to read property setted in a foreach loop
body: <p>Dear, I currently face some problem to retrieve the value of a property setted in a foreach loop. Maybe one of you could help me...</p>
  
  <p>The purpose is to check if one file of a folder has been modified since the corresponding jar has been generated. This way I know if I have to generate the jar again.
  What I do is to go through the folder with a foreach loop and if one file match my test, set a property to true.</p>
  
  <p>The problem is that my variable doesn't seems to exist after my loop... Here is a simplified code example that has the same problem:</p>
  
  <pre><code>&lt;target name="target"&gt;
      &lt;taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${lib.dir}/ant-contrib.jar"&gt;&lt;/taskdef&gt;
      &lt;foreach target="setVar" param="var" list="a,b"/&gt;
      &lt;echo&gt;myreturn in target: ${env.myreturn}&lt;/echo&gt;
      &lt;property name="env.myreturn" value="c"/&gt;
      &lt;echo&gt;myreturn in second: ${env.myreturn}&lt;/echo&gt;
  &lt;/target&gt;
  &lt;target name="setVar"&gt;
      &lt;property name="env.myreturn" value="${var}"/&gt;
      &lt;echo&gt;myreturn in setVar: ${env.myreturn}&lt;/echo&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>The result of this code is:</p>
  
  <pre><code>target:
  setVar:
   [echo] myreturn in setVar: a
  setVar:
   [echo] myreturn in setVar: b
   [echo] myreturn in target: ${env.myreturn}
   [echo] myreturn in second: c
  BUILD SUCCESSFUL
  </code></pre>
  
  <p>It seems that the variable is correctly set as it could be printed in the "setVar" target but no way to retrieve value from the calling target.</p>
  
  <p>I also know it's not possible to assign a value to a property twice. But the problem doesn't even occurs... When it'll be the case I could add a check on the value of the property before to assign it to be sure it is not already initialized...</p>
  
  <p>Do you have a clue on the way I can solve my problem ???</p>
  
  <p>Many thanks in advance for your help :)</p>