ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Set properties.
Date Wed, 27 Jun 2001 13:03:37 GMT
Natalia Bello <nbello@isabel.be> wrote:

> Hi, I am quite new with Ant, and I have some problems.  I am trying
> to use the same target from two different ones; setting some
> parameters, and execute or not this last target depending of one of
> the parameters.
> 
> This is the code:
> 
>     <target name="chek_junit">  
>           <available file="${junit.jar}"
>           property="junit.jar.present"/> <echo message="Junit
>           present; ${junit.jar.present}"/> <antcall
>           target="get_jar"> <param name="present"
>           value="${junit.jar.present}"/> <param name="project.name"
>           value="${Junit.project.name}"/> <param name="jar.name"
>           value="${junit.jar}"/> </antcall>
> 
>    </target>   
>                
>     <target name="check_log4j">  
>           <available file="${log4j.jar}" property="
>           log4j.jar.present "/> <echo message="Log4j present:
>           ${log4j.jar.present}"/> <antcall target="get_jar">
>           
>             <param name="present" value="${log4j.jar.present}"/>
>             <param name="project.name"
>             value="${log4j.project.name}"/> <param name="jar.name"
>             value="${log4j.jar}"/>
>            </antcall>
>    </target>   
>    
> 
> <target name="get_jar" unless="present">   
> 	.....
> </target>
> 

> The problem is that when one of the files doesn't exists, the
> property is not set , and the value that the parameter take is
> literally "${log4j.jar.present}", and the target "get_jar" is never
> executed, because present is alredy set.

Move the available task to a target get_jar depends upon, something like

<target name="check_log4j">
  <antcall target="get_jar">
    <param name="jar" value="${log4j.jar}" />
    ....
  </antcall>
</target>

<target name="check">
  <available file="${jar}" property="present "/>
  <echo message="${jar} present: ${present}" />
</target>

<target name="get_jar" unless="present" depends="check">   
	.....
</target>

Stefan

Mime
View raw message