Skip to Content

Installation

Add all required JARs to ANT's classpath

Before you can use ant4eclipse within your ant files, you have to add the org.ant4eclipse_<version>.jar JAR and all the JARs contained in the libs directory of the ant4eclipse distribution to the ant4eclipse classpath. This can be done in any of the following ways (take a look at the Ant manual for further information):

  • Installing ant4eclipse to Ant's lib-directories
    This is the easiest way of installing ant4eclipse. Simply copy the org.ant4eclipse_<version>.jar and the jars from the libs directory from the ant4eclipse distribution into the lib directory of your ant installation. An alternative approach is to copy the jar files to a directory called .ant/lib in your home directory. Both directories will be searched by Ant for libraries.
  • Using ant4eclipse from command line
    Add the org.ant4eclipse_<version>.jar and the jars from the libs directory from the ant4eclipse distribution to the classpath by using Ant's "-lib" command line argument:
     ant -lib /path/to/ant4eclipse/ant4eclipse.jar -lib /path/to/ant4eclipse/libs <other ant args>; 

Add ant4eclipse's tasks in your build file

After you have installed ant4eclipse, you can create a new build.xml file and add the tasks that come with ant4eclipse using Ant's taskdef task:

<project ...
         xmlns:ant4eclipse="antlib:org.ant4eclipse"
         xmlns:antcontrib="antlib:net.sf.antcontrib">

	<taskdef uri="antlib:net.sf.antcontrib"
	         resource="net/sf/antcontrib/antlib.xml" />

	<taskdef uri="antlib:org.ant4eclipse"
	         resource="org/ant4eclipse/antlib.xml" />
  ...

</project>

Note that you can not use the classpath argument of the taskdef task (otherwise the EJC compiler adapter won't work). You must make sure that ant4eclipse is included in ant's classpath as described above. If you want to edit your build files from Eclipse include the jars that comes with ant4eclipse in the Eclipse Ant runtime environment at Window -> Preferences -> Ant -> Runtime -> Global Entries. See the following screenshot for an example (Of course you have to adjust the path settings for your environment):