DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31513>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31513

task dependencies are being executed even if 'if' attribute do not match





------- Additional Comments From [EMAIL PROTECTED]  2004-10-02 23:08 -------
It's OK to be blasphemous, but you also have to recognise that even if we were
shown to be hopelessly wrong, we couldnt change behaviour for backwards
compatibility reasons. So you'd have to start an entire new fork of the code,
which is what usually happens in real religions (that and centuries of war and
strife)

Here is a rewrite/extension of your example:
  <target name="all" depends="build" />
  
  <target name="check-preconditions" depends="test-jcc-dir" />
  
  <target name="test-jcc-dir">
    <available file="${jcc_home.dir}" type="dir" property="valid-precondition" 
/>
  </target>  
  
  <target name="casual-error-msg" unless="valid-precondition"
depends="check-preconditions">
      <echo level="error" message="ERROR: Please set the path of 'jcc_home.dir'
in the
build.xml file!" />
  </target>    
  
  <target name="test" depends="check-preconditions" if="valid-precondition" >
        <!-- something that only works if preconds are met -->
  </target>
  
  <target name="build" depends="clean, compile, test, dist" />


Note
1. anything that depends on a precondition check *explicitly* declares that in
the dependency graph

2. any target that doesnt want to wrun when a precond is false says if="" 
itself.

You are currently trying to define behaviour by ordering stuff in descendent
classes, and marking them conditional. Visualise the tasks as a directed acyclic
graph: everything which depends on another target should say what it depends on
either directly (depending on that target) or indirectly (depending on a target
that also depends on the target). Ant builds up a graph and then runs through
them : whenever it gets to execute a target it first looks at the current
if/unless state.

Your proposed policy 'dont execute predecessors if invalid' doesnt work in a
complex graph, as different children could have different policies. For example.
here we have two targets which are contradictory:
  <target name="if-run" depends="test" if="valid-precondition" >
  <target name="unless-run" depends="test" unless="valid-precondition" >
  <target name="inconsistent" depends="check-preconditions,if-run,unless-run" 

if you run "ant inconsistent" our interpretation of conditionalness is valid,
but yours would be inconsistent: would test run or not?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to