ANT Introduction
Importance of build tool
Before learning Apache Ant, one must understand the need for a build tool. Why do we need Ant, or more specifically, why do we need a build tool?
The "Build" is a process that covers all the steps required to create a "deliverable" of your software. In the Java world, this typically includes:
- Generating sources (sometimes).
- Compiling sources.
- Compiling test sources.
- Executing tests (unit tests, integration tests, etc).
- Packaging (into jar, war, ejb-jar, ear).
- Running health checks (static analyzers like Checkstyle, Findbugs, PMD, test coverage, etc).
- Generating reports.
Importance of build tool
Before learning Apache Ant, one must understand the need for a build tool. Why do we need Ant, or more specifically, why do we need a build tool?
The "Build" is a process that covers all the steps required to create a "deliverable" of your software. In the Java world, this typically includes:
- Generating sources (sometimes).
- Compiling sources.
- Compiling test sources.
- Executing tests (unit tests, integration tests, etc).
- Packaging (into jar, war, ejb-jar, ear).
- Running health checks (static analyzers like Checkstyle, Findbugs, PMD, test coverage, etc).
- Generating reports.
A defined build process ensures that the software in your development project is built in the exact same manner each time a build is executed. As the build process becomes more complex -- for example, with EJB builds or additional tasks -- it becomes more necessary to achieve such standardization. You should establish, document, and automate the exact series of steps as much as possible.
What is Ant?
Ant is a piece of software that was originally built for automating software builds. It’s made by Apache, and its primarily purpose is to build Java applications. When you’re building software, you do several tasks(compile,packaging etc) that are identical each time you build or publish or deploy your project. It’s a waste of your valuable time to do this manually. Ant makes it incredibly easy to define a set of tasks that you can then execute with a few commands.
How to install Apache Ant on Windows
Follow the steps mentioned below for the ant installation
Step 1: Install Java JDK
The first step to installing ANT is actually to install the java JDK. Go to the Oracle JDK Download Page and download the JDK installer.
Run the installer and note the install directory for later. My own install ended up at "C:\Program Files\java\jdk[version number]"
Step 2: Download & Extract The Latest ANT Build
With java installed go ahead and download the latest ANT build zip file from the ANT Download Page . Then simply extract the zip file to a convenient location. I placed mine at "D:\apache-ant-1.9.3".
Step 3: Setup System Variables
Now we need to setup three system variables.
- "ANT_HOME" : The location we extracted the ANT zip file to.
- "JAVA_HOME" : The java JDK location.
- "PATH" : The existing PATH value plus the location of the ANT bin folder.
For my install I used the following values.
- "ANT_HOME" : D:\apache-ant-1.9.3
- "JAVA_HOME" : C:\Program Files (x86)\Java\jdk1.6.0_14
- "PATH" : C:\Program Files (x86)\Java\jdk1.6.0_14\bin
To set up the variables -> Right Click My Computer -> Click Properties -> Click Advanced system settings -> Click Environment Variables -> Click New System Variable.
Create new user variables JAVA_HOME, ANT HOME. Make sure to set to the proper locations for your environment.
Step 4: Verify Ant Installation
Now we need to setup three system variables.
Open up the command line - Type 'ant -version'. Version number should be displayed
If you got the screen like above then your ANT is work correctly on your Windows