ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson, Rob (Global Trade)" <Rob.Ander...@nike.com>
Subject RE: Best way to perform this type of conditonal test in ANT
Date Fri, 21 Sep 2007 16:53:31 GMT
Why have the wrapper target at all? Add the if condition to the "_pmd"
target itself.

 <target name="_pmd"
depends="pmd-init,find-pmd-java-files,modified-java-pmd,new-java-pmd"
if="pmd.jar"/>

-Rob Anderson

> -----Original Message-----
> From: Eric Wood [mailto:EWood@llbean.com] 
> Sent: Friday, September 21, 2007 6:18 AM
> To: Ant Users List
> Subject: Best way to perform this type of conditonal test in ANT
> 
> I want to only call a target ( _pmd ) if the property 
> "pmd.jar" is set. 
> 
>     <target name="perform-pmd" if="pmd.jar" >
>         <runtarget target="_pmd" />
>     </target>
> 
>     <target name="_pmd"
> depends="pmd-init,find-pmd-java-files,modified-java-pmd,new-ja
> va-pmd" />
> 
> 
> The problem I have with the code above is that runtarget 
> seems to run in
> its own JVM so properties that are set in there that I need 
> to reference
> later are not available after it runs.  Also, if I add the "if" clause
> to the _pmd target, the depends are processed first.
> 
> How do I best handle the conditional execution of a target 
> without using
> either antcall or runtarget?
> 


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


Mime
View raw message