Comment exécuter Ant en ligne de commande

J'ai un fichier Ant, et j'essaie de l'exécuter en ligne de commande avec la commande suivante:

$ C:\Program Files (x86)\.....>ant -f C:\Silk4J\Automation\iControlSilk4J\build.xml

Mais rien ne se passe, et le résultat est:

BUILD SUCCESSFUL
Total time: 0 seconds

Ma variable d'environnement est correct.


Quel est le problème? Voici mon fichier de build:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. -->
<project basedir="." default="build" name="iControlSilk4J">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../../Program Files (x86)/Silk/SilkTest/eclipse"/>
<property name="junit.output.dir" value="junit"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.6"/>
<property name="source" value="1.6"/>
<path id="Silk Test JTF 13.5.0 Library.libraryclasspath">
<pathelement location="../../../Program Files (x86)/Silk/SilkTest/ng/JTF/silktest-jtf-nodeps.jar"/>
</path>
<path id="JUnit 4.libraryclasspath">
<pathelement location="${ECLIPSE_HOME}/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar"/>
<pathelement location="${ECLIPSE_HOME}/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
</path>
<path id="iControlSilk4J.classpath">
<pathelement location="bin"/>
<pathelement location="lib/apache-log4j.jar"/>
<pathelement location="lib/commons-io-2.4.jar"/>
<pathelement location="lib/commons-lang3-3.1.jar"/>
<pathelement location="lib/junit.jar"/>
<pathelement location="lib/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
<pathelement location="lib/silktest-jtf-nodeps.jar"/>
<path refid="Silk Test JTF 13.5.0 Library.libraryclasspath"/>
<path refid="JUnit 4.libraryclasspath"/>
<pathelement location="../../../Users/Admin/Desktop/java-mail-1.4.4.jar"/>
<pathelement location="../../../Users/Admin/Desktop/javax.activation.jar"/>
<pathelement location="lib/joda-time-2.3.jar"/>
</path>
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="bin"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects"/>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="iControlSilk4J.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
...
Heureux que vous avez collé le fichier build, mais vous avez omis certaines portions importantes. Notez que la balise projet a "construire" comme valeur par défaut. Pour vous aider, nous avons besoin de voir la définition de la cible nommée "construire".
Est-ce que vous parlez ?<projet basedir="." default="construire" name="iControlSilk4J"> ?!?
Oui, qui indique que le build cible est la valeur par défaut. Ce qui signifie que, quelque part dans votre fichier de build, il y a un <target name="build"/> tag nous avons besoin de voir.
Voici la définition de la cible dans la build.xml :
Voici la def. de la cible dans la build.xml : </target> <nom de la cible="AdministrationCtrl.PlayDensite2Service"> j'exécute cette commande : ...>ant AdministrationCtrl.PlayDensite2Service -f res. est : Buildfile: C:\Silk4J\Automation\iControlSilk4J\build.xml AdministrationCtrl.PlayDensite2Service: [junit] com en cours d'Exécution.miranda.icontrol.silk4j.l'installation.AdministrationCtrl [junit] exécution des Tests: 1, Failures: 0 Erreurs: 1, Ignorées: 0, Temps écoulé: 0 sec [junit] Test com.miranda.icontrol.silk4j.l'installation.AdministrationCtrl FAI LED CONSTRUIRE avec SUCCÈS temps Total: 1 seconde, Mais nothins exécuter ?!?

OriginalL'auteur Guylene Emond | 2013-09-26