- Salesforce Blogs -

How to Install and Use Salesforce ANT Migration Tools?

An ANT Migration Tool is a Java-based command-line utility for transferring metadata between a local directory and Salesforce Org. They are majorly used for retrieving or deploying Salesforce artifacts stored on local machine using the command line interface. This blog will give you information on what is ANT migration tools, and steps for installing and using ANT migration tools. Here are the reasons why should you use the ANT migration tool.

1). For multiple setup changes

If there is a development project for which you have to set up the testing environment with a lot of setup changes, then you can use ANT migration tools in that case. Making these changes with the help of a web interface is usually time-consuming and tough to manage.

2). For multistage release process

A typical development process follows iterative building, testing, and staging before a product is released to the production environment. A scripted retrieval or deployment of components can make this process more efficient, and this is possible through ANT migration tools only.

3). For repetitive deployment

If you need repetitive deployment, then you should use ANT migration tools. It allows you to retrieve the metadata in your organization, make edits, and deploy a subset of components. To repeat the process several times, you just have to call the deployment target again.

4). For scripted deployment

If someone prefers deployment in a scripted environment, then ANT migration tool can be the most familiar process here.

5). For scheduling batch deployments

If you want to deploy any product in midnight without disrupting users, you can pull down changes every day with ANT migration tools. salesforce Curriculum As we have discussed in the introduction part, An Ant Migration Tool is a Java-based command-line utility for transferring metadata between a local directory and Salesforce Org. So, what is Metadata API? Let us discuss the same in our next section in detail.

Metadata API – What you need to know?

Metadata API is a set of objects that contains customized information for an organization and the SOAP calls and manipulate those objects. Here are some facts what metadata API can do for an organization:

  • It works with setup configuration as XML metadata files.
  • It can migrate configuration changes between organizations.
  • It can create a set of tools to manage the organization and application metadata.

Although organizations can write their own apps for using Metadata API and SOAP calls, Salesforce offers ANT migration tools to retrieve and deploy metadata and APEX. Metadata API usually work in a package-centric way that contains one or more components as per the requirement. It is possible installing packages from Salesforce AppExchange. At the same time, ANT migration tools in Salesforce are limited to work in a single package or there is no package at all. A package can be divided into three major categories. Salesforce ANT Migration Tools

  • Unpackaged: if there are some native components in your organization like standard objects, it comes under the unpackaged package.
  • Unmanaged Package: It is typically used to distribute open-source templates or projects to provide basic building blocks for an application. Once components are retrieved from the unmanaged package, they can be edited by the organization. Developers who created unmanaged packages has no control over them once they are installed by an organization. These packages should not be used to migrate components from sandbox organization to the production organization. Instead, you can use Change Sets.
  • Managed Packages: A collection of application components that are posted as a single unit on AppExchange with a namespace or license are named as managed packages. They should be managed properly to support upgrades.

A single managed package can be used or installed by multiple organizations together. They are different from unmanaged packages because they are possible to manage even after the installation. However, managed packages obfuscate certain components to protect the intellectual property of an organization. salesforce quiz

Installing and Using ANT Migration Tools

Before you install ANT Migration Tools, you need Java and ANT installed on your system. After these installations, you can download ANT migration tools from Salesforce. If Java and ANT are installed in advance, you should not install them again. It is possible checking installation from the command prompt.

Steps to Install Java

Java 1.7.x version or later is recommended for better security controls and TLS security protocols. Here are the steps on how to verify the Java installation on your system.

  • Open the command prompt first.
  • At the prompt, type Java -version and press ENTER.
  • If you are using Java 7 then the output should look like this:

java version "1.7.0_21" java(TM) SE Runtime Environment (build 1.7.0_21-b11) java HotSpot (TM) 64-Bit Server VM (build 23.21-b01, mixed mode To enhance the security, you should Java 7 or later versions and ANT Migration Tools version 36.0 that contains TLS 1.2 for secure communication with the Salesforce. The tool avails TLS 1.2 explicitly. If you are using Java 8, then TLS 1.2 is used by default. For Java version 6.0, TLS 1.0 is used and not supported by the Salesforce these days. Alternatively, if you are using ANT Migration Tools 36.0 with Java 7, you don’t have to upgrade version of tools, but you can use ANT_OPS environment variable as shown below. –Dhttps:.protocols=TLSv1.1,TLSv1.2

This command enforces TLS 1.1 or TLS 1.2 for ANT Migration Tools on your local machine. If Java is not installed on your system, then you can install it from the link - http://www.oracle.com/technetwork/java/javase/downloads/index.html and get the latest version of Java JDK. Once the Java installation is finished, you can check again by typing the Java -version at the command prompt.

Steps to Install ANT

If you want to check either ANT is installed in advance or not, you should use the following steps:

  • Open the command prompt.
  • Now type ANT -version and press ENTER. The output should look like this as mentioned below. Apache ant version 1.7.0 compiled on December 13 2006

If ANT 1.5 or earlier version is installed, then you should upgrade it to the latest version. Please note that even if ANT is installed on your local machine, you should put bin directory on your local path. If you are using a Windows operating system, then you should set ANT_HOME or JAVA_HOME variables as follows.

  • You should download the latest version of ANT like 1.6 from the link http://ant.apache.org/bindownload.cgi to a local directory ANT_HOME. If files are already installed on your system, there is no need for further installation.
  • It is the right time to add the bin directory to your path. Only the bin and lib directories are used to run ANT generally.
  • For the Windows operating system, set the ANT_HOME environment variable and set the values where ANT is installed. Also, create the JAVA_HOME environment variable and set the path where JDK is installed.

Steps to Install ANT Migration Tools

Once you have installed JAVA and ANT successfully, it is the time to install ANT Migration Tools on your local machine. Here are the steps for installing ANT migration tools:

  • First of all, download the zip file of the Spring 19 for ANT Migration Tool. The downlink link does not demand any authentication from Salesforce. If you are logged in to the Salesforce, then you should log out first before you access the download link in the browser.
  • In the next step, you should save the zip file locally and extract the content to any directory of your choice.
  • ANT Migration Tools are using jar files in the distribution of zip files. If a previous version of tools is installed on your system, then delete the installed jar files and upgrade it with the latest version. You should update the path where jar files are installed.
  • When the zip file for the tool is extracted, several files are written to the specified location. You should understand the significance of each of the files and how to use them for your application.

Using ANT Migration Tools

Here is the general procedure to follow when using ANT Migration Tools to copy metadata from one Salesforce organization to another.

  • You should give connection information or add credentials of the source to the build. Properties file run the sample ANT tasks in build.xml.
  • Now retrieve or create targets in build.xml. The build.xml file is generally required to retrieve or deploy API calls.
  • In the third step, construct a project manifest in the package.xml file.
  • Run the ANT migration tools to retrieve metadata from Salesforce.
  • Now give connection information of destination or add destination credentials in build — properties file.
  • Run the ANT migration tools to deploy the metadata or perform deletions to Salesforce.

free salesforce demo

Common Migration Issues

There are several issues you may run into while migrating metadata or deploying changes. These issues are broadly grouped into three categories. Common Migration Issues

  • Metadata – You should follow certain considerations while migrating metadata from the system.
  • Connectivity – Sometimes, you may face issues in connectivity or polling for the result.
  • Test & Code coverage – The problem comes when you have to test APEX before deployment.

Final Words:

This is a meaningful guide on installing and using ANT migration tools in Salesforce. It gives you a depth idea of installation and step by step process to complete the installation in the first attempt. To know more on Salesforce and similar concepts, you should join the Salesforce certification course at JanBask training and gain practical knowledge to become a valuable IT resource and a demanding Salesforce professional.

    Janbask Training

    JanBask Training is a leading Global Online Training Provider through Live Sessions. The Live classes provide a blended approach of hands on experience along with theoretical knowledge which is driven by certified professionals.


Salesforce Upcoming Batches

Mon - Fri

6 Weeks

Mon - Fri

6 Weeks