Paramétrer un script Ant

Pour passer des paramètres à un script Ant :

  1. Ajouter une property au début du script : <property name="module" value="default"/>

  2. Fixer la valeur de cette property au moment de l'appel au script grâce à la syntaxe -Dproperty

Exemple

CTRL+C pour copier, CTRL+V pour coller
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!-- test.ant -->
3
<project>
4
    <property name="p">Default</property>
5
    <echo message="${p}"/>
6
</project>
7
<?xml version="1.0" encoding="UTF-8"?>
<!-- test.ant -->
<project>
    <property name="p">Default</property>
    <echo message="${p}"/>
</project>
CTRL+C pour copier, CTRL+V pour coller
1
$ ant -buildfile test.ant
2
Buildfile: /home/stc/Desktop/test.ant
3
     [echo] Default
4
$ ant -buildfile test.ant
Buildfile: /home/stc/Desktop/test.ant
     [echo] Default
CTRL+C pour copier, CTRL+V pour coller
1
$ ant -buildfile test.ant -Dp Hello
2
Buildfile: /home/stc/Desktop/test.ant
3
     [echo] Hello
4
$ ant -buildfile test.ant -Dp Hello
Buildfile: /home/stc/Desktop/test.ant
     [echo] Hello