Ahhh, you're using var instead of property. I missed that before. Since you instantiate it first, the scope remains over the antcalls. Beautiful, thanks Budd! Eric
----- Original Message ----- From: "McNish, Budd" <bmcn...@healthplan.com> To: Ant Users List <user@ant.apache.org>; 'Eric Fetzer' <elstonk...@yahoo.com> Cc: Sent: Wednesday, May 15, 2013 9:36 AM Subject: RE: <target unless=...> Eric, Okay try this one. <project default="invalid"> <target name="invalid"> <taskdef resource="net/sf/antcontrib/antcontrib.properties"> <classpath location="${antcontrib.jar}"/> </taskdef> <var name="testit" value="" /> <antcall target="test1" inheritall="true" /> <antcall target="test2" inheritall="true" /> </target> <target name="test1" depends="setvalue"> <echo message="in test1 and value of testit is: ${testit}"/> </target> <target name="test2" unless="testit"> <echo message="in test2"/> <echo message="value of testit is: ${testit}"/> </target> <target name="setvalue"> <echo>setting the value to 1.2.3.4</echo> <var name="testit" value="1.2.3.4" /> <echo>testit = ${testit}</echo> </target> </project> C:\IBM>ant -f /temp/throw.xml Buildfile: C:\temp\throw.xml invalid: setvalue: [echo] setting the value to 1.2.3.4 [echo] testit = 1.2.3.4 test1: [echo] in test1 and value of testit is: 1.2.3.4 test2: BUILD SUCCESSFUL Total time: 0 seconds C:\IBM> Budd A. McNish Health Plan Services 813-289-1000 ext. 2352 -----Original Message----- From: Eric Fetzer [mailto:elstonk...@yahoo.com] Sent: Wednesday, May 15, 2013 11:21 AM To: Ant Users List Subject: Re: <target unless=...> Sorry Budd, it looks like I wasn't clear on one aspect of this. The value of this property must be set inside of the first target called. In reality, the first target called has a depends target that may set this property. Based on whether it sets that property, we may or may not want to come back to that target again. So a more valid repro would be: <project name="test" default="testIt"> <taskdef resource="net/sf/antcontrib/antlib.xml"/> <target name="testIt"> <antcall target="test1" inheritall="true" /> <echo message="back out to main target, label is: ${label}"/> <antcall target="test2" inheritall="true" /> </target> <target name="test1" depends="setLabel" > <echo message="in test1 and value of label is: ${label}"/> </target> <target name="test2" depends="setLabel"> <echo message="in test2"/> <echo message="value of label is: ${label}"/> </target> <target name="setLabel" unless="label"> <property name="label" value="1.2.3.4"/> <echo message="I'm creating a label here..."/> </target> </project> And the results from running this are: Buildfile: test.xml testIt: setLabel: [echo] I'm creating a label here... test1: [echo] in test1 and value of label is: 1.2.3.4 [echo] back out to main target, label is: ${label} setLabel: [echo] I'm creating a label here... test2: [echo] in test2 [echo] value of label is: 1.2.3.4 BUILD SUCCESSFUL Total time: 0 seconds You see that it attempts to create the label twice which will fail in my real application. I think what I need to do instead is: <project name="test" default="testIt"> <taskdef resource="net/sf/antcontrib/antlib.xml"/> <target name="testIt" depends="setLabel"> <antcall target="test1" inheritall="true" /> <antcall target="test2" inheritall="true" /> </target> <target name="test1"> <echo message="in test1 and value of label is: ${label}"/> </target> <target name="test2"> <echo message="in test2"/> <echo message="value of label is: ${label}"/> </target> <target name="setLabel"> <property name="label" value="1.2.3.4"/> <echo message="I'm creating a label here..."/> </target> </project> In my real world application, that will take some rewriting, but simple is good... Thanks for looking at my spaghetti (mmmmmm, meatballs)! Thanks, Eric ----- Original Message ----- From: "McNish, Budd" <bmcn...@healthplan.com> To: Ant Users <user@ant.apache.org>; 'Eric Fetzer' <elstonk...@yahoo.com> Cc: Sent: Wednesday, May 15, 2013 8:48 AM Subject: RE: <target unless=...> This works. <project default="invalid"> <target name="invalid"> <property name="testit" value="" /> <antcall target="test1" inheritall="true" > <param name="testit" value="true"/> </antcall> <antcall target="test2" inheritall="true" /> </target> <target name="test1"> <echo message="in test1 and value of testit is: ${testit}"/> </target> <target name="test2" unless="testit"> <echo message="in test2"/> <echo message="value of testit is: ${testit}"/> </target> </project> C:\IBM>ant -f /temp/throw.xml Buildfile: C:\temp\throw.xml invalid: test1: [echo] in test1 and value of testit is: true test2: BUILD SUCCESSFUL Total time: 0 seconds C:\IBM> Budd A. McNish Health Plan Services 813-289-1000 ext. 2352 -----Original Message----- From: Eric Fetzer [mailto:elstonk...@yahoo.com] Sent: Wednesday, May 15, 2013 10:14 AM To: Ant Users Subject: <target unless=...> Hi! I've found that my unless= is somewhat useless when using <antcall>. Here's a repro for what I'm trying to do: <project name="test" default="testIt"> <taskdef resource="net/sf/antcontrib/antlib.xml"/> <target name="testIt"> <antcall target="test1" inheritall="true" /> <antcall target="test2" inheritall="true" /> </target> <target name="test1"> <property name="testit" value="true"/> <echo message="in test1 and value of testit is: ${testit}"/> </target> <target name="test2" unless="testit"> <echo message="in test2"/> <echo message="value of testit is: ${testit}"/> </target> </project> And the results that I'm sure you anticipate as you understand how antcall works: [me@myMachine]$ ant -f test.xml Buildfile: test.xml testIt: test1: [echo] in test1 and value of testit is: true test2: [echo] in test2 [echo] value of testit is: ${testit} BUILD SUCCESSFUL Total time: 0 seconds My actual antcall is in a for loop using a list to call targets that start with the same word, like so: <for list="${build.apps} param="app"> <sequential> <antcall target="build@{app}"/> </sequential> </for> Can anyone give me a better methodology for achieving the results I'm after? Thanks, Eric --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ CONFIDENTIALITY NOTICE: If you have received this email in error, please immediately notify the sender by e-mail at the address shown.This email transmission may contain confidential information.This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly. Please delete it from your files if you are not the intended recipient. Thank you for your compliance. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ CONFIDENTIALITY NOTICE: If you have received this email in error, please immediately notify the sender by e-mail at the address shown.This email transmission may contain confidential information.This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly. Please delete it from your files if you are not the intended recipient. Thank you for your compliance. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org