For CDH, follow these steps: Install ANT in /home/ant: tar -zxvf apache-ant-1.8.2-bin.tar.gz -C /home/ant/ Install Maven in /home/mvn: tar -zxvf apache-maven-3.0.4-bin.tar.gz -C /home/mvn. Apache-ant-1.9.15-bin.zip main category: Programming. Developer: Apache Software Foundation visit homepage. Top alternatives FREE Google Map GPS Cell Phone Tracker. I switched from CentOS 6.3 to Fedora 17, and now I have all the latest java packages. I'm running apache tomcat 1.7 and ant 1.8 from rpm packages without problems now. – BullShark Apr 23 '13 at 22:43.
- Ant Tutorial
- Ant Useful Resources
- Selected Reading
Apache Ant Ant is distributed under the Apache Software License, a fully-fledged open source license certified by the open source initiative.
The latest Apache Ant version, including its full-source code, class files, and documentation can be found at http://ant.apache.org.
Installing Apache Ant
It is assumed that you have already downloaded and installed Java Development Kit (JDK) on your computer. If not, please follow the instructions here.
Ensure that the JAVA_HOME environment variable is set to the folder where your JDK is installed.
Download the binaries from https://ant.apache.org
Unzip the zip file to a convenient location c:folder. using Winzip, winRAR, 7-zip or similar tools.
Create a new environment variable called ANT_HOME that points to the Ant installation folder, in this case c:apache-ant-1.8.2-bin folder.
Append the path to the Apache Ant batch file to the PATH environment variable. In our case this would be the c:apache-ant-1.8.2-binbin folder.
Verifying Apache Ant Installation
To verify the successful installation of Apache Ant on your computer, type ant on your command prompt.
You should see an output similar to −
If you do not see the above output, then please verify that you have followed the installation steps properly.
Installing Eclipse
This tutorial also covers integration of Ant with Eclipse IDE. Hence, if you have not installed Eclipse already, please download and install Eclipse
To install Eclipse −
Download the latest Eclipse binaries from www.eclipse.org
Unzip the Eclipse binaries to a convenient location, say c:folder
Run Eclipse from c:eclipseeclipse.exe
Getting Apache Ant
The Short Story
To get up and running with the binary distribution of Ant quickly, follow these steps:
- Make sure you have a Java environment installed. See System Requirements fordetails.
- Download Ant. See Binary Distribution for details.
- Uncompress the downloaded file into a directory.
- Set environmental variables:
JAVA_HOME
to your Java environment,ANT_HOME
to the directoryyou uncompressed Ant to, and add ${ANT_HOME}/bin (Unix) or %ANT_HOME%/bin (Windows) toyourPATH
. See Setup for details. - Optionally, from the
ANT_HOME
directory run ant -f fetch.xml -Ddest=system to get thelibrary dependencies of most of the Ant tasks that require them. If you don't do this, many of the dependent Ant taskswill not be available. See Optional Tasks for details and other options forthe -Ddest parameter. - Optionally, add any desired Antlibs. See AntLibraries for a list.
Note that the links in the list above will give more details about each of the steps, should you need them. Or you canjust continue reading the rest of this document.
The short story for working with the Ant source code (not needed if you are working with the binary distribution) is:
- Get the source code. See Source Distribution for details.
- Build Ant. See Building Ant for details.
For the full story, continue reading.
Binary Distribution
The latest stable version of Ant is available from the Ant web page https://ant.apache.org/
The binary distribution of Ant is available as 3 different archives
- .zip—Recommended compression format for Windows, can also be used on other platforms. Supportedby many programs and some operating systems natively.
- .tar.gz—Using the tar program to gather files together, and gzip to compress and uncompress.
- .tar.bz2—Using the tar program to gather files together, and bzip2 to compress and uncompress.
Choose the format that is best supported for your platform.
Binary RPM Package
Consult the jpackage section below.
Bundled in IDEs
All the main Java IDEs ship with Ant, products such as Eclipse, NetBeans and IntelliJ IDEA. If you install Ant this wayyou usually get the most recent release of Ant at the time the IDE was released. Some of the IDEs (Eclipse and NetBeansin particular) ship with extra tasks that only work if IDE-specific tools are on Ant's path. To use these oncommand-line versions of Ant, the relevant JARs need to be added to the command-line Ant as extra libraries/tasks. Notethat if it is an IDE task or extension that is not behaving, the Ant team is unable to field bug reports. Try the IDEmailing lists first, who will cross-file bugs if appropriate.
IDEs can invariably be pointed at different Ant installations. This lets developers upgrade to a new release of Ant, andeliminate inconsistencies between command-line and IDE Ant.
Bundled in Java Applications
Many Java applications, most particularly application servers, ship with a version of Ant. These are primarily forinternal use by the application, using the Java APIs to delegate tasks such as JSP page compilation to the Antruntime. Such distributions are usually unsupported by everyone. Particularly troublesome are those products that notonly ship with their own Ant release, they add their own version of ANT.BAT or ant.sh tothe PATH
. If Ant starts behaving weirdly after installing something, trythe diagnostics advice.
Source Distribution
If you prefer the source distribution, you can download the source for the latest Ant releasefrom https://ant.apache.org/srcdownload.cgi.
If you prefer the leading-edge code, you can access the code as it is being developed via Git. The Ant website hasdetails on accessing Git. All bug fixes will go in againstthe HEAD of the source tree, and the first response to many bug reports will be 'have you tried the latestversion'. Don't be afraid to download and build a prerelease distribution, as everything other than new features areusually stable.
See the section Building Ant on how to build Ant from the source code. You can also accessthe Ant Git repository on-line.
Archive Download Area Layout
Older versions of Ant are available in the archives at https://archive.apache.org/dist/ant/. The files are organized as follows.
Filename or Path | Description |
---|---|
KEYS | PGP keyfile. It contains the PGP keys of Ant developers so you can 'trust' the distribution. |
RELEASE-NOTES-{version}.html | Release notes of the given version in HTML format. When upgrading your Ant installation you should have a look at the Changes that could break older environments section. |
ant-current-bin.zip | ZIP archive containing the compiled version of Ant in the last released version. It is recommended that you do not download the latest version this way, as the standard way of downloading described above will redirect you to a mirror closer to you, thus making the download faster for you and reducing the load on Apache servers. |
ant-current-src.zip | ZIP archive containing the sources of Ant. If you have this you can compile Ant. If you do not have the required dependencies, the classes depending on them are just not built. Again, it is preferred to use the standard way of getting the source package described above to make your download quicker and to reduce the load on Apache servers. |
ant-current-*.asc | Security file for checking the correctness of the zip file. This one is the PGP signature. |
ant-current-*.md5 | Security file for checking the correctness of the zip file. This one is the MD5 checksum. |
ant-current-*.sha1 | Security file for checking the correctness of the zip file. This one is the SHA1 checksum. |
ant-current-*.sha512 | Security file for checking the correctness of the zip file. This one is the SHA512 checksum. |
antlibs/ | This directory holds the Antlibs that are made of available by the Apache Ant project. Antlibs are bundles of Ant tasks that are not delivered as part of the Ant core but are available as optional downloads. |
binaries/ | The binaries directory holds specific Ant releases bundled in both ZIP and tar.gz archive formats. The named releases are in contrast to the ant-current-bin.zip file in the parent directory, which is always guaranteed to be the most current release of Ant. |
common/ | The common directory holds various files, such as the Apache License file that Ant is licensed under, that people may wish to examine without having to download the whole Ant distribution. |
source/ | The source directory holds the source code for specific Ant releases bundled in both ZIP and tar.gz archive formats. The named releases are in contrast to the ant-current-src.zip file in the parent directory, which is always guaranteed to hold the source code for the most current release of Ant. |
System Requirements
Ant has been used successfully on many platforms, including Linux, commercial flavours of Unix such as Solaris andHP-UX, macOS, Windows NT descendants, OS/2 Warp, Novell Netware 6, OpenVMS. The platforms used most for development are,in no particular order, Linux, macOS, Microsoft Windows and Unix; these are therefore that platforms that tend to workbest. Since Ant 1.7, Windows 9x is no longer supported.
For the current version of Ant (1.10), you will also need a JDK installed on your system, version 8 or later required.The more up-to-date the version of Java, the more Ant tasks you get.
Note: If a JDK is not present, only the runtime (JRE), then many tasks will not work.
Note: Ant 1.9.* works with JDK 1.5 and higher, Ant 1.8.* works with JDK 1.4 and higher, Ant 1.7.* works with JDK 1.3 and higher, Ant 1.6.* works with JDK 1.2 and higher, Ant 1.2 to Ant 1.5.* work with JDK 1.1 and higher.
Open Source Java Runtimes
The Ant team strongly supports users running Ant on OpenJDK andother open source Java runtimes, and so strives to have a product that works well on those platforms.
Installing Ant
The binary distribution of Ant consists of the following directory layout: Madura dictionary offline.
Only the bin and lib directories are required to run Ant.
To install Ant, choose a directory and copy the distribution files there. This directory will be knownas ANT_HOME
.
Windows 95, Windows 98 & Windows ME Note
Note that current releases of Ant no longer support these systems. If you are using an older version of Ant, however, the script used to launch Ant will have problems if ANT_HOME
is a long filename (i.e. a filename which is not of the format known as '8.3'). This is due to limitations in the OS's handling of the 'for'
batch file statement. It is recommended, therefore, that Ant be installed in a short, 8.3 path, such as C:Ant.
On these systems you will also need to configure more environment space to cater for the environment variables used in the Ant launch script. To do this, you will need to add or update the following line in the config.sys file
Setup
Before you can run Ant there is some additional setup you will need to do unless you are installingthe RPM Version from jpackage.org:
- Add the bin directory to your path.
- Set the
ANT_HOME
environment variable to the directory where you installed Ant. On some operatingsystems, Ant's startup scripts can guessANT_HOME
(Unix dialects and Windows NT descendants), but it isbetter to not rely on this behavior. - Optionally, set the
JAVA_HOME
environment variable (see the Advanced sectionbelow). This should be set to the directory where your JDK is installed.
Operating System-specific instructions for doing this from the command line are inthe Windows, Linux/Unix (bash), and Linux/Unix (csh)sections. Note that using this method, the settings will only be valid for the command line session you run them in.
Note: Do not install Ant's ant.jar file into the lib/ext directory of theJDK/JRE. Ant is an application, whilst the extension directory is intended for JDK extensions. In particular there aresecurity restrictions on the classes which may be loaded by an extension.
Windows Note
The ant.bat script makes use of three environment variables—ANT_HOME
, CLASSPATH
and JAVA_HOME
. Ensure that ANT_HOME
and JAVA_HOME
variables are set, and that they do not have quotes (either ' or ') and they do not end with or with /. CLASSPATH
should be unset or empty.
Check Installation
You can check the basic installation with opening a new shell and typing ant. You should get a message likethis
So Ant works. This message is there because you need to write a buildfile for your project. With a ant-version you should get an output like
If this does not work, ensure your environment variables are set right. E.g., on Windows, they must resolve to:
- required:
%ANT_HOME%binant.bat
- optional:
%JAVA_HOME%binjava.exe
- required:
%PATH%=..maybe-other-entries..;%ANT_HOME%bin;..maybe-other-entries..
ANT_HOME
is used by the launcher script for finding the libraries. JAVA_HOME
is used by thelauncher for finding the JDK/JRE to use. (JDK is recommended as some tasks require the Java tools.) If not set, thelauncher tries to find one via the %PATH%
environment variable. PATH
is set for userconvenience. With that set you can just start ant instead of alwaystyping the/complete/path/to/your/ant/installation/bin/ant.
Optional Tasks
Ant supports a number of optional tasks. An optional task is a task which typically requires an external library tofunction. The optional tasks are packaged together with the core Ant tasks.
The external libraries required by each of the optional tasks is detailed in the LibraryDependencies section. These external libraries must be added to Ant's classpath, in any of the following ways:
In
ANT_HOME/lib
. This makes the JAR files available to all Ant users and builds.In
${user.home}/.ant/lib
(since Ant 1.6). This allows different users to add new libraries toAnt. All JAR files added to this directory are available to command-line Ant.On the command line with a -lib parameter. This lets you add new JAR files on a case-by-case basis.
In the
CLASSPATH
environment variable. Avoid this; it makes the JAR files visible to all Javaapplications, and causes no end of support calls. See below for details.In some
accepted by the task itself. Since Ant 1.7.0, you can runthe
task without junit.jar in Ant's own classpath, so long as it is included(along with your program and tests) in the classpath passed when running the task.
Where possible, this option is generally to be preferred, as the Ant script itself can determine the best path to loadthe library from: via relative path from the basedir (if you keep the library under version control with your project),according to Ant properties, environment variables, Ivy downloads, whatever you like.
If you are using the binary distribution of Ant, or if you are working from source code, you can easily gather most ofthe dependencies and install them for use with your Ant tasks. In your ANT_HOME
directory you should see afile called fetch.xml. This is an Ant script that you can run to install almost all the dependencies thatthe optional Ant tasks need.
To do so, change to the ANT_HOME
directory and execute the command:
where option is one of the following, as described above:
system
—store in Ant's lib directory (Recommended)user
—store in the user's home directoryoptional
—store in Ant's source code lib/optional directory, used when building Antsource code
You may also need to set proxy settings. See the Proxy Settings section for details.
Note that not all dependencies are gathered using fetch.xml. Tasks that depend on commercial software, inparticular, will require you to have the commercial software installed in order to be used.
The Apache Ant Project also provides additional tasks and types that are available as separately downloaded AntLibraries. You can see the the list of available Antlibs at the Ant Libraries page.
You can also find tasks and types provided by third-party projects at the External Tools and Tasks page.
IDEs have different ways of adding external JAR files and third-party tasks to Ant. Usually it is done by someconfiguration dialog. Sometimes JAR files added to a project are automatically added to Ant's classpath.
The CLASSPATH
Environment Variable
The CLASSPATH
environment variable is a source of many Ant support queries. As the round trip time fordiagnosis on the Ant user mailing list can be slow, and because filing bug reports complaining about 'ant.bat' notworking will be rejected by the developers as WORKSFORME 'this is a configuration problem, not a bug', you can saveyourself a lot of time and frustration by following some simple steps.
- Do not ever set
CLASSPATH
. Ant does not need it, it only causes confusion and breaks things. - If you ignore the previous rule, do not ever, ever, put quotes in the
CLASSPATH
, even if there is aspace in a directory. This will break Ant, and it is not needed. - If you ignore the first rule, do not ever, ever, have a trailing backslash in a
CLASSPATH
, as it breaksAnt's ability to quote the string. Again, this is not needed for the correct operation of theCLASSPATH
environment variable, even if a DOS directory is to be added to the path. - You can stop Ant using the
CLASSPATH
environment variable by setting the -noclasspathoption on the command line. This is an easy way to test for classpath-related problems.
The usual symptom of CLASSPATH
problems is that Ant will not run with some error about not being able tofind org.apache.tools.ant.launch.Launcher
, or, if you have got the quotes/backslashes wrong,some very weird Java startup error. To see if this is the case, run ant -noclasspath or unsetthe CLASSPATH
environment variable.
You can also make your Ant script reject this environment variable just by placing the following at the top of thescript (or in an init target):
Proxy Configuration
Many Ant built-in and third-party tasks use network connections to retrieve files from HTTP servers. If you are behind afirewall with a proxy server, then Ant needs to be configured with the proxy. Here are the different ways to dothis.
- With Java 5 or above
When you run Ant on Java 5 or above, you could try to use the automatic proxy setup mechanismwith -autoproxy.
- With explicit JVM properties.
These are documented in Java's Networking Properties, and control the proxy behaviour of the entire JVM. To set them in Ant,declare them in the
ANT_OPTS
environment variable. This is the best option for a non-mobile system. For alaptop, you have to change these settings as you roam. To setANT_OPTS
:For csh/tcsh:
For bash:
For Windows, set the environment variable in the appropriate dialog box and open a new console or, by hand
- In the build file itself
If you are writing a build file that is always to be used behind the firewall,the setproxy task lets you configure the proxy (which it does by setting the JVMproperties). If you do this, we strongly recommend using Ant properties to define the proxy host, port, etc, so thatindividuals can override the defaults.
The Ant team acknowledges that this is unsatisfactory. Until the JVM automatic proxy setup works properly everywhere,explicit JVM options via ANT_ARGS
are probably the best solution. Setting properties on Ant's command linedo not work, because those are Ant properties being set, not JVM options. This means the following does not setup the command line:
All it does is set up two Ant properties.
One other trouble spot with proxies is with authenticating proxies. Ant cannot go beyond what the JVM does here, and asit is very hard to remotely diagnose, test and fix proxy-related problems, users who work behind a secure proxy willhave to spend much time configuring the JVM properties until they are happy.
Windows and OS/2
Assume Ant is installed in c:ant. The following sets up theenvironment:
Linux/Unix (bash)
Assume Ant is installed in /usr/local/ant. The following sets upthe environment:
Linux/Unix (csh)
Having a symbolic link set up to point to the JVM/JDK version makes updates more seamless.
RPM version from jpackage.org
Apache Ant Ant is distributed under the Apache Software License, a fully-fledged open source license certified by the open source initiative.
The latest Apache Ant version, including its full-source code, class files, and documentation can be found at http://ant.apache.org.
Installing Apache Ant
It is assumed that you have already downloaded and installed Java Development Kit (JDK) on your computer. If not, please follow the instructions here.
Ensure that the JAVA_HOME environment variable is set to the folder where your JDK is installed.
Download the binaries from https://ant.apache.org
Unzip the zip file to a convenient location c:folder. using Winzip, winRAR, 7-zip or similar tools.
Create a new environment variable called ANT_HOME that points to the Ant installation folder, in this case c:apache-ant-1.8.2-bin folder.
Append the path to the Apache Ant batch file to the PATH environment variable. In our case this would be the c:apache-ant-1.8.2-binbin folder.
Verifying Apache Ant Installation
To verify the successful installation of Apache Ant on your computer, type ant on your command prompt.
You should see an output similar to −
If you do not see the above output, then please verify that you have followed the installation steps properly.
Installing Eclipse
This tutorial also covers integration of Ant with Eclipse IDE. Hence, if you have not installed Eclipse already, please download and install Eclipse
To install Eclipse −
Download the latest Eclipse binaries from www.eclipse.org
Unzip the Eclipse binaries to a convenient location, say c:folder
Run Eclipse from c:eclipseeclipse.exe
Getting Apache Ant
The Short Story
To get up and running with the binary distribution of Ant quickly, follow these steps:
- Make sure you have a Java environment installed. See System Requirements fordetails.
- Download Ant. See Binary Distribution for details.
- Uncompress the downloaded file into a directory.
- Set environmental variables:
JAVA_HOME
to your Java environment,ANT_HOME
to the directoryyou uncompressed Ant to, and add ${ANT_HOME}/bin (Unix) or %ANT_HOME%/bin (Windows) toyourPATH
. See Setup for details. - Optionally, from the
ANT_HOME
directory run ant -f fetch.xml -Ddest=system to get thelibrary dependencies of most of the Ant tasks that require them. If you don't do this, many of the dependent Ant taskswill not be available. See Optional Tasks for details and other options forthe -Ddest parameter. - Optionally, add any desired Antlibs. See AntLibraries for a list.
Note that the links in the list above will give more details about each of the steps, should you need them. Or you canjust continue reading the rest of this document.
The short story for working with the Ant source code (not needed if you are working with the binary distribution) is:
- Get the source code. See Source Distribution for details.
- Build Ant. See Building Ant for details.
For the full story, continue reading.
Binary Distribution
The latest stable version of Ant is available from the Ant web page https://ant.apache.org/
The binary distribution of Ant is available as 3 different archives
- .zip—Recommended compression format for Windows, can also be used on other platforms. Supportedby many programs and some operating systems natively.
- .tar.gz—Using the tar program to gather files together, and gzip to compress and uncompress.
- .tar.bz2—Using the tar program to gather files together, and bzip2 to compress and uncompress.
Choose the format that is best supported for your platform.
Binary RPM Package
Consult the jpackage section below.
Bundled in IDEs
All the main Java IDEs ship with Ant, products such as Eclipse, NetBeans and IntelliJ IDEA. If you install Ant this wayyou usually get the most recent release of Ant at the time the IDE was released. Some of the IDEs (Eclipse and NetBeansin particular) ship with extra tasks that only work if IDE-specific tools are on Ant's path. To use these oncommand-line versions of Ant, the relevant JARs need to be added to the command-line Ant as extra libraries/tasks. Notethat if it is an IDE task or extension that is not behaving, the Ant team is unable to field bug reports. Try the IDEmailing lists first, who will cross-file bugs if appropriate.
IDEs can invariably be pointed at different Ant installations. This lets developers upgrade to a new release of Ant, andeliminate inconsistencies between command-line and IDE Ant.
Bundled in Java Applications
Many Java applications, most particularly application servers, ship with a version of Ant. These are primarily forinternal use by the application, using the Java APIs to delegate tasks such as JSP page compilation to the Antruntime. Such distributions are usually unsupported by everyone. Particularly troublesome are those products that notonly ship with their own Ant release, they add their own version of ANT.BAT or ant.sh tothe PATH
. If Ant starts behaving weirdly after installing something, trythe diagnostics advice.
Source Distribution
If you prefer the source distribution, you can download the source for the latest Ant releasefrom https://ant.apache.org/srcdownload.cgi.
If you prefer the leading-edge code, you can access the code as it is being developed via Git. The Ant website hasdetails on accessing Git. All bug fixes will go in againstthe HEAD of the source tree, and the first response to many bug reports will be 'have you tried the latestversion'. Don't be afraid to download and build a prerelease distribution, as everything other than new features areusually stable.
See the section Building Ant on how to build Ant from the source code. You can also accessthe Ant Git repository on-line.
Archive Download Area Layout
Older versions of Ant are available in the archives at https://archive.apache.org/dist/ant/. The files are organized as follows.
Filename or Path | Description |
---|---|
KEYS | PGP keyfile. It contains the PGP keys of Ant developers so you can 'trust' the distribution. |
RELEASE-NOTES-{version}.html | Release notes of the given version in HTML format. When upgrading your Ant installation you should have a look at the Changes that could break older environments section. |
ant-current-bin.zip | ZIP archive containing the compiled version of Ant in the last released version. It is recommended that you do not download the latest version this way, as the standard way of downloading described above will redirect you to a mirror closer to you, thus making the download faster for you and reducing the load on Apache servers. |
ant-current-src.zip | ZIP archive containing the sources of Ant. If you have this you can compile Ant. If you do not have the required dependencies, the classes depending on them are just not built. Again, it is preferred to use the standard way of getting the source package described above to make your download quicker and to reduce the load on Apache servers. |
ant-current-*.asc | Security file for checking the correctness of the zip file. This one is the PGP signature. |
ant-current-*.md5 | Security file for checking the correctness of the zip file. This one is the MD5 checksum. |
ant-current-*.sha1 | Security file for checking the correctness of the zip file. This one is the SHA1 checksum. |
ant-current-*.sha512 | Security file for checking the correctness of the zip file. This one is the SHA512 checksum. |
antlibs/ | This directory holds the Antlibs that are made of available by the Apache Ant project. Antlibs are bundles of Ant tasks that are not delivered as part of the Ant core but are available as optional downloads. |
binaries/ | The binaries directory holds specific Ant releases bundled in both ZIP and tar.gz archive formats. The named releases are in contrast to the ant-current-bin.zip file in the parent directory, which is always guaranteed to be the most current release of Ant. |
common/ | The common directory holds various files, such as the Apache License file that Ant is licensed under, that people may wish to examine without having to download the whole Ant distribution. |
source/ | The source directory holds the source code for specific Ant releases bundled in both ZIP and tar.gz archive formats. The named releases are in contrast to the ant-current-src.zip file in the parent directory, which is always guaranteed to hold the source code for the most current release of Ant. |
System Requirements
Ant has been used successfully on many platforms, including Linux, commercial flavours of Unix such as Solaris andHP-UX, macOS, Windows NT descendants, OS/2 Warp, Novell Netware 6, OpenVMS. The platforms used most for development are,in no particular order, Linux, macOS, Microsoft Windows and Unix; these are therefore that platforms that tend to workbest. Since Ant 1.7, Windows 9x is no longer supported.
For the current version of Ant (1.10), you will also need a JDK installed on your system, version 8 or later required.The more up-to-date the version of Java, the more Ant tasks you get.
Note: If a JDK is not present, only the runtime (JRE), then many tasks will not work.
Note: Ant 1.9.* works with JDK 1.5 and higher, Ant 1.8.* works with JDK 1.4 and higher, Ant 1.7.* works with JDK 1.3 and higher, Ant 1.6.* works with JDK 1.2 and higher, Ant 1.2 to Ant 1.5.* work with JDK 1.1 and higher.
Open Source Java Runtimes
The Ant team strongly supports users running Ant on OpenJDK andother open source Java runtimes, and so strives to have a product that works well on those platforms.
Installing Ant
The binary distribution of Ant consists of the following directory layout: Madura dictionary offline.
Only the bin and lib directories are required to run Ant.
To install Ant, choose a directory and copy the distribution files there. This directory will be knownas ANT_HOME
.
Windows 95, Windows 98 & Windows ME Note
Note that current releases of Ant no longer support these systems. If you are using an older version of Ant, however, the script used to launch Ant will have problems if ANT_HOME
is a long filename (i.e. a filename which is not of the format known as '8.3'). This is due to limitations in the OS's handling of the 'for'
batch file statement. It is recommended, therefore, that Ant be installed in a short, 8.3 path, such as C:Ant.
On these systems you will also need to configure more environment space to cater for the environment variables used in the Ant launch script. To do this, you will need to add or update the following line in the config.sys file
Setup
Before you can run Ant there is some additional setup you will need to do unless you are installingthe RPM Version from jpackage.org:
- Add the bin directory to your path.
- Set the
ANT_HOME
environment variable to the directory where you installed Ant. On some operatingsystems, Ant's startup scripts can guessANT_HOME
(Unix dialects and Windows NT descendants), but it isbetter to not rely on this behavior. - Optionally, set the
JAVA_HOME
environment variable (see the Advanced sectionbelow). This should be set to the directory where your JDK is installed.
Operating System-specific instructions for doing this from the command line are inthe Windows, Linux/Unix (bash), and Linux/Unix (csh)sections. Note that using this method, the settings will only be valid for the command line session you run them in.
Note: Do not install Ant's ant.jar file into the lib/ext directory of theJDK/JRE. Ant is an application, whilst the extension directory is intended for JDK extensions. In particular there aresecurity restrictions on the classes which may be loaded by an extension.
Windows Note
The ant.bat script makes use of three environment variables—ANT_HOME
, CLASSPATH
and JAVA_HOME
. Ensure that ANT_HOME
and JAVA_HOME
variables are set, and that they do not have quotes (either ' or ') and they do not end with or with /. CLASSPATH
should be unset or empty.
Check Installation
You can check the basic installation with opening a new shell and typing ant. You should get a message likethis
So Ant works. This message is there because you need to write a buildfile for your project. With a ant-version you should get an output like
If this does not work, ensure your environment variables are set right. E.g., on Windows, they must resolve to:
- required:
%ANT_HOME%binant.bat
- optional:
%JAVA_HOME%binjava.exe
- required:
%PATH%=..maybe-other-entries..;%ANT_HOME%bin;..maybe-other-entries..
ANT_HOME
is used by the launcher script for finding the libraries. JAVA_HOME
is used by thelauncher for finding the JDK/JRE to use. (JDK is recommended as some tasks require the Java tools.) If not set, thelauncher tries to find one via the %PATH%
environment variable. PATH
is set for userconvenience. With that set you can just start ant instead of alwaystyping the/complete/path/to/your/ant/installation/bin/ant.
Optional Tasks
Ant supports a number of optional tasks. An optional task is a task which typically requires an external library tofunction. The optional tasks are packaged together with the core Ant tasks.
The external libraries required by each of the optional tasks is detailed in the LibraryDependencies section. These external libraries must be added to Ant's classpath, in any of the following ways:
In
ANT_HOME/lib
. This makes the JAR files available to all Ant users and builds.In
${user.home}/.ant/lib
(since Ant 1.6). This allows different users to add new libraries toAnt. All JAR files added to this directory are available to command-line Ant.On the command line with a -lib parameter. This lets you add new JAR files on a case-by-case basis.
In the
CLASSPATH
environment variable. Avoid this; it makes the JAR files visible to all Javaapplications, and causes no end of support calls. See below for details.In some
accepted by the task itself. Since Ant 1.7.0, you can runthe
task without junit.jar in Ant's own classpath, so long as it is included(along with your program and tests) in the classpath passed when running the task.
Where possible, this option is generally to be preferred, as the Ant script itself can determine the best path to loadthe library from: via relative path from the basedir (if you keep the library under version control with your project),according to Ant properties, environment variables, Ivy downloads, whatever you like.
If you are using the binary distribution of Ant, or if you are working from source code, you can easily gather most ofthe dependencies and install them for use with your Ant tasks. In your ANT_HOME
directory you should see afile called fetch.xml. This is an Ant script that you can run to install almost all the dependencies thatthe optional Ant tasks need.
To do so, change to the ANT_HOME
directory and execute the command:
where option is one of the following, as described above:
system
—store in Ant's lib directory (Recommended)user
—store in the user's home directoryoptional
—store in Ant's source code lib/optional directory, used when building Antsource code
You may also need to set proxy settings. See the Proxy Settings section for details.
Note that not all dependencies are gathered using fetch.xml. Tasks that depend on commercial software, inparticular, will require you to have the commercial software installed in order to be used.
The Apache Ant Project also provides additional tasks and types that are available as separately downloaded AntLibraries. You can see the the list of available Antlibs at the Ant Libraries page.
You can also find tasks and types provided by third-party projects at the External Tools and Tasks page.
IDEs have different ways of adding external JAR files and third-party tasks to Ant. Usually it is done by someconfiguration dialog. Sometimes JAR files added to a project are automatically added to Ant's classpath.
The CLASSPATH
Environment Variable
The CLASSPATH
environment variable is a source of many Ant support queries. As the round trip time fordiagnosis on the Ant user mailing list can be slow, and because filing bug reports complaining about 'ant.bat' notworking will be rejected by the developers as WORKSFORME 'this is a configuration problem, not a bug', you can saveyourself a lot of time and frustration by following some simple steps.
- Do not ever set
CLASSPATH
. Ant does not need it, it only causes confusion and breaks things. - If you ignore the previous rule, do not ever, ever, put quotes in the
CLASSPATH
, even if there is aspace in a directory. This will break Ant, and it is not needed. - If you ignore the first rule, do not ever, ever, have a trailing backslash in a
CLASSPATH
, as it breaksAnt's ability to quote the string. Again, this is not needed for the correct operation of theCLASSPATH
environment variable, even if a DOS directory is to be added to the path. - You can stop Ant using the
CLASSPATH
environment variable by setting the -noclasspathoption on the command line. This is an easy way to test for classpath-related problems.
The usual symptom of CLASSPATH
problems is that Ant will not run with some error about not being able tofind org.apache.tools.ant.launch.Launcher
, or, if you have got the quotes/backslashes wrong,some very weird Java startup error. To see if this is the case, run ant -noclasspath or unsetthe CLASSPATH
environment variable.
You can also make your Ant script reject this environment variable just by placing the following at the top of thescript (or in an init target):
Proxy Configuration
Many Ant built-in and third-party tasks use network connections to retrieve files from HTTP servers. If you are behind afirewall with a proxy server, then Ant needs to be configured with the proxy. Here are the different ways to dothis.
- With Java 5 or above
When you run Ant on Java 5 or above, you could try to use the automatic proxy setup mechanismwith -autoproxy.
- With explicit JVM properties.
These are documented in Java's Networking Properties, and control the proxy behaviour of the entire JVM. To set them in Ant,declare them in the
ANT_OPTS
environment variable. This is the best option for a non-mobile system. For alaptop, you have to change these settings as you roam. To setANT_OPTS
:For csh/tcsh:
For bash:
For Windows, set the environment variable in the appropriate dialog box and open a new console or, by hand
- In the build file itself
If you are writing a build file that is always to be used behind the firewall,the setproxy task lets you configure the proxy (which it does by setting the JVMproperties). If you do this, we strongly recommend using Ant properties to define the proxy host, port, etc, so thatindividuals can override the defaults.
The Ant team acknowledges that this is unsatisfactory. Until the JVM automatic proxy setup works properly everywhere,explicit JVM options via ANT_ARGS
are probably the best solution. Setting properties on Ant's command linedo not work, because those are Ant properties being set, not JVM options. This means the following does not setup the command line:
All it does is set up two Ant properties.
One other trouble spot with proxies is with authenticating proxies. Ant cannot go beyond what the JVM does here, and asit is very hard to remotely diagnose, test and fix proxy-related problems, users who work behind a secure proxy willhave to spend much time configuring the JVM properties until they are happy.
Windows and OS/2
Assume Ant is installed in c:ant. The following sets up theenvironment:
Linux/Unix (bash)
Assume Ant is installed in /usr/local/ant. The following sets upthe environment:
Linux/Unix (csh)
Having a symbolic link set up to point to the JVM/JDK version makes updates more seamless.
RPM version from jpackage.org
The JPackage project distributes an RPM version of Ant. With thisversion, it is not necessary to set JAVA_HOME
or ANT_HOME
environment variables and the RPMinstaller will correctly place the ant executable on your path.
Note: Since Ant 1.7.0, if the ANT_HOME
environment variable is set, the JPackagedistribution will be ignored.
Optional JARs for the JPackage version are handled in two ways. The easiest, and best way is to get these externallibraries from JPackage if JPackage has them available. (Note: for each such library, you will have to get both theexternal package itself (e.g. oro-2.0.8-2jpp.noarch.rpm) and the small library that links Ant and theexternal package (e.g. ant-apache-oro-1.6.2-3jpp.noarch.rpm).
However, JPackage does not package proprietary software, and since some of the optional packages depend on proprietaryJARs, they must be handled as follows. This may violate the spirit of JPackage, but it is necessary if you need theseproprietary packages. For example, suppose you want to install support for NetRexx, which JPackage does not support:
- Decide where you want to deploy the extra JARs. One option is in
$ANT_HOME/lib
, which, for JPackage isusually /usr/share/ant/lib. Another, less messy option is to create an .ant/lib subdirectoryof your home directory and place your non-JPackage Ant JARs there, thereby avoiding mixing JPackage libraries withnon-JPackage stuff in the same folder. More information on where Ant finds its libraries isavailable here - Download a non-JPackage binary distribution from the regular Apache Ant site
- Unzip or untar the distribution into a temporary directory
- Copy the linking JAR, in this case ant-jai.jar, into the library directory you chose in step 1above.
- Copy the proprietary JAR itself into the same directory.
Advanced
There are many different ways to run Ant. What you need is at least the following:
- The classpath for Ant must contain ant.jar and any JARs/classes needed for your chosen JAXP-compliantXML parser.
- When you need JDK functionality (such as for the javac task orthe rmic task), then tools.jar must be added. The scripts supplied with Ant,in the bin directory, will add the required JDK classes automatically, if the
JAVA_HOME
environment variable is set. - When you are executing platform-specific applications, such as the exec task orthe cvs task, the property
ant.home
must be set to the directory containingwhere you installed Ant. Again this is set by the Ant scripts to the value of theANT_HOME
environmentvariable.
ANT_OPTS
environment variable which can be used to supplyextra options to Ant. Some of the scripts also read in an extra script stored in the users home directory, which can beused to set such options. Look at the source for your platform's invocation script for details.Building Ant
To build Ant from source, you can either install the Ant source distribution or clone the Ant repository from Git. SeeSource Distribution for details.
Once you have installed the source, change into the installation directory.
Set the JAVA_HOME
environment variable to the directory where the JDK isinstalled. See Installing Ant for examples on how to do this for your operating system.
Note: The bootstrap process of Ant requires a greedy compiler like OpenJDK orOracle's javac. It does not work with gcj or kjc.
Make sure you have downloaded any auxiliary JARs required to build tasks you are interested in. These should be added tothe lib/optional directory of the source tree. See Library Dependenciesfor a list of JAR requirements for various features. Note that this will make the auxiliary JAR available for thebuilding of Ant only. For running Ant you will still need to make the JARs available as describedunder Installing Ant.
You can also get most of the auxiliary JAR files (i.e. the JAR files that various optional Ant tasks depend on) byrunning Ant on the fetch.xml build file. See Optional Tasks for instructionson how to do this.
Since Ant 1.7.0, Ant has a hard dependency on JUnit. The fetch.xml build script will downloadJUnit automatically, but if you don't use this you must install it manually into lib/optional (download itfrom JUnit.org) if you are using a source distribution of Ant.
Your are now ready to build Ant:
build -Ddist.dir=<directory-to-contain-Ant-distribution> dist (Windows)
sh build.sh -Ddist.dir=<directory-to-contain-Ant-distribution> dist (Unix)
This will create a binary distribution of Ant in the directory you specified.
Apache Ant 1.8 1 Bin Zip Download
The above action does the following:
- If necessary it will bootstrap the Ant code. Bootstrapping involves the manual compilation of enough Ant code to beable to run Ant. The bootstrapped Ant is used for the remainder of the build steps.
- Invokes the bootstrapped Ant with the parameters passed to the build script. In this case, these parameters definean Ant property value and specify the
dist
target in Ant's own build.xml file. - Create the ant.jar and ant-launcher.jar JAR files
- Create optional JARs for which the build had the relevant libraries. If a particular library is missingfrom lib/optional, then the matching ant-library JAR file will not be created. Forexample, ant-junit.jar is only built if there is a junit.jar in the lib/optionaldirectory.
On most occasions you will not need to explicitly bootstrap Ant since the build scripts do that for you. However, if thebuild file you are using makes use of features not yet compiled into the bootstrapped Ant, you will need to manuallybootstrap. Run bootstrap.bat (Windows) or bootstrap.sh (UNIX) to build a new bootstrap versionof Ant.
If you wish to install the build into the currentANT_HOME
directory, you can use:build install (Windows)
sh build.sh install (Unix)
You can avoid the lengthy Javadoc step, if desired, with:build install-lite (Windows)
sh build.sh install-lite (Unix)
This will only install the bin and lib directories.Both the install and install-lite targets will overwrite the current Ant versionin ANT_HOME
.
Ant's build script will try to set executable flags for its shell scripts on Unix(-like) systems. There are variousreasons why the chmod task might fail (like when you are running the build script as adifferent user than the one who installed Ant initially). In this case you can set the Antproperty chmod.fail
to false when starting the build like in
and any error to change permission will not result in a build failure.
Library Dependencies
The following libraries are needed in Ant's classpath if you are using the indicated feature. Note that only one of theregexp libraries is needed for use with the mappers (and Java includes a regexp implementation which Ant will findautomatically). You will also need to install the particular Ant optional JAR containing the task definitions to makethese tasks available. Please refer to the Installing Ant / Optional Tasks section above.
JAR Name | Needed For | Available At |
---|---|---|
jakarta-regexp-1.4.jar | regexp type with mappers (if you do not wish to use java.util.regex) | https://attic.apache.org/projects/jakarta-regexp.html |
jakarta-oro-2.0.8.jar | regexp type with mappers (if you do not wish to use java.util.regex) or ftp task with commons-net 1.4.1 | https://attic.apache.org/projects/jakarta-oro.html |
junit.jar | junit task (may be in classpath passed to task rather than Ant's classpath) | https://junit.org/ |
xalan.jar | junitreport task | https://xml.apache.org/xalan-j/ |
antlr.jar | antlr task | https://www.antlr.org/ |
bsf.jar | script task Note: Ant 1.6 and later require Apache BSF 2.3.0 or later. Note: BSF 2.4.0 is needed to use a 1.5R4 or later versions of Rhino JavaScript. Note: BSF 2.4.0 uses Commons Logging so it needs the commons-logging.jar. | https://commons.apache.org/bsf/ |
Groovy JARs | Groovy Ant tasks with bindings or Groovy with script and scriptdef tasks | http://groovy-lang.org/ Use either groovy-ant for Groovy Ant tasks with bindings or groovy-bsf for Groovy with script and scriptdef tasks (or groovy-all) |
netrexx.jar | netrexxc task, Rexx with script task | https://www.ibm.com/software/awdtools/netrexx/library.html |
rhino.jar (included in Java 7 runtime, replaced by Nashorn in Java 8 and later, dropped with Java 15) | JavaScript with script task Note: Apache BSF 2.4.0 works only with Rhino 1.5R4 and later versions. | https://www.mozilla.org/rhino/ |
graalvm js.jar and js-scriptengine.jar | JavaScript with script task for Java 15 and later | Java 15 has dropped Nashorn and GraalVM JavaScript is meant to replace it - outside of the Java class library. Note GraalVM JavaScript is not a drop-in replacement for Nashorn, see the script task documentation for details. Also GraakVM JavaScript requires a couple of more dependencies, in particular GraalVM regex, truffle, the GraalVM SDK and ICU. |
jython.jar | Python with script task | https://www.jython.org/ |
jacl.jar and tcljava.jar | TCL with script task | http://tcljava.sourceforge.net/ |
jtcl.jar | TCL with script task | https://jtcl-project.github.io/jtcl/ |
BeanShell JAR(s) | BeanShell with script task. Note: Ant requires BeanShell version 1.3 or later | http://www.beanshell.org/ |
jruby.jar | Ruby with script task | https://jruby.org/ |
judo.jar | Judo language with script task | used to be at http://www.judoscript.org/ which is now not available anymore. |
commons-logging.jar | CommonsLoggingListener | https://commons.apache.org/logging/ |
log4j.jar | Log4jListener | https://logging.apache.org/log4j/ |
commons-net.jar | ftp, rexec and telnet tasks A minimum version of commons-net of 1.4.0 is needed to compile Ant, earlier versions did not support the full range of configuration options. jakarta-oro 2.0.8 is required together with commons-net 1.4.x at run time. Note: do not use commons-net 3.2 because of performance issues | https://commons.apache.org/net/ |
bcel.jar | classfileset data type, JavaClassHelper used by the ClassConstants filter reader and optionally used by ejbjar task for dependency determination | https://commons.apache.org/bcel/ |
jakarta.mail.jar | mail task and deprecatedmimemail task | https://eclipse-ee4j.github.io/mail/ |
activation.jar
| mail task with MIME encoding, and deprecatedmimemail task | https://github.com/eclipse-ee4j/jaf |
jdepend.jar | jdepend task | https://github.com/clarkware/jdepend |
resolver.jar 1.1 or later | xmlcatalog datatype only if support for external catalog files is desired | https://xerces.apache.org/xml-commons/components/resolver/ |
jsch.jar 0.1.55 or later | sshexec and scp tasks | http://www.jcraft.com/jsch/ |
JAI—Java Advanced Imaging | image task | https://download.java.net/media/jai/builds/release/1_1_3/INSTALL.html |
jai-imageio-core.jar | imageio task for TIFF support on Java 8, as well as PCX, PNM, RAW support | https://github.com/jai-imageio/jai-imageio-core/releases |
XZ—XZ for Java 1.6 or later | xz and unxz tasks, xzresource, xz compression in tar/untar tasks | https://www.tukaani.org/xz/java.html |
JUnit 5 Platform jars:
| junitlauncher task. Additional libraries maybe needed depending on the selected test engines, details of which are available in that task's documentation | https://junit.org/junit5/ |
Troubleshooting
Diagnostics
Apache Ant 1.8 1 Bin Cooler
Ant has a built in diagnostics feature. If you run ant -diagnostics, Ant will look at its internal stateand print it out. This code will check and print the following things.
- Where Ant is running from. Sometimes you can be surprised.
- The version of ant.jar and of the ant-*.jar containing the optional tasks—andwhether they match
- Which JAR files are in
ANT_HOME/lib
- Which optional tasks are available. If a task is not listed as being available, either it is not present, orlibraries that it depends on are absent.
- XML Parser information
- JVM system properties
- The status of the temp directory. If this is not writable, or its timestamp is horribly wrong (possibleif it is on a network drive), a lot of tasks may fail with obscure error messages.
- The current time zone as Java sees it. If this is not what it should be for your location, then dependency logic mayget confused.
Running ant -diagnostics is a good way to check that Ant is installed. It is also a first step towardsself-diagnosis of any problem. Any configuration problem reported to the user mailing list will probably result inssomeone asking you to run the command and show the results, so save time by using it yourself.
For diagnostics from within IDE, use the diagnostics task to run the same tests asan Ant option. This can be added to a diagnostics target in a build file to see what tasks are available under the IDE,what the XML parser and classpath is, etc.
Apache Ant 1.8 1 Bin Storage Box
User Mailing List
If you cannot get Ant installed or working, the Ant user mailing list is the best place to start with anyproblem. Please do your homework first, make sure that it is not a CLASSPATH
problem, and run a diagnostics check to see what Ant thinks of its own state. Why the userlist, and not the developer list? Because there are more users than developers, so more people who can help you.
Please only file a bug report against Ant for a configuration/startup problem if there really is a fixable bug in Antrelated to configuration, such as it not working on a particular platform, with a certain JVM version, etc, or if youare advised to do it by the user mailing list.