2010-03-09 2 views
3

Imaginez ce que le code de build.xml:Comment puis-je exécuter une tâche de fourmi plus d'une fois?

<project name="test project"> 
    <target name="first"> 
     <echo>first</echo> 
    </target> 
    <target name="second" depends="first"> 
     <echo>second</echo> 
    </target> 
    <target name="third" depends="first,second"> 
     <echo>third</echo> 
    </target> 
</project> 

Que dois-je faire pour que quand je lance:

ant third 

je recevrais la sortie suivante:

first,first,second,third 

En d'autres termes, je voudrais que chaque dépendance s'exécute, qu'elle ait déjà fonctionné ou non.

Répondre

4

Ce n'est pas ce que sont les dépendances.

Si vous avez besoin de ce comportement, utilisez plutôt antcall ou MacroDef.

<project name="test project"> 
    <target name="first"> 
     <echo>first</echo> 
    </target> 
    <target name="second"> 
     <antcall target="first" /> 
     <echo>second</echo> 
    </target> 
    <target name="third"> 
     <antcall target="first" /> 
     <antcall target="second" /> 
     <echo>third</echo> 
    </target> 
</project> 

> ant third 
Buildfile: build.xml 

third: 

first: 
    [echo] first 

second: 

first: 
    [echo] first 
    [echo] second 
    [echo] third 

BUILD SUCCESSFUL 
Total time: 0 seconds 
Questions connexes