Nathan Coast wrote:

Hi,

Apologies if this is a duplicate, I think I posted this yesterday but it doesn't seem to have reached the list.

I'm having problems using ant:available within a loop.

<j:forEach var="lib" items="${pom.artifacts}">
   <j:set var="dep" value="${lib.dependency}"/>
   <j:set var="junitejb.test.jar"
          value="foo.bar.${dep.getArtifactId()}.jar"/>

   <ant:available property="junitejb.test.jar.available"
                  file="${junitejb.test.jar}"/>

   <j:if test="${junitejb.test.jar.available}">
       ..... do something
   </j:if>
   <j:set var="junitejb.test.jar.available" value=""/>
</j:forEach>

If the available test fails to locate the file, the value of the property is unchanged. So when a file is located, all subsequent loops the property junitejb.test.jar.available is true.

I tried resetting the property to "" but then the var doesn't seem to get set to true if a file is located in subsequent loops.

Ant properties can be set once only, so <ant:available> tag just won't cut it here. You need to take a look at the jelly tag libraries for a tag doing a similar thing. Alternatively you could instantiate java.io.File object programatically using jelly:core tags, and call ${file.exists()} in the <j:if> test.


R.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to