Ant

Tips Ant

Contributions ANT

ANT ne sait pas tout faire, pour rajouter à ANT des conditions if, ou des boucles for, voyez ant-contrib

Connaître l'OS sur lequel Ant s'exécute

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Si vous avez l'erreur Exception in thread "main" java.lang.OutOfMemoryError: Java heap space dans votre script Ant qui lance une tache java, rajoutez l'option de mémoire à votre jVM :

<java classname="com.google.gwt.dev.GWTCompiler" fork="true">
 <jvmarg value="-Xmx256M"/> 
 <arg line="-logLevel TRACE"/>
 <arg line="-style OBF"/>
 <arg line="-out build/gwtOutput"/>
 <arg value="com.placeoweb.testGwt.MyModule"/>
 <classpath>
   <path refid="base.path"/>
 </classpath>
</java>

Configuration pour exécuter ANT

Ant 1.7 et Java 1.6

set ANT_HOME=C:\apache-ant-1.7.1
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_13
set JETTY_HOME=C:\jetty-6.1.11
set PATH=%PATH%;%ANT_HOME%\bin;%JAVA_HOME%\bin
C:\>java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)

C:\>ant -version
Apache Ant version 1.7.1 compiled on June 27 2008

Ant 1.8 et Java 1.7

set ANT_HOME=D:\java\java.libs\apache-ant-1.8.2
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_02
set PATH=%PATH%;%ANT_HOME%\bin
C:\>ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
cd D:\workspaceEclipse37Indigo\HW\
D:
ant projectBuilder.xml
D:\workspaceEclipse37Indigo\HW>ant -buildfile projectBuilder.xml
Buildfile: D:\workspaceEclipse37Indigo\HW\projectBuilder.xml

makejar:
      [jar] Building jar: D:\workspaceEclipse37Indigo\HW\HelloWorld.jar

BUILD SUCCESSFUL
Total time: 3 seconds

Un autre cas, en erreur :

D:\workspaceEclipse37Indigo\GwtGoogleEclipse>ant -buildfile build.SmartGwt.xml
Buildfile: build.SmartGwt.xml does not exist!
Build failed

D:\workspaceEclipse37Indigo\GwtGoogleEclipse>ant -buildfile ant\build.SmartGwt.xml
Buildfile: D:\workspaceEclipse37Indigo\GwtGoogleEclipse\ant\build.SmartGwt.xml
  [taskdef] Could not load definitions from resource net/sf/antcontrib/antlib.xml. It could not be found.

BUILD FAILED
D:\workspaceEclipse37Indigo\GwtGoogleEclipse\ant\build.SmartGwt.xml:194: Problem: failed to create task or type if
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.


Total time: 1 second

Pour le problème du if, voyez comment le rajouter : ANT ajouter une condition if, then ou une boucle for avec ANT Contrib