Grokbase Groups Ant user May 2013
FAQ
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-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

Search Discussions

  • McNish, Budd at May 15, 2013 at 2:49 pm
    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
    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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Eric Fetzer at May 15, 2013 at 3:21 pm
    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" <bmcnish@healthplan.com>
    To: Ant Users <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • McNish, Budd at May 15, 2013 at 3:43 pm
    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
    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" <bmcnish@healthplan.com>
    To: Ant Users <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Eric Fetzer at May 15, 2013 at 3:59 pm
    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" <bmcnish@healthplan.com>
    To: Ant Users List <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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" <bmcnish@healthplan.com>
    To: Ant Users <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Eric Fetzer at Aug 21, 2013 at 9:31 pm
    I just threw this out because I couldn't get anything to work.  Reviving because I can't accept failure.  Budd, your repro wasn't doing what I wanted, but I didn't realize why until now.  The reson you went into test1 was because you didn't put an unless clause on it.  Put the unless clause on it and you wouldn't go into it.  As soon as you instantiate the var, you won't go into any of the targets for the var.  I want to go into my target once and only once.  Consider the following example:

    <project default="invalid">
        <!-- Import the properties_common.xml file -->
        <import file="properties.xml" />
        <import file="includes.xml" />
        <taskdef resource="net/sf/antcontrib/antlib.xml"/>
        <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
      <target name="invalid">
            <var name="testit" value=""/>
            <antcall target="dotest1" inheritall="true" />
            <antcall target="dotest2" inheritall="true" />
      </target>
      <target name="dotest1" depends="setvalue">
        <echo message="in test1 and value of testit is:  ${testit}"/>
      </target>
      <target name="dotest2" depends="setvalue">
        <echo message="in test2"/>
        <echo message="value of testit is:  ${testit}"/>
      </target>
      <target name="setvalue" unless="testit">
          <echo>setting the value to true</echo>
          <var name="testit" value="true" />
          <echo>testit = ${testit}</echo>
      </target>
    </project>

    It won't go into setvalue ever because testit is already instantiated.  I want it to go in once.  Anyone able to help me on this?

    Thanks,
    Eric


    ----- Original Message -----
    From: Eric Fetzer <elstonkers@yahoo.com>
    To: "McNish, Budd" <bmcnish@healthplan.com>; Ant Users List <user@ant.apache.org>
    Cc:
    Sent: Wednesday, May 15, 2013 9:59 AM
    Subject: Re: <target unless=...>

    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" <bmcnish@healthplan.com>
    To: Ant Users List <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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" <bmcnish@healthplan.com>
    To: Ant Users <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Eric Fetzer at Aug 22, 2013 at 3:53 pm
    This is insane!  Is there no way to preserve information set in an antcall?  I tried to change strategy a little and do the following:

    <project default="invalid">
        <!-- Import the properties_common.xml file -->
        <import file="properties.xml" />
        <import file="includes.xml" />
        <taskdef resource="net/sf/antcontrib/antlib.xml"/>
        <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
      <target name="invalid">
         <property name="labelset" value="false"/>
         <antcall target="dotest1" inheritall="true" />
         <echo>before going to dotest2 labelset = ${labelset}</echo>
         <antcall target="dotest2" inheritall="true" />
      </target>
      <target name="dotest1" depends="setvalue">
        <echo message="in test1 and value of labelset is:  ${labelset}"/>
      </target>
      <target name="dotest2" depends="setvalue">
        <echo message="in test2"/>
        <echo message="value of labelset is:  ${labelset}"/>
      </target>
      <target name="setvalue">
        <if>
          <equals arg1="${labelset}" arg2="false" />
          <then>
            <echo>Before setting the value, labelset = ${labelset}</echo>
            <echo>setting the value to true</echo>
            <unset name="labelset"/>
            <property name="labelset" value="true" />
            <echo>labelset = ${labelset}</echo>
          </then>
        </if>
      </target>
    </project>

    Same results:

    Buildfile: testthrow.xml
    invalid:
    setvalue:
         [echo] Before setting the value, labelset = false
         [echo] setting the value to true
         [echo] labelset = true
    dotest1:
         [echo] in test1 and value of labelset is:  true
         [echo] before going to dotest2 labelset = false
    setvalue:
         [echo] Before setting the value, labelset = false
         [echo] setting the value to true
         [echo] labelset = true
    dotest2:
         [echo] in test2
         [echo] value of labelset is:  true
    BUILD SUCCESSFUL

    It loses the setting that happened in setvalue...  Anybody?????


    ----- Original Message -----
    From: Eric Fetzer <elstonkers@yahoo.com>
    To: "McNish, Budd" <bmcnish@healthplan.com>; Ant Users List <user@ant.apache.org>
    Cc:
    Sent: Wednesday, August 21, 2013 3:31 PM
    Subject: Re: <target unless=...>

    I just threw this out because I couldn't get anything to work.  Reviving because I can't accept failure.  Budd, your repro wasn't doing what I wanted, but I didn't realize why until now.  The reson you went into test1 was because you didn't put an unless clause on it.  Put the unless clause on it and you wouldn't go into it.  As soon as you instantiate the var, you won't go into any of the targets for the var.  I want to go into my target once and only once.  Consider the following example:

    <project default="invalid">
        <!-- Import the properties_common.xml file -->
        <import file="properties.xml" />
        <import file="includes.xml" />
        <taskdef resource="net/sf/antcontrib/antlib.xml"/>
        <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
      <target name="invalid">
            <var name="testit" value=""/>
            <antcall target="dotest1" inheritall="true" />
            <antcall target="dotest2" inheritall="true" />
      </target>
      <target name="dotest1" depends="setvalue">
        <echo message="in test1 and value of testit is:  ${testit}"/>
      </target>
      <target name="dotest2" depends="setvalue">
        <echo message="in test2"/>
        <echo message="value of testit is:  ${testit}"/>
      </target>
      <target name="setvalue" unless="testit">
          <echo>setting the value to true</echo>
          <var name="testit" value="true" />
          <echo>testit = ${testit}</echo>
      </target>
    </project>

    It won't go into setvalue ever because testit is already instantiated.  I want it to go in once.  Anyone able to help me on this?

    Thanks,
    Eric


    ----- Original Message -----
    From: Eric Fetzer <elstonkers@yahoo.com>
    To: "McNish, Budd" <bmcnish@healthplan.com>; Ant Users List <user@ant.apache.org>
    Cc:
    Sent: Wednesday, May 15, 2013 9:59 AM
    Subject: Re: <target unless=...>

    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" <bmcnish@healthplan.com>
    To: Ant Users List <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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" <bmcnish@healthplan.com>
    To: Ant Users <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@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-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Peter Reilly at Aug 22, 2013 at 4:50 pm
    Maybe ant-contrib's runtarget may fit better for your use-case.

    Peter

    On Thu, Aug 22, 2013 at 9:52 AM, Eric Fetzer wrote:

    This is insane! Is there no way to preserve information set in an
    antcall? I tried to change strategy a little and do the following:

    <project default="invalid">
    <!-- Import the properties_common.xml file -->
    <import file="properties.xml" />
    <import file="includes.xml" />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
    <target name="invalid">
    <property name="labelset" value="false"/>
    <antcall target="dotest1" inheritall="true" />
    <echo>before going to dotest2 labelset = ${labelset}</echo>
    <antcall target="dotest2" inheritall="true" />
    </target>
    <target name="dotest1" depends="setvalue">
    <echo message="in test1 and value of labelset is: ${labelset}"/>
    </target>
    <target name="dotest2" depends="setvalue">
    <echo message="in test2"/>
    <echo message="value of labelset is: ${labelset}"/>
    </target>
    <target name="setvalue">
    <if>
    <equals arg1="${labelset}" arg2="false" />
    <then>
    <echo>Before setting the value, labelset = ${labelset}</echo>
    <echo>setting the value to true</echo>
    <unset name="labelset"/>
    <property name="labelset" value="true" />
    <echo>labelset = ${labelset}</echo>
    </then>
    </if>
    </target>
    </project>

    Same results:

    Buildfile: testthrow.xml
    invalid:
    setvalue:
    [echo] Before setting the value, labelset = false
    [echo] setting the value to true
    [echo] labelset = true
    dotest1:
    [echo] in test1 and value of labelset is: true
    [echo] before going to dotest2 labelset = false
    setvalue:
    [echo] Before setting the value, labelset = false
    [echo] setting the value to true
    [echo] labelset = true
    dotest2:
    [echo] in test2
    [echo] value of labelset is: true
    BUILD SUCCESSFUL

    It loses the setting that happened in setvalue... Anybody?????


    ----- Original Message -----
    From: Eric Fetzer <elstonkers@yahoo.com>
    To: "McNish, Budd" <bmcnish@healthplan.com>; Ant Users List <
    user@ant.apache.org>
    Cc:
    Sent: Wednesday, August 21, 2013 3:31 PM
    Subject: Re: <target unless=...>

    I just threw this out because I couldn't get anything to work. Reviving
    because I can't accept failure. Budd, your repro wasn't doing what I
    wanted, but I didn't realize why until now. The reson you went into test1
    was because you didn't put an unless clause on it. Put the unless clause
    on it and you wouldn't go into it. As soon as you instantiate the var, you
    won't go into any of the targets for the var. I want to go into my target
    once and only once. Consider the following example:

    <project default="invalid">
    <!-- Import the properties_common.xml file -->
    <import file="properties.xml" />
    <import file="includes.xml" />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
    <target name="invalid">
    <var name="testit" value=""/>
    <antcall target="dotest1" inheritall="true" />
    <antcall target="dotest2" inheritall="true" />
    </target>
    <target name="dotest1" depends="setvalue">
    <echo message="in test1 and value of testit is: ${testit}"/>
    </target>
    <target name="dotest2" depends="setvalue">
    <echo message="in test2"/>
    <echo message="value of testit is: ${testit}"/>
    </target>
    <target name="setvalue" unless="testit">
    <echo>setting the value to true</echo>
    <var name="testit" value="true" />
    <echo>testit = ${testit}</echo>
    </target>
    </project>

    It won't go into setvalue ever because testit is already instantiated. I
    want it to go in once. Anyone able to help me on this?

    Thanks,
    Eric


    ----- Original Message -----
    From: Eric Fetzer <elstonkers@yahoo.com>
    To: "McNish, Budd" <bmcnish@healthplan.com>; Ant Users List <
    user@ant.apache.org>
    Cc:
    Sent: Wednesday, May 15, 2013 9:59 AM
    Subject: Re: <target unless=...>

    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" <bmcnish@healthplan.com>
    To: Ant Users List <user@ant.apache.org>; 'Eric Fetzer' <
    elstonkers@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
    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" <bmcnish@healthplan.com>
    To: Ant Users <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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-unsubscribe@ant.apache.org For additional
    commands, e-mail: user-help@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-unsubscribe@ant.apache.org For additional
    commands, e-mail: user-help@ant.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
    commands, e-mail: user-help@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-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Eric Fetzer at Aug 22, 2013 at 5:06 pm
    Oh, Peter!  I thank you very very much!  This is the first I've heard of the runtarget task in antcontrib.  It works brilliantly.
    Thanks,
    Eric

    ----- Original Message -----
    From: Peter Reilly <peter.kitt.reilly@gmail.com>
    To: Ant Users List <user@ant.apache.org>
    Cc:
    Sent: Thursday, August 22, 2013 10:49 AM
    Subject: Re: <target unless=...>

    Maybe ant-contrib's runtarget may fit better for your use-case.

    Peter

    On Thu, Aug 22, 2013 at 9:52 AM, Eric Fetzer wrote:

    This is insane!  Is there no way to preserve information set in an
    antcall?  I tried to change strategy a little and do the following:

    <project default="invalid">
    <!-- Import the properties_common.xml file -->
    <import file="properties.xml" />
    <import file="includes.xml" />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
    <target name="invalid">
    <property name="labelset" value="false"/>
    <antcall target="dotest1" inheritall="true" />
    <echo>before going to dotest2 labelset = ${labelset}</echo>
    <antcall target="dotest2" inheritall="true" />
    </target>
    <target name="dotest1" depends="setvalue">
    <echo message="in test1 and value of labelset is:  ${labelset}"/>
    </target>
    <target name="dotest2" depends="setvalue">
    <echo message="in test2"/>
    <echo message="value of labelset is:  ${labelset}"/>
    </target>
    <target name="setvalue">
    <if>
    <equals arg1="${labelset}" arg2="false" />
    <then>
    <echo>Before setting the value, labelset = ${labelset}</echo>
    <echo>setting the value to true</echo>
    <unset name="labelset"/>
    <property name="labelset" value="true" />
    <echo>labelset = ${labelset}</echo>
    </then>
    </if>
    </target>
    </project>

    Same results:

    Buildfile: testthrow.xml
    invalid:
    setvalue:
    [echo] Before setting the value, labelset = false
    [echo] setting the value to true
    [echo] labelset = true
    dotest1:
    [echo] in test1 and value of labelset is:  true
    [echo] before going to dotest2 labelset = false
    setvalue:
    [echo] Before setting the value, labelset = false
    [echo] setting the value to true
    [echo] labelset = true
    dotest2:
    [echo] in test2
    [echo] value of labelset is:  true
    BUILD SUCCESSFUL

    It loses the setting that happened in setvalue...  Anybody?????


    ----- Original Message -----
    From: Eric Fetzer <elstonkers@yahoo.com>
    To: "McNish, Budd" <bmcnish@healthplan.com>; Ant Users List <
    user@ant.apache.org>
    Cc:
    Sent: Wednesday, August 21, 2013 3:31 PM
    Subject: Re: <target unless=...>

    I just threw this out because I couldn't get anything to work.  Reviving
    because I can't accept failure.  Budd, your repro wasn't doing what I
    wanted, but I didn't realize why until now.  The reson you went into test1
    was because you didn't put an unless clause on it.  Put the unless clause
    on it and you wouldn't go into it.  As soon as you instantiate the var, you
    won't go into any of the targets for the var.  I want to go into my target
    once and only once.  Consider the following example:

    <project default="invalid">
    <!-- Import the properties_common.xml file -->
    <import file="properties.xml" />
    <import file="includes.xml" />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
    <target name="invalid">
    <var name="testit" value=""/>
    <antcall target="dotest1" inheritall="true" />
    <antcall target="dotest2" inheritall="true" />
    </target>
    <target name="dotest1" depends="setvalue">
    <echo message="in test1 and value of testit is:  ${testit}"/>
    </target>
    <target name="dotest2" depends="setvalue">
    <echo message="in test2"/>
    <echo message="value of testit is:  ${testit}"/>
    </target>
    <target name="setvalue" unless="testit">
    <echo>setting the value to true</echo>
    <var name="testit" value="true" />
    <echo>testit = ${testit}</echo>
    </target>
    </project>

    It won't go into setvalue ever because testit is already instantiated.  I
    want it to go in once.  Anyone able to help me on this?

    Thanks,
    Eric


    ----- Original Message -----
    From: Eric Fetzer <elstonkers@yahoo.com>
    To: "McNish, Budd" <bmcnish@healthplan.com>; Ant Users List <
    user@ant.apache.org>
    Cc:
    Sent: Wednesday, May 15, 2013 9:59 AM
    Subject: Re: <target unless=...>

    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" <bmcnish@healthplan.com>
    To: Ant Users List <user@ant.apache.org>; 'Eric Fetzer' <
    elstonkers@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
    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" <bmcnish@healthplan.com>
    To: Ant Users <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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-unsubscribe@ant.apache.org For additional
    commands, e-mail: user-help@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-unsubscribe@ant.apache.org For additional
    commands, e-mail: user-help@ant.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
    commands, e-mail: user-help@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-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

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

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org
  • Matt Benson at Aug 26, 2013 at 6:22 am
    I haven't deeply evaluated the targets you are invoking via antcalls, but I
    have very rarely found the need for them since the introduction of
    macrodefs around Ant 1.6--ancient history! I would recommend you experiment
    and see if you can't accomplish your goals with stock Ant.

    Matt
    On Aug 22, 2013 12:06 PM, "Eric Fetzer" wrote:

    Oh, Peter! I thank you very very much! This is the first I've heard of
    the runtarget task in antcontrib. It works brilliantly.
    Thanks,
    Eric

    ----- Original Message -----
    From: Peter Reilly <peter.kitt.reilly@gmail.com>
    To: Ant Users List <user@ant.apache.org>
    Cc:
    Sent: Thursday, August 22, 2013 10:49 AM
    Subject: Re: <target unless=...>

    Maybe ant-contrib's runtarget may fit better for your use-case.

    Peter

    On Thu, Aug 22, 2013 at 9:52 AM, Eric Fetzer wrote:

    This is insane! Is there no way to preserve information set in an
    antcall? I tried to change strategy a little and do the following:

    <project default="invalid">
    <!-- Import the properties_common.xml file -->
    <import file="properties.xml" />
    <import file="includes.xml" />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
    <target name="invalid">
    <property name="labelset" value="false"/>
    <antcall target="dotest1" inheritall="true" />
    <echo>before going to dotest2 labelset = ${labelset}</echo>
    <antcall target="dotest2" inheritall="true" />
    </target>
    <target name="dotest1" depends="setvalue">
    <echo message="in test1 and value of labelset is: ${labelset}"/>
    </target>
    <target name="dotest2" depends="setvalue">
    <echo message="in test2"/>
    <echo message="value of labelset is: ${labelset}"/>
    </target>
    <target name="setvalue">
    <if>
    <equals arg1="${labelset}" arg2="false" />
    <then>
    <echo>Before setting the value, labelset = ${labelset}</echo>
    <echo>setting the value to true</echo>
    <unset name="labelset"/>
    <property name="labelset" value="true" />
    <echo>labelset = ${labelset}</echo>
    </then>
    </if>
    </target>
    </project>

    Same results:

    Buildfile: testthrow.xml
    invalid:
    setvalue:
    [echo] Before setting the value, labelset = false
    [echo] setting the value to true
    [echo] labelset = true
    dotest1:
    [echo] in test1 and value of labelset is: true
    [echo] before going to dotest2 labelset = false
    setvalue:
    [echo] Before setting the value, labelset = false
    [echo] setting the value to true
    [echo] labelset = true
    dotest2:
    [echo] in test2
    [echo] value of labelset is: true
    BUILD SUCCESSFUL

    It loses the setting that happened in setvalue... Anybody?????


    ----- Original Message -----
    From: Eric Fetzer <elstonkers@yahoo.com>
    To: "McNish, Budd" <bmcnish@healthplan.com>; Ant Users List <
    user@ant.apache.org>
    Cc:
    Sent: Wednesday, August 21, 2013 3:31 PM
    Subject: Re: <target unless=...>

    I just threw this out because I couldn't get anything to work. Reviving
    because I can't accept failure. Budd, your repro wasn't doing what I
    wanted, but I didn't realize why until now. The reson you went into test1
    was because you didn't put an unless clause on it. Put the unless clause
    on it and you wouldn't go into it. As soon as you instantiate the var, you
    won't go into any of the targets for the var. I want to go into my target
    once and only once. Consider the following example:

    <project default="invalid">
    <!-- Import the properties_common.xml file -->
    <import file="properties.xml" />
    <import file="includes.xml" />
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>
    <taskdef name="unset" classname="ise.antelope.tasks.Unset"/>
    <target name="invalid">
    <var name="testit" value=""/>
    <antcall target="dotest1" inheritall="true" />
    <antcall target="dotest2" inheritall="true" />
    </target>
    <target name="dotest1" depends="setvalue">
    <echo message="in test1 and value of testit is: ${testit}"/>
    </target>
    <target name="dotest2" depends="setvalue">
    <echo message="in test2"/>
    <echo message="value of testit is: ${testit}"/>
    </target>
    <target name="setvalue" unless="testit">
    <echo>setting the value to true</echo>
    <var name="testit" value="true" />
    <echo>testit = ${testit}</echo>
    </target>
    </project>

    It won't go into setvalue ever because testit is already instantiated. I
    want it to go in once. Anyone able to help me on this?

    Thanks,
    Eric


    ----- Original Message -----
    From: Eric Fetzer <elstonkers@yahoo.com>
    To: "McNish, Budd" <bmcnish@healthplan.com>; Ant Users List <
    user@ant.apache.org>
    Cc:
    Sent: Wednesday, May 15, 2013 9:59 AM
    Subject: Re: <target unless=...>

    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" <bmcnish@healthplan.com>
    To: Ant Users List <user@ant.apache.org>; 'Eric Fetzer' <
    elstonkers@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
    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" <bmcnish@healthplan.com>
    To: Ant Users <user@ant.apache.org>; 'Eric Fetzer' <elstonkers@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
    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-unsubscribe@ant.apache.org For additional
    commands, e-mail: user-help@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-unsubscribe@ant.apache.org For additional
    commands, e-mail: user-help@ant.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional
    commands, e-mail: user-help@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-unsubscribe@ant.apache.org
    For additional commands, e-mail: user-help@ant.apache.org

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

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedMay 15, '13 at 2:14p
activeAug 26, '13 at 6:22a
posts10
users4
websiteant.apache.org

People

Translate

site design / logo © 2018 Grokbase