2010-10-25 13 views

risposta

19

Sì, le dipendenze vengono eseguite prima che le condizioni vengano valutate.


Dal Ant manual:

Importante: il se e meno attributi solo attivare o disattivare la porta a cui sono collegati. Non controllano se gli obiettivi che un obiettivo condizionale dipende o meno vengono eseguiti. In realtà, non vengono nemmeno valutati fino a quando l'obiettivo sta per essere eseguito e tutti i suoi predecessori sono già stati eseguiti.


Si potrebbe anche provato da soli:

<project> 
    <target name="-runTests"> 
    <property name="testSetupDone" value="foo"/> 
    </target> 
    <target name="runTestsIfTestSetupDone" if="testSetupDone" depends="-runTests"> 
    <echo>Test</echo> 
    </target> 
</project> 

che sto impostando la proprietà testSetupDone all'interno del bersaglio seconda, e l'uscita è:

Buildfile: build.xml 

-runTests: 

runTestsIfTestSetupDone: 
    [echo] Test 

BUILD SUCCESSFUL 
Total time: 0 seconds 

target -runTests è eseguito, anche se testSetupDone non è impostato in questo momento e runTestsIfTestSetupDone viene eseguito dopo ards, quindi depend viene valutato prima delloif (utilizzando Ant 1.7.0).

4

Da the docs:

Ant tries to execute the targets in the depends attribute in the order they 
appear (from left to right). Keep in mind that it is possible that a 
target can get executed earlier when an earlier target depends on it: 

<target name="A"/> 
<target name="B" depends="A"/> 
<target name="C" depends="B"/> 
<target name="D" depends="C,B,A"/> 

Suppose we want to execute target D. From its depends attribute, 
you might think that first target C, then B and then A is executed. 
Wrong! C depends on B, and B depends on A, 
so first A is executed, then B, then C, and finally D. 

Call-Graph: A --> B --> C --> D 
+3

Questa non è una risposta alla domanda che è stato chiesto. –

Problemi correlati