Examining the following ant build file.  Could someone please tell me
why it is continually running the "create" task even though I'm trying
to set the property after it is run once?  Basically I don't care if I
do it this way or another way...I just want to know how to keep tasks
from being run more than once.  It seems to be working in the init task
but not in the other tasks where I mimic the same property behavior.
Thanks for your help.


ANT BUILD FILE:
<project name="sprayIP" default="all" basedir=".">

   <target name="init" unless="init.done">
      <echo message="init.done = ${init.done}" />
      <property name="EMAIL_LIST" value="[EMAIL PROTECTED]" />
      <property name="OLD_IP_FILENAME" value="IP-old.txt" />
      <property name="NEW_IP_FILENAME" value="IP-new.txt" />
      
      <property name="init.done" value="true" />
      <echo message="init.done = ${init.done}" />
   </target>

   <target name="create" depends="init" unless="create.done">
      <echo message="create.done = ${create.done}" />
      <exec executable="getIP.bat">
         <arg value="${NEW_IP_FILENAME}" />
      </exec>
      
      <property name="create.done" value="true" />
      <echo message="create.done = ${create.done}" />
   </target>

   <target name="email" depends="init, create, checkIP"
unless="ip.not.changed">
      <mail from="MAX" tolist="${EMAIL_LIST}" 
            subject="MAX IP ADDRESS" files="${NEW_IP_FILENAME}"
            mailhost="MYMAILHOST"/>
   </target>

   <target name="cleanup" depends="init, email">
      <move file="${NEW_IP_FILENAME}" tofile="${OLD_IP_FILENAME}"
overwrite="yes" />
   </target>

   <target name="all" depends="init" unless="all.done">
      <antcall target="checkIP" />
      <antcall target="email" />
      <antcall target="cleanup" />

      <property name="all.done" value="true" />
   </target>
    
   <target name="checkIP" depends="init, create" unless="checkIP.done">
      <condition property="ip.not.changed">
         <filesmatch file1="${NEW_IP_FILENAME}"
file2="${OLD_IP_FILENAME}" />
      </condition>

      <echo message="ip.not.changed = ${ip.not.changed}" />
      <property name="checkIP.done" value="true" />
    </target>
</project>

ANT BUILD FILE OUTPUT:
Buildfile: mailIP.xml

init:
     [echo] init.done = ${init.done}
     [echo] init.done = true

all:

init:

create:
     [echo] create.done = ${create.done}

     [exec] C:\bin>ipconfig /all  1>IP-new.txt 
     [echo] create.done = true

checkIP:
     [echo] ip.not.changed = true

init:

create:
     [echo] create.done = ${create.done}

     [exec] C:\bin>ipconfig /all  1>IP-new.txt 
     [echo] create.done = true

checkIP:
     [echo] ip.not.changed = true

email:

init:

create:
     [echo] create.done = ${create.done}

     [exec] C:\bin>ipconfig /all  1>IP-new.txt 
     [echo] create.done = true

checkIP:
     [echo] ip.not.changed = true

email:

cleanup:
     [move] Moving 1 files to C:\bin

BUILD SUCCESSFUL
Total time: 2 seconds

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@;jakarta.apache.org>

Reply via email to