ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "George Czernuszka" <george.czernus...@nscgroup.co.uk>
Subject RE: refid still not behaving as expected in 1.7.0
Date Thu, 30 Aug 2007 11:24:36 GMT

Thanks Peter

I'll try some code like this at some stage.
 

> -----Original Message-----
> From: Peter Reilly [mailto:peter.kitt.reilly@gmail.com] 
> Sent: 30 August 2007 11:43
> To: Ant Users List
> Subject: Re: refid still not behaving as expected in 1.7.0
> 
> You can write your own isreference implementation -
>     <script language="beanshell">
>       import org.apache.tools.ant.*;
>       import org.apache.tools.ant.taskdefs.condition.Condition;
>       public class IsItAReference extends ProjectComponent 
> implements Condition {
>           private String r;
>           public void setRefId(String r) {
>              this.r = r;
>           }
>           public boolean eval() {
>              if (r == null) {
>               return false;
>              }
>              return getProject().getReferences().get(r) != null;
>           }
>       }
>       project.addDataTypeDefinition("isitareference", 
> IsItAReference.class);
>     </script>
> 
> <project name="x" default="x">
>   <import file="define-my-types.xml"/>
>   <target name="y">
>     <path id="ref.not-here" path="."/>
>   </target>
> 
>   <target name="x">
> 
>     <path id="ref.here" path="."/>
>     <condition property="here">
>       <isitareference refid="ref.here"/>
>     </condition>
>     <echo>${here}</echo>
> 
>     <condition property="not-here">
>       <isitareference refid="ref.not-here"/>
>     </condition>
>     <echo>${not-here}</echo>
>   </target>
> 
> </project>
> 
> Peter
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message